Merge lp:~clint-fewbar/ubuntu/precise/sysvinit/wait-for-long-shutdown-jobs into lp:ubuntu/precise/sysvinit

Proposed by Clint Byrum on 2011-12-10
Status: Merged
Merged at revision: 166
Proposed branch: lp:~clint-fewbar/ubuntu/precise/sysvinit/wait-for-long-shutdown-jobs
Merge into: lp:ubuntu/precise/sysvinit
Diff against target: 138 lines (+65/-29)
3 files modified
debian/changelog (+14/-0)
debian/src/initscripts/etc/init.d/sendsigs (+23/-1)
debian/src/initscripts/etc/init.d/umountroot (+28/-28)
To merge this branch: bzr merge lp:~clint-fewbar/ubuntu/precise/sysvinit/wait-for-long-shutdown-jobs
Reviewer Review Type Date Requested Status
Steve Langasek 2011-12-10 Pending
Review via email: mp+85208@code.launchpad.net

Description of the change

Untested change to cause sysvinit to wait for any upstart jobs that upstart has already started shutting down.

To post a comment you must log in.
165. By Clint Byrum on 2011-12-12

also omit pids of stop/killed upstart jobs since we know they've
been killed already.

166. By Clint Byrum on 2011-12-12

d/src/initscripts/etc/init.d/umountroot: Check for init.upgraded
file in /var/run before clearing out /var/run. (LP: #886439)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2011-11-15 20:33:01 +0000
+++ debian/changelog 2011-12-12 23:11:25 +0000
@@ -1,3 +1,17 @@
1sysvinit (2.88dsf-13.10ubuntu6) UNRELEASED; urgency=low
2
3 * d/src/initscripts/etc/init.d/sendsigs: wait up to 300 extra
4 seconds for upstart jobs that have been killed. They will be sent
5 SIGKILL by upstart when their 'kill timeout' has been reached, so
6 we should trust the job's author to give the service a reasonable
7 amount of time to shut down. (LP: #688541)
8 * also omit pids of stop/killed upstart jobs since we know they've
9 been killed already.
10 * d/src/initscripts/etc/init.d/umountroot: Check for init.upgraded
11 file in /var/run before clearing out /var/run. (LP: #886439)
12
13 -- Clint Byrum <clint@ubuntu.com> Mon, 12 Dec 2011 15:07:04 -0800
14
1sysvinit (2.88dsf-13.10ubuntu5) precise; urgency=low15sysvinit (2.88dsf-13.10ubuntu5) precise; urgency=low
216
3 * d/service/service: Updated to use 'stop/start' instead of passing17 * d/service/service: Updated to use 'stop/start' instead of passing
418
=== modified file 'debian/src/initscripts/etc/init.d/sendsigs'
--- debian/src/initscripts/etc/init.d/sendsigs 2011-07-12 07:41:11 +0000
+++ debian/src/initscripts/etc/init.d/sendsigs 2011-12-12 23:11:25 +0000
@@ -22,8 +22,12 @@
22 /usr/share/apport/unkillable_shutdown $OMITPIDS22 /usr/share/apport/unkillable_shutdown $OMITPIDS
23}23}
2424
25upstart_killed_jobs () {
26 initctl list | grep 'stop/killed'
27}
28
25upstart_jobs () {29upstart_jobs () {
26 initctl list | grep start/ | sed -n -e "/process [0-9]/s/.*process //p"30 initctl list | grep -E '(start/|stop/killed)' | sed -n -e "/process [0-9]/s/.*process //p"
27}31}
2832
29do_stop () {33do_stop () {
@@ -106,6 +110,24 @@
106110
107 sleep 1111 sleep 1
108 done112 done
113
114 # Upstart has a method to set a kill timeout and so the job author
115 # may want us to wait longer than 10 seconds (as in the case of
116 # mysql). (LP: #688541)
117 #
118 # We will wait up to 300 seconds for any jobs in stop/killed state.
119 # Any kill timeout higher than that will be overridden by the need
120 # to shutdown. NOTE the re-use of seq from above, since we already
121 # waited up to 10 seconds for them.
122 while [ -n "$(upstart_killed_jobs)" ] ; do
123 seq=$(($seq+1))
124 if [ $seq -ge 300 ] ; then
125 break
126 fi
127
128 sleep 1
129 done
130
109 if [ -z "$alldead" ] ; then131 if [ -z "$alldead" ] ; then
110 #report_unkillable132 #report_unkillable
111 log_action_begin_msg "Killing all remaining processes"133 log_action_begin_msg "Killing all remaining processes"
112134
=== modified file 'debian/src/initscripts/etc/init.d/umountroot'
--- debian/src/initscripts/etc/init.d/umountroot 2011-07-14 05:02:25 +0000
+++ debian/src/initscripts/etc/init.d/umountroot 2011-12-12 23:11:25 +0000
@@ -16,6 +16,34 @@
1616
17do_stop () {17do_stop () {
18 [ "$VERBOSE" = no ] || log_action_begin_msg "Mounting root filesystem read-only"18 [ "$VERBOSE" = no ] || log_action_begin_msg "Mounting root filesystem read-only"
19 # Ask init to re-exec itself before we go down if it has been
20 # upgraded this cycle. It'll lose all its state, but at least
21 # it won't hold open files on the root filesystem (lp:#672177).
22 if [ -f /var/run/init.upgraded ]
23 then
24 old_map=$( cat /proc/1/maps )
25 map=$old_map
26 telinit u || :
27 i=0
28 timeout=5
29 while [ "$map" = "$old_map" ]
30 do
31 sleep 1
32 map=$( cat /proc/1/maps )
33 /usr/bin/logger "waiting for init to respawn"
34 i=$((i+1))
35 if [ $i -eq $timeout ] ; then
36 break
37 fi
38 done
39
40 if [ "$map" = "$old_map" ] ; then
41 /usr/bin/logger "FAIL: init failed to respawn in $timeout seconds - unmounting anyway"
42 else
43 /usr/bin/logger "SUCCESS: init respawned after $i seconds (within $timeout seconds timeout)"
44 fi
45 fi
46
19 # These directories must exist on the root filesystem as they are47 # These directories must exist on the root filesystem as they are
20 # targets for system mountpoints. We've just unmounted all other48 # targets for system mountpoints. We've just unmounted all other
21 # filesystems, so either they are mounted now (in which case the49 # filesystems, so either they are mounted now (in which case the
@@ -49,34 +77,6 @@
49 ln -nsf /run /lib/init/rw77 ln -nsf /run /lib/init/rw
50 fi78 fi
5179
52 # Ask init to re-exec itself before we go down if it has been
53 # upgraded this cycle. It'll lose all its state, but at least
54 # it won't hold open files on the root filesystem (lp:#672177).
55 if [ -f /var/run/init.upgraded ]
56 then
57 old_map=$( cat /proc/1/maps )
58 map=$old_map
59 telinit u || :
60 i=0
61 timeout=5
62 while [ "$map" = "$old_map" ]
63 do
64 sleep 1
65 map=$( cat /proc/1/maps )
66 /usr/bin/logger "waiting for init to respawn"
67 i=$((i+1))
68 if [ $i -eq $timeout ] ; then
69 break
70 fi
71 done
72
73 if [ "$map" = "$old_map" ] ; then
74 /usr/bin/logger "FAIL: init failed to respawn in $timeout seconds - unmounting anyway"
75 else
76 /usr/bin/logger "SUCCESS: init respawned after $i seconds (within $timeout seconds timeout)"
77 fi
78 fi
79
80 MOUNT_FORCE_OPT=80 MOUNT_FORCE_OPT=
81 [ "$(uname -s)" = "GNU/kFreeBSD" ] && MOUNT_FORCE_OPT=-f81 [ "$(uname -s)" = "GNU/kFreeBSD" ] && MOUNT_FORCE_OPT=-f
82 # This:82 # This:

Subscribers

People subscribed via source and target branches

to all changes: