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

Proposed by Clint Byrum
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 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

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

166. By Clint Byrum

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

Subscribers

People subscribed via source and target branches

to all changes: