Merge lp:~stgraber/ubuntu/precise/upstart/upstart-containers into lp:ubuntu/precise/upstart

Proposed by Stéphane Graber
Status: Merged
Merged at revision: 1362
Proposed branch: lp:~stgraber/ubuntu/precise/upstart/upstart-containers
Merge into: lp:ubuntu/precise/upstart
Diff against target: 227 lines (+113/-7)
12 files modified
debian/changelog (+24/-0)
debian/conf/console.conf (+11/-0)
debian/conf/container-detect.conf (+42/-0)
debian/conf/tty1.conf (+5/-1)
debian/conf/tty2.conf (+5/-1)
debian/conf/tty3.conf (+5/-1)
debian/conf/tty4.conf (+5/-1)
debian/conf/tty5.conf (+2/-1)
debian/conf/tty6.conf (+2/-1)
debian/control (+1/-1)
debian/running-in-container (+10/-0)
debian/upstart.install (+1/-0)
To merge this branch: bzr merge lp:~stgraber/ubuntu/precise/upstart/upstart-containers
Reviewer Review Type Date Requested Status
James Hunt (community) Approve
Steve Langasek Pending
Review via email: mp+90986@code.launchpad.net

Description of the change

Merge proposal to make our default upstart jobs container aware.

Add a new container-detect job:
 - emits 'container CONTAINER=type' if in a container
   (with type: lxc, lxc-libvirt, openvz or vserver)
 - emits 'not-container' otherwise
 - writes the container type to /run/container_type for use by
   running-in-container

Adds a new tool running-in-container printing the name of the technology
and return 0 if in a container, returning 1 otherwise.

Add a new console.conf getty job starting only in plain LXC containers.

Update tty[1234] to start on regular machines as well as LXC and
libvirt LXC.

Update tty[56] to only start on regular machines.

Add a Conflict on lxcguest (now useless and providing lxcconsole.conf
which would conflict with the new console.conf).

To post a comment you must log in.
Revision history for this message
Stéphane Graber (stgraber) wrote :

I tested these changes in a lxc container and in a Precise VM, both seemed to work fine.
I have a test package in my experimental PPA: https://launchpad.net/~stgraber/+archive/experimental/+packages

Revision history for this message
Stéphane Graber (stgraber) wrote :

Rebased on current packaging branch.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Looks good to me. Tested under kvm+lxc environments.

review: Approve

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 2012-02-03 14:19:41 +0000
3+++ debian/changelog 2012-02-06 04:44:21 +0000
4@@ -1,3 +1,27 @@
5+upstart (1.4-0ubuntu6) UNRELEASED; urgency=low
6+
7+ [ Serge Hallyn ]
8+ * debian/conf/container-detect.conf: an upstart job to track whether upstart
9+ detected itself running in a container.
10+ * debian/running-in-container: a script using container.conf to
11+ answer whether upstart is running in a container.
12+ * debian/conf/console.conf: run getty on /dev/console when running
13+ in a lxc container.
14+ * debian/control: conflict with lxcguest.
15+
16+ [ Stéphane Graber ]
17+ * debian/conf/container-detect.conf: extend to also detect OpenVZ and vserver
18+ as well as write the type in /run/container_type and emit either:
19+ - container CONTAINER=type
20+ (where type is lxc, lxc-libvirt, openvz or vserver)
21+ - not-container
22+ * debian/running-in-container: extend to also print the type of container.
23+ * Rebase debian/conf/console.conf on debian/conf/tty1.conf.
24+ * Update tty[1234].conf to start on regular machines and LXC containers.
25+ * Update tty[56].conf to only start on regular machines.
26+
27+ -- Stéphane Graber <stgraber@ubuntu.com> Tue, 31 Jan 2012 15:05:40 -0500
28+
29 upstart (1.4-0ubuntu5) precise; urgency=low
30
31 * Merge of important upstream log fixes to handle scenario attempts
32
33=== added file 'debian/conf/console.conf'
34--- debian/conf/console.conf 1970-01-01 00:00:00 +0000
35+++ debian/conf/console.conf 2012-02-06 04:44:21 +0000
36@@ -0,0 +1,11 @@
37+# console - getty
38+#
39+# This service maintains a getty on console from the point the system is
40+# started until it is shut down again.
41+
42+start on stopped rc RUNLEVEL=[2345] and container CONTAINER=lxc
43+
44+stop on runlevel [!2345]
45+
46+respawn
47+exec /sbin/getty -8 38400 console
48
49=== added file 'debian/conf/container-detect.conf'
50--- debian/conf/container-detect.conf 1970-01-01 00:00:00 +0000
51+++ debian/conf/container-detect.conf 2012-02-06 04:44:21 +0000
52@@ -0,0 +1,42 @@
53+description "Track if upstart is running in a container"
54+
55+start on mounted MOUNTPOINT=/run
56+
57+env container
58+env LIBVIRT_LXC_UUID
59+
60+emits container
61+emits not-container
62+
63+pre-start script
64+ # The "standard" way of telling if we are in a container
65+ # is to check for "container" in init's environment.
66+ # The code below is for cases where it's not set.
67+
68+ # Detect old-style libvirt
69+ if [ -z "$container" ]; then
70+ [ -n "$LIBVIRT_LXC_UUID" ] && container=lxc-libvirt
71+ fi
72+
73+ # Detect OpenVZ containers
74+ if [ -z "$container" ]; then
75+ [ -d /proc/vz ] && [ ! -d /proc/bc ] && container=openvz
76+ fi
77+
78+ # Detect Vserver containers
79+ if [ -z "$container" ]; then
80+ VXID="$(cat /proc/self/status | grep ^VxID | cut -f2)" || true
81+ [ "${VXID:-0}" -gt 1 ] && container=vserver
82+ fi
83+
84+ if [ -n "$container" ]; then
85+ echo "$container" > /run/container_type || true
86+ initctl emit --no-wait container CONTAINER=$container
87+ exit 0
88+ fi
89+
90+ # If not a container, stop there
91+ rm -f /run/container_type
92+ initctl emit --no-wait not-container
93+ stop
94+end script
95
96=== modified file 'debian/conf/tty1.conf'
97--- debian/conf/tty1.conf 2009-07-14 12:30:09 +0000
98+++ debian/conf/tty1.conf 2012-02-06 04:44:21 +0000
99@@ -3,7 +3,11 @@
100 # This service maintains a getty on tty1 from the point the system is
101 # started until it is shut down again.
102
103-start on stopped rc RUNLEVEL=[2345]
104+start on stopped rc RUNLEVEL=[2345] and (
105+ not-container or
106+ container CONTAINER=lxc or
107+ container CONTAINER=lxc-libvirt)
108+
109 stop on runlevel [!2345]
110
111 respawn
112
113=== modified file 'debian/conf/tty2.conf'
114--- debian/conf/tty2.conf 2009-07-14 12:30:09 +0000
115+++ debian/conf/tty2.conf 2012-02-06 04:44:21 +0000
116@@ -3,7 +3,11 @@
117 # This service maintains a getty on tty2 from the point the system is
118 # started until it is shut down again.
119
120-start on runlevel [23]
121+start on runlevel [23] and (
122+ not-container or
123+ container CONTAINER=lxc or
124+ container CONTAINER=lxc-libvirt)
125+
126 stop on runlevel [!23]
127
128 respawn
129
130=== modified file 'debian/conf/tty3.conf'
131--- debian/conf/tty3.conf 2009-07-14 12:30:09 +0000
132+++ debian/conf/tty3.conf 2012-02-06 04:44:21 +0000
133@@ -3,7 +3,11 @@
134 # This service maintains a getty on tty3 from the point the system is
135 # started until it is shut down again.
136
137-start on runlevel [23]
138+start on runlevel [23] and (
139+ not-container or
140+ container CONTAINER=lxc or
141+ container CONTAINER=lxc-libvirt)
142+
143 stop on runlevel [!23]
144
145 respawn
146
147=== modified file 'debian/conf/tty4.conf'
148--- debian/conf/tty4.conf 2009-07-14 12:30:09 +0000
149+++ debian/conf/tty4.conf 2012-02-06 04:44:21 +0000
150@@ -3,7 +3,11 @@
151 # This service maintains a getty on tty4 from the point the system is
152 # started until it is shut down again.
153
154-start on runlevel [23]
155+start on runlevel [23] and (
156+ not-container or
157+ container CONTAINER=lxc or
158+ container CONTAINER=lxc-libvirt)
159+
160 stop on runlevel [!23]
161
162 respawn
163
164=== modified file 'debian/conf/tty5.conf'
165--- debian/conf/tty5.conf 2009-07-14 12:30:09 +0000
166+++ debian/conf/tty5.conf 2012-02-06 04:44:21 +0000
167@@ -3,7 +3,8 @@
168 # This service maintains a getty on tty5 from the point the system is
169 # started until it is shut down again.
170
171-start on runlevel [23]
172+start on runlevel [23] and not-container
173+
174 stop on runlevel [!23]
175
176 respawn
177
178=== modified file 'debian/conf/tty6.conf'
179--- debian/conf/tty6.conf 2009-07-14 12:30:09 +0000
180+++ debian/conf/tty6.conf 2012-02-06 04:44:21 +0000
181@@ -3,7 +3,8 @@
182 # This service maintains a getty on tty6 from the point the system is
183 # started until it is shut down again.
184
185-start on runlevel [23]
186+start on runlevel [23] and not-container
187+
188 stop on runlevel [!23]
189
190 respawn
191
192=== modified file 'debian/control'
193--- debian/control 2012-01-09 10:10:08 +0000
194+++ debian/control 2012-02-06 04:44:21 +0000
195@@ -12,7 +12,7 @@
196 Depends: ${shlibs:Depends}, ${misc:Depends}, sysvinit-utils, sysv-rc, initscripts, mountall, ifupdown (>= 0.6.10ubuntu5)
197 Suggests: python, graphviz, bash-completion
198 Replaces: upstart-job, sysvinit, upstart-compat-sysv, startup-tasks, system-services
199-Conflicts: upstart-job, sysvinit, upstart-compat-sysv, startup-tasks, system-services
200+Conflicts: upstart-job, sysvinit, upstart-compat-sysv, startup-tasks, system-services, lxcguest
201 Provides: upstart-job, upstart-compat-sysv, startup-tasks, system-services
202 Breaks: libc6 (<< 2.12.1-0ubuntu12), friendly-recovery (<< 0.2.13)
203 Multi-Arch: foreign
204
205=== added file 'debian/running-in-container'
206--- debian/running-in-container 1970-01-01 00:00:00 +0000
207+++ debian/running-in-container 2012-02-06 04:44:21 +0000
208@@ -0,0 +1,10 @@
209+#!/bin/sh
210+# Return 0 if in a container, 1 if not
211+# if in a container, also print the container type
212+status container-detect 2>/dev/null | grep -q start
213+
214+if [ $? -eq 0 ]; then
215+ [ -f /run/container_type ] && cat /run/container_type
216+ exit 0
217+fi
218+exit 1
219
220=== modified file 'debian/upstart.install'
221--- debian/upstart.install 2010-12-20 16:03:33 +0000
222+++ debian/upstart.install 2012-02-06 04:44:21 +0000
223@@ -2,3 +2,4 @@
224 debian/upstart-job lib/init/
225 debian/apparmor-profile-load lib/init/
226 debian/migrate-inittab.pl usr/lib/upstart/
227+debian/running-in-container bin/

Subscribers

People subscribed via source and target branches