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=600
26 galera_sync_timeout=360
27 cluster_settle_timeout=1800
29 timestamp_file="$timestamp_dir/$update_identifier"
30 if [[ -a "$timestamp_file" ]]; then
31 echo "Not running for already-run timestamp \"$update_identifier\""
34 touch "$timestamp_file"
36 command_arguments=${command_arguments:-}
38 list_updates=$(yum list updates)
40 if [[ "$list_updates" == "" ]]; then
41 echo "No packages require updating"
45 pacemaker_status=$(systemctl is-active pacemaker)
46 pacemaker_dumpfile=$(mktemp)
48 if [[ "$pacemaker_status" == "active" ]] ; then
53 neutron-metadata-agent
54 neutron-openvswitch-agent
56 openstack-ceilometer-alarm-evaluator
57 openstack-ceilometer-alarm-notifier
58 openstack-ceilometer-api
59 openstack-ceilometer-central
60 openstack-ceilometer-collector
61 openstack-ceilometer-notification
63 openstack-cinder-scheduler
64 openstack-cinder-volume
66 openstack-glance-registry
68 openstack-heat-api-cfn
69 openstack-heat-api-cloudwatch
73 openstack-nova-conductor
74 openstack-nova-consoleauth
75 openstack-nova-novncproxy
76 openstack-nova-scheduler"
78 echo "Dumping Pacemaker config"
79 pcs cluster cib $pacemaker_dumpfile
81 echo "Checking for missing constraints"
83 if ! pcs constraint order show | grep "start openstack-nova-novncproxy-clone then start openstack-nova-api-clone"; then
84 pcs -f $pacemaker_dumpfile constraint order start openstack-nova-novncproxy-clone then openstack-nova-api-clone
87 if ! pcs constraint order show | grep "start rabbitmq-clone then start openstack-keystone-clone"; then
88 pcs -f $pacemaker_dumpfile constraint order start rabbitmq-clone then openstack-keystone-clone
91 if ! pcs constraint order show | grep "promote galera-master then start openstack-keystone-clone"; then
92 pcs -f $pacemaker_dumpfile constraint order promote galera-master then openstack-keystone-clone
95 if pcs resource | grep "haproxy-clone"; then
96 SERVICES="$SERVICES haproxy"
97 if ! pcs constraint order show | grep "start haproxy-clone then start openstack-keystone-clone"; then
98 pcs -f $pacemaker_dumpfile constraint order start haproxy-clone then openstack-keystone-clone
102 if ! pcs constraint order show | grep "start memcached-clone then start openstack-keystone-clone"; then
103 pcs -f $pacemaker_dumpfile constraint order start memcached-clone then openstack-keystone-clone
106 if ! pcs constraint order show | grep "promote redis-master then start openstack-ceilometer-central-clone"; then
107 pcs -f $pacemaker_dumpfile constraint order promote redis-master then start openstack-ceilometer-central-clone require-all=false
110 # ensure neutron constraints https://review.openstack.org/#/c/229466
111 # remove ovs-cleanup after server and add openvswitch-agent instead
112 if pcs constraint order show | grep "start neutron-server-clone then start neutron-ovs-cleanup-clone"; then
113 pcs -f $pacemaker_dumpfile constraint remove order-neutron-server-clone-neutron-ovs-cleanup-clone-mandatory
115 if ! pcs constraint order show | grep "start neutron-server-clone then start neutron-openvswitch-agent-clone"; then
116 pcs -f $pacemaker_dumpfile constraint order start neutron-server-clone then neutron-openvswitch-agent-clone
120 if ! pcs resource defaults | grep "resource-stickiness: INFINITY"; then
121 pcs -f $pacemaker_dumpfile resource defaults resource-stickiness=INFINITY
124 echo "Setting resource start/stop timeouts"
125 for service in $SERVICES; do
126 pcs -f $pacemaker_dumpfile resource update $service op start timeout=200s op stop timeout=200s
128 # mongod start timeout is higher, setting only stop timeout
129 pcs -f $pacemaker_dumpfile resource update mongod op start timeout=370s op stop timeout=200s
131 echo "Applying new Pacemaker config"
132 if ! pcs cluster cib-push $pacemaker_dumpfile; then
133 echo "ERROR failed to apply new pacemaker config"
137 echo "Pacemaker running, stopping cluster node and doing full package update"
138 node_count=$(pcs status xml | grep -o "<nodes_configured.*/>" | grep -o 'number="[0-9]*"' | grep -o "[0-9]*")
139 if [[ "$node_count" == "1" ]] ; then
140 echo "Active node count is 1, stopping node with --force"
141 pcs cluster stop --force
146 # clean leftover keepalived and radvd instances from neutron
147 # (can be removed when we remove neutron-netns-cleanup from cluster services)
148 # see https://review.gerrithub.io/#/c/248931/1/neutron-netns-cleanup.init
149 killall neutron-keepalived-state-change 2>/dev/null || :
150 kill $(ps ax | grep -e "keepalived.*\.pid-vrrp" | awk '{print $1}') 2>/dev/null || :
151 kill $(ps ax | grep -e "radvd.*\.pid\.radvd" | awk '{print $1}') 2>/dev/null || :
153 echo "Excluding upgrading packages that are handled by config management tooling"
154 command_arguments="$command_arguments --skip-broken"
155 for exclude in $(cat /var/lib/tripleo/installed-packages/* | sort -u); do
156 command_arguments="$command_arguments --exclude $exclude"
160 command=${command:-update}
161 full_command="yum -y $command $command_arguments"
162 echo "Running: $full_command"
164 result=$($full_command)
167 echo "yum return code: $return_code"
169 if [[ "$pacemaker_status" == "active" ]] ; then
170 echo "Starting cluster node"
173 hostname=$(hostname -s)
175 while [[ "$(pcs status | grep "^Online" | grep -F -o $hostname)" == "" ]]; do
178 if (( tnow-tstart > cluster_start_timeout )) ; then
179 echo "ERROR $hostname failed to join cluster in $cluster_start_timeout seconds"
186 while ! clustercheck; do
189 if (( tnow-tstart > galera_sync_timeout )) ; then
190 echo "ERROR galera sync timed out"
195 echo "Waiting for pacemaker cluster to settle"
196 if ! timeout -k 10 $cluster_settle_timeout crm_resource --wait; then
197 echo "ERROR timed out while waiting for the cluster to settle"
204 echo -n "true" > $heat_outputs_path.update_managed_packages
207 echo "Finished yum_update.sh on server $deploy_server_id at `date`"