should have some way to indicate shutdown or reboot
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Medium
|
Scott Moser |
Bug Description
At [1], I put in place change like below as a way to shut down cleanly, and
avoid the annoying messages cloud-init spews if you run /sbin/poweroff from
inside a user-data script.
Basically, at the end of my user-data I would do something like this:
# delay the poweroff to avoid annoying cloud-init messages
sh -fc 'i=0; while [ $i -lt 30 ] && i=$(($i+1)); do
state=$(status cloud-final);
set -- $state
case "$2" in
stop/*) poweroff; exit 0;;
esac
echo "$state [$2] after $i"
sleep 1
done
echo "giving up after 30 seconds"
poweroff' </dev/null &
That actually works fine, but its a bit more involved than it should be.
I can think of 2 ways to somewhat cleanly expose this:
cloud-init request-poweroff [type [delay]]
where 'type' would be 'reboot', 'poweroff' ...
and cloud-init would somehow handle making that happen "delay" seconds after
it finished cloud-final.
Secondly, it'd be nice to have that as a cloud-config option also.
#cloud-config
shutdown: reboot 30
request-poweroff could just put a marker file in /run that would be read when
cloud-final finished.
[1] https:/
Related branches
- Joshua Harlow (community): Approve
-
Diff: 307 lines (+268/-0)5 files modifiedChangeLog (+2/-0)
cloudinit/config/cc_power_state_change.py (+156/-0)
config/cloud.cfg (+1/-0)
doc/examples/cloud-config.txt (+21/-0)
tests/unittests/test_handler/test_handler_power_state.py (+88/-0)
Changed in cloud-init: | |
status: | New → Triaged |
importance: | Undecided → Medium |
Changed in cloud-init: | |
assignee: | nobody → Scott Moser (smoser) |
status: | Triaged → In Progress |
Changed in cloud-init: | |
status: | In Progress → Fix Released |
Tracked in Github Issues as https:/ /github. com/canonical/ cloud-init/ issues/ 2305