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 [ -f /.dockerenv ]; then
14 echo "Not running due to running inside a container"
18 if [[ -z "$update_identifier" ]]; then
19 echo "Not running due to unset update_identifier"
23 timestamp_dir=/var/lib/overcloud-yum-update
24 mkdir -p $timestamp_dir
26 # sanitise to remove unusual characters
27 update_identifier=${update_identifier//[^a-zA-Z0-9-_]/}
29 # seconds to wait for this node to rejoin the cluster after update
30 cluster_start_timeout=600
31 galera_sync_timeout=1800
32 cluster_settle_timeout=1800
34 timestamp_file="$timestamp_dir/$update_identifier"
35 if [[ -a "$timestamp_file" ]]; then
36 echo "Not running for already-run timestamp \"$update_identifier\""
39 touch "$timestamp_file"
42 # We include word boundaries in order to not match pacemaker_remote
43 if hiera -c /etc/puppet/hiera.yaml service_names | grep -q '\bpacemaker\b'; then
44 pacemaker_status=$(systemctl is-active pacemaker)
47 # (NB: when backporting this s/pacemaker_short_bootstrap_node_name/bootstrap_nodeid)
48 # This runs before the yum_update so we are guaranteed to run it even in the absence
49 # of packages to update (the check for -z "$update_identifier" guarantees that this
50 # is run only on overcloud stack update -i)
51 if [[ "$pacemaker_status" == "active" && \
52 "$(hiera -c /etc/puppet/hiera.yaml pacemaker_short_bootstrap_node_name | tr '[:upper:]' '[:lower:]')" == "$(facter hostname | tr '[:upper:]' '[:lower:]')" ]] ; then \
53 # OCF scripts don't cope with -eu
54 echo "Verifying if we need to fix up any IPv6 VIPs"
59 if [ $ret -ne 0 ]; then
60 echo "Fixing up IPv6 VIPs failed. Stopping here. (See https://bugs.launchpad.net/tripleo/+bug/1686357 for more info)"
65 command_arguments=${command_arguments:-}
67 # yum check-update exits 100 if updates are available
69 check_update=$(yum check-update 2>&1)
73 if [[ "$check_update_exit" == "1" ]]; then
74 echo "Failed to check for package updates"
77 elif [[ "$check_update_exit" != "100" ]]; then
78 echo "No packages require updating"
82 # special case https://bugs.launchpad.net/tripleo/+bug/1635205 +bug/1669714
83 special_case_ovs_upgrade_if_needed
85 if [[ "$pacemaker_status" == "active" ]] ; then
86 echo "Pacemaker running, stopping cluster node and doing full package update"
87 node_count=$(pcs status xml | grep -o "<nodes_configured.*/>" | grep -o 'number="[0-9]*"' | grep -o "[0-9]*")
88 if [[ "$node_count" == "1" ]] ; then
89 echo "Active node count is 1, stopping node with --force"
90 pcs cluster stop --force
95 echo "Upgrading openstack-puppet-modules and its dependencies"
96 yum -q -y update openstack-puppet-modules
97 yum deplist openstack-puppet-modules | awk '/dependency/{print $2}' | xargs yum -q -y update
98 echo "Upgrading other packages is handled by config management tooling"
99 echo -n "true" > $heat_outputs_path.update_managed_packages
103 command=${command:-update}
104 full_command="yum -q -y $command $command_arguments"
105 echo "Running: $full_command"
107 result=$($full_command)
110 echo "yum return code: $return_code"
112 if [[ "$pacemaker_status" == "active" ]] ; then
113 echo "Starting cluster node"
116 hostname=$(hostname -s)
118 while [[ "$(pcs status | grep "^Online" | grep -F -o $hostname)" == "" ]]; do
121 if (( tnow-tstart > cluster_start_timeout )) ; then
122 echo "ERROR $hostname failed to join cluster in $cluster_start_timeout seconds"
128 RETVAL=$( pcs resource show galera-master | grep wsrep_cluster_address | grep -q `crm_node -n` ; echo $? )
130 if [[ $RETVAL -eq 0 && -e /etc/sysconfig/clustercheck ]]; then
132 while ! clustercheck; do
135 if (( tnow-tstart > galera_sync_timeout )) ; then
136 echo "ERROR galera sync timed out"
142 echo "Waiting for pacemaker cluster to settle"
143 if ! timeout -k 10 $cluster_settle_timeout crm_resource --wait; then
144 echo "ERROR timed out while waiting for the cluster to settle"
152 echo "Finished yum_update.sh on server $deploy_server_id at `date` with return code: $return_code"