Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crowbar: do a graceful shutdown/reboot when invoked via crowbar (bsc#1047636) #1271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use systemd here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does systemd help with reboot? is there a reboot command with systemd?

end
end
result
Expand Down