Skip to content

Commit

Permalink
crowbar: do a graceful shutdown/reboot when invoked via crowbar
Browse files Browse the repository at this point in the history
(bsc#1047636)

Currently there is a hard reboot executed which is interrupting
a currently pending chef-client run. Normally that shouldn't be
a problem but in the HA cluster case it can cause significant harm.
  • Loading branch information
dirkmueller committed Jul 18, 2017
1 parent 765ef67 commit e8243b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ wait_for_admin_server() {
return 0
}

wait_for_chef_run_finish() {

local tries_left=300
while [[ $tries_left > 0 ]] ; do
if [ ! -r /var/log/chef/client.log ] || grep -q "Chef Run complete" /var/log/chef/client.log; then
break
fi
tries_left=$(($tries_left-1))
sleep 1
done
}

sync_time() {
if [ -z "$VALID_NTP_SERVERS" ]; then
echo_verbose "Skipping time synchronization..."
Expand Down Expand Up @@ -508,6 +520,11 @@ elif [ "$MODE" == "stop" ]; then
final_state="shutdown"
[ "$RUNLEVEL" == "6" ] && final_state="reboot"

# Be graceful to a running chef-client run
wait_for_chef_run_finish

systemctl stop chef-client.service

echo_debug "Stopping with state=$final_state (runlevel $RUNLEVEL)"

HOSTNAME=$(hostname -f)
Expand Down
2 changes: 1 addition & 1 deletion crowbar_framework/app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ def set_state(state)
if @node[:platform_family] == "windows"
net_rpc_cmd(:power_cycle)
else
ssh_cmd("/sbin/reboot")
ssh_cmd("/usr/sbin/crowbar_join --stop || /sbin/reboot")
end
end
result
Expand Down

0 comments on commit e8243b8

Please # to comment.