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"
41 command_arguments=${command_arguments:-}
43 list_updates=$(yum list updates)
45 if [[ "$list_updates" == "" ]]; then
46 echo "No packages require updating"
50 pacemaker_status=$(systemctl is-active pacemaker || :)
52 # Fix the redis/rabbit resource start/stop timeouts. See https://bugs.launchpad.net/tripleo/+bug/1633455
53 # and https://bugs.launchpad.net/tripleo/+bug/1634851
54 if [[ "$pacemaker_status" == "active" && \
55 "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]] ; then
56 if pcs resource show rabbitmq | grep -E "start.*timeout=100"; then
57 pcs resource update rabbitmq op start timeout=200s
59 if pcs resource show rabbitmq | grep -E "stop.*timeout=90"; then
60 pcs resource update rabbitmq op stop timeout=200s
62 if pcs resource show redis | grep -E "start.*timeout=120"; then
63 pcs resource update redis op start timeout=200s
65 if pcs resource show redis | grep -E "stop.*timeout=120"; then
66 pcs resource update redis op stop timeout=200s
70 if [[ "$pacemaker_status" == "active" ]] ; then
71 echo "Pacemaker running, stopping cluster node and doing full package update"
72 node_count=$(pcs status xml | grep -o "<nodes_configured.*/>" | grep -o 'number="[0-9]*"' | grep -o "[0-9]*")
73 if [[ "$node_count" == "1" ]] ; then
74 echo "Active node count is 1, stopping node with --force"
75 pcs cluster stop --force
80 echo "Upgrading openstack-puppet-modules and its dependencies"
81 yum -q -y update openstack-puppet-modules
82 yum deplist openstack-puppet-modules | awk '/dependency/{print $2}' | xargs yum -q -y update
83 echo "Upgrading other packages is handled by config management tooling"
84 echo -n "true" > $heat_outputs_path.update_managed_packages
88 command=${command:-update}
89 full_command="yum -q -y $command $command_arguments"
90 echo "Running: $full_command"
92 result=$($full_command)
95 echo "yum return code: $return_code"
97 # Writes any changes caused by alterations to os-net-config and bounces the
98 # interfaces *before* restarting the cluster.
99 os-net-config -c /etc/os-net-config/config.json -v --detailed-exit-codes
101 if [[ $RETVAL == 2 ]]; then
102 echo "os-net-config: interface configuration files updated successfully"
103 elif [[ $RETVAL != 0 ]]; then
104 echo "ERROR: os-net-config configuration failed"
108 if [[ "$pacemaker_status" == "active" ]] ; then
109 echo "Starting cluster node"
112 hostname=$(hostname -s)
114 while [[ "$(pcs status | grep "^Online" | grep -F -o $hostname)" == "" ]]; do
117 if (( tnow-tstart > cluster_start_timeout )) ; then
118 echo "ERROR $hostname failed to join cluster in $cluster_start_timeout seconds"
125 while ! clustercheck; do
128 if (( tnow-tstart > galera_sync_timeout )) ; then
129 echo "ERROR galera sync timed out"
134 echo "Waiting for pacemaker cluster to settle"
135 if ! timeout -k 10 $cluster_settle_timeout crm_resource --wait; then
136 echo "ERROR timed out while waiting for the cluster to settle"
143 echo "Finished yum_update.sh on server $deploy_server_id at `date`"