3 # A heat-config-script which runs yum update during a stack-update.
5 # deploy_action - yum will only be run if this is UPDATE
6 # update_identifier - yum will only run for previously unused values of update_identifier
7 # command - yum sub-command to run, defaults to "update"
8 # command_arguments - yum command arguments, defaults to ""
10 echo "Started yum_update.sh on server $deploy_server_id at `date`"
11 echo -n "false" > $heat_outputs_path.update_managed_packages
13 if [[ -z "$update_identifier" ]]; then
14 echo "Not running due to unset update_identifier"
18 timestamp_dir=/var/lib/overcloud-yum-update
19 mkdir -p $timestamp_dir
21 # sanitise to remove unusual characters
22 update_identifier=${update_identifier//[^a-zA-Z0-9-_]/}
24 # seconds to wait for this node to rejoin the cluster after update
25 cluster_start_timeout=360
27 timestamp_file="$timestamp_dir/$update_identifier"
28 if [[ -a "$timestamp_file" ]]; then
29 echo "Not running for already-run timestamp \"$update_identifier\""
32 touch "$timestamp_file"
34 command_arguments=${command_arguments:-}
36 list_updates=$(yum list updates)
38 if [[ "$list_updates" == "" ]]; then
39 echo "No packages require updating"
43 pacemaker_status=$(systemctl is-active pacemaker)
45 if [[ "$pacemaker_status" == "active" ]] ; then
46 echo "Checking for and adding missing constraints"
48 if ! pcs constraint order show | grep "start openstack-nova-novncproxy-clone then start openstack-nova-api-clone"; then
49 pcs constraint order start openstack-nova-novncproxy-clone then openstack-nova-api-clone
52 if ! pcs constraint order show | grep "start rabbitmq-clone then start openstack-keystone-clone"; then
53 pcs constraint order start rabbitmq-clone then openstack-keystone-clone
56 if ! pcs constraint order show | grep "promote galera-master then start openstack-keystone-clone"; then
57 pcs constraint order promote galera-master then openstack-keystone-clone
60 if ! pcs constraint order show | grep "start haproxy-clone then start openstack-keystone-clone"; then
61 pcs constraint order start haproxy-clone then openstack-keystone-clone
64 if ! pcs constraint order show | grep "start memcached-clone then start openstack-keystone-clone"; then
65 pcs constraint order start memcached-clone then openstack-keystone-clone
68 if ! pcs constraint order show | grep "promote redis-master then start openstack-ceilometer-central-clone"; then
69 pcs constraint order promote redis-master then start openstack-ceilometer-central-clone require-all=false
72 if ! pcs resource defaults | grep "resource-stickiness: INFINITY"; then
73 pcs resource defaults resource-stickiness=INFINITY
76 echo "Pacemaker running, stopping cluster node and doing full package update"
77 node_count=$(pcs status xml | grep -o "<nodes_configured.*/>" | grep -o 'number="[0-9]*"' | grep -o "[0-9]*")
78 if [[ "$node_count" == "1" ]] ; then
79 echo "Active node count is 1, stopping node with --force"
80 pcs cluster stop --force
85 echo "Excluding upgrading packages that are handled by config management tooling"
86 command_arguments="$command_arguments --skip-broken"
87 for exclude in $(cat /var/lib/tripleo/installed-packages/* | sort -u); do
88 command_arguments="$command_arguments --exclude $exclude"
92 command=${command:-update}
93 full_command="yum -y $command $command_arguments"
94 echo "Running: $full_command"
96 result=$($full_command)
99 echo "yum return code: $return_code"
101 if [[ "$pacemaker_status" == "active" ]] ; then
102 echo "Starting cluster node"
105 hostname=$(hostname -s)
107 while [[ "$(pcs status | grep "^Online" | grep -F -o $hostname)" == "" ]]; do
110 if (( tnow-tstart > cluster_start_timeout )) ; then
111 echo "ERROR $hostname failed to join cluster in $cluster_start_timeout seconds"
119 echo -n "true" > $heat_outputs_path.update_managed_packages
122 echo "Finished yum_update.sh on server $deploy_server_id at `date`"