should have some way to indicate shutdown or reboot

Bug #1064665 reported by Scott Moser
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
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;;
    echo "$state [$2] after $i"
    sleep 1
  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.
  shutdown: reboot 30

request-poweroff could just put a marker file in /run that would be read when
cloud-final finished.


Related branches

Scott Moser (smoser)
Changed in cloud-init:
status: New → Triaged
importance: Undecided → Medium
Scott Moser (smoser)
Changed in cloud-init:
assignee: nobody → Scott Moser (smoser)
status: Triaged → In Progress
Scott Moser (smoser)
Changed in cloud-init:
status: In Progress → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.