Merge lp:~smoser/maas/cleaner-shutdown into lp:maas/trunk

Proposed by Scott Moser on 2012-10-09
Status: Merged
Approved by: Scott Moser on 2012-10-10
Approved revision: 1246
Merged at revision: 1250
Proposed branch: lp:~smoser/maas/cleaner-shutdown
Merge into: lp:maas/trunk
Diff against target: 61 lines (+30/-5)
2 files modified
contrib/preseeds_v2/enlist_userdata (+15/-1)
etc/maas/commissioning-user-data (+15/-4)
To merge this branch: bzr merge lp:~smoser/maas/cleaner-shutdown
Reviewer Review Type Date Requested Status
Julian Edwards (community) 2012-10-09 Approve on 2012-10-10
Review via email: mp+128807@code.launchpad.net

Commit Message

fix annoying cloud-init warnings caused by shutting down

when /sbin/shutdown is called from a user-data script, it ends up
making upstart kill syslog or even cloud-init itself, and cloud-init
is somewhat annoying about it to the console.

This ensures that cloud-final (the job that runs user-scripts) has
finished before shutting down.

Description of the Change

fix annoying cloud-init warnings caused by shutting down

when /sbin/shutdown is called from a user-data script, it ends up
making upstart kill syslog or even cloud-init itself, and cloud-init
is somewhat annoying about it to the console.

This ensures that cloud-final (the job that runs user-scripts) has
finished before shutting down.

To post a comment you must log in.
Julian Edwards (julian-edwards) wrote :

Is there any way of factoring the common code in the enlist and commissioning user data? If there's a bug in it (which is hard to tell, since we don't have tests) then it'll be in two places.

16 + echo "$state [$2] after $i"
39 + echo "$state [$2] after $i"

This is a poor message, can you make it something like:
"After $i seconds, cloud-final still in state $2"

and then at the top of the function please add something like
echo "Waiting for cloud-final to shut down."

Also, some capital letters and punctuation would not go amiss (we're sticklers for that in the Launchpad^WCloud Engineering team).

Approved if you ran and tested this.

review: Approve
Scott Moser (smoser) wrote :

This change removes the polling and the status output.
Reguarding the copied code, I dont like it either.

We can and should re-factor the way user-data is created so that we can re-use the code more effectively. Thats a more invasive change though.

MAAS Lander (maas-lander) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'contrib/preseeds_v2/enlist_userdata'
2--- contrib/preseeds_v2/enlist_userdata 2012-10-10 04:46:36 +0000
3+++ contrib/preseeds_v2/enlist_userdata 2012-10-10 14:08:26 +0000
4@@ -212,9 +212,23 @@
5 sleep 60
6 [ -e $bfile ] && exit 0
7 fi
8- poweroff
9+ - &write_poweroff_job |
10+ cat >/etc/init/maas-poweroff.conf <<EOF
11+ description "poweroff when maas task is done"
12+ start on stopped cloud-final
13+ console output
14+ task
15+ script
16+ [ ! -e /tmp/block-poweroff ] || exit 0
17+ poweroff
18+ end script
19+ EOF
20+ # reload required due to lack of inotify in overlayfs (LP: #882147)
21+ initctl reload-configuration
22+
23
24 packages: [ maas-enlist, freeipmi-tools ]
25 output: {all: '| tee -a /var/log/cloud-init-output.log'}
26 runcmd:
27 - [ sh, -c, *maas_enlist ]
28+ - [ sh, -c, *write_poweroff_job ]
29
30=== modified file 'etc/maas/commissioning-user-data'
31--- etc/maas/commissioning-user-data 2012-10-09 18:51:53 +0000
32+++ etc/maas/commissioning-user-data 2012-10-10 14:08:26 +0000
33@@ -93,13 +93,24 @@
34 exit 1
35 }
36
37-shutdown() {
38- echo "Finished, powering off."
39- /sbin/shutdown -P now
40+write_poweroff_job() {
41+ cat >/etc/init/maas-poweroff.conf <<EOF
42+ description "poweroff when maas task is done"
43+ start on stopped cloud-final
44+ console output
45+ task
46+ script
47+ [ ! -e /tmp/block-poweroff ] || exit 0
48+ poweroff
49+ end script
50+EOF
51+ # reload required due to lack of inotify in overlayfs (LP: #882147)
52+ initctl reload-configuration
53 }
54
55 main() {
56- trap shutdown EXIT
57+ write_poweroff_job
58+
59 # Install tools and load modules.
60 aptget update
61 aptget install freeipmi-tools