Merge lp:~kampka/ubuntu/quantal/lxc/upstart-instance into lp:ubuntu/quantal/lxc

Proposed by Christian Kampka
Status: Work in progress
Proposed branch: lp:~kampka/ubuntu/quantal/lxc/upstart-instance
Merge into: lp:ubuntu/quantal/lxc
Diff against target: 98 lines (+32/-17) (has conflicts)
4 files modified
debian/changelog (+6/-0)
debian/lxc.lxc-instance.upstart (+23/-0)
debian/lxc.upstart (+2/-17)
debian/rules (+1/-0)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~kampka/ubuntu/quantal/lxc/upstart-instance
Reviewer Review Type Date Requested Status
Serge Hallyn Approve
Ubuntu branches Pending
Review via email: mp+123995@code.launchpad.net

Description of the change

This change proposes that upstart takes care of running and managing lxc container instances instead of having them run as daemons.
This has some advantages:
 - lxc containers can benefit from upstart supervision, eg. respawn can be easily enabled, and parallel job execution
   At the moment with serial execution, stopping the lxc service can (worst case)
   take up to n times $LXC_SHUTDOWN_TIMEOUT, n being the number of containers running.
   Having upstart manage instance shutdown avoids this problem.
 - Administrators can write upstart jobs that run on lxc container startup/shutdown of a specific container.
   Consider for example a job that enables transparent port 80 routing once a container names "squid" comes up.

I have not found any possibility to assign the instance kill timeout dynamically so for now it's fixed at two minutes.

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :

Just a couple of points:

- It would be extremely useful if you added a 'usage' stanza to allow admins to see how to run the lxc-instance job as currently, if you forget to specify it, the job does nothing, silently.

  For example, add something like:

  usage "NAME=name of LXC instance, CONFIG=full path to configuration file"

  See http://upstart.ubuntu.com/cookbook/#usage

- Shouldn't that 'stop on' condition be 'stop on stopping lxc' ('stopping' rather than 'stopped')?

144. By Christian Kampka on 2012-09-17

* [Upstart]
  - add usage stanza to lxc-instance job
  - stop lxc-instance on 'stopping lxc'

Revision history for this message
Christian Kampka (kampka) wrote :

Thanks for the input, agreed on both points.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Thanks, Christian, I really like it.

I've changed the topic of the bug to add '[FFE]' - it's probably too late for quantal, but I'll see whether the release team is willing to approve this.

James Hunt,

With Christian having addressed your feedback, do you have any other comments?

review: Approve
Revision history for this message
St├ęphane Graber (stgraber) wrote :

Marking as work in progress as it's been rejected for Quantal. Can you resubmit it for R once the archive opens next month?

Thanks for your work.

Unmerged revisions

144. By Christian Kampka on 2012-09-17

* [Upstart]
  - add usage stanza to lxc-instance job
  - stop lxc-instance on 'stopping lxc'

143. By Christian Kampka on 2012-09-12

Have upstart run lxc instances

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2012-09-14 11:45:46 +0000
+++ debian/changelog 2012-09-17 10:17:18 +0000
@@ -11,6 +11,7 @@
1111
12 [ Serge Hallyn ]12 [ Serge Hallyn ]
13 * 0214-give-pclose-errno: help debug pclose failures when lxc runs scripts.13 * 0214-give-pclose-errno: help debug pclose failures when lxc runs scripts.
14<<<<<<< TREE
14 * 0215-lxc-clone-name-arg: fix incorrect checking for --name argument.15 * 0215-lxc-clone-name-arg: fix incorrect checking for --name argument.
15 (LP: #1049914)16 (LP: #1049914)
16 * 0216-hook-kmsg-to-console: link /dev/kmsg to /dev/console so init log17 * 0216-hook-kmsg-to-console: link /dev/kmsg to /dev/console so init log
@@ -49,6 +50,11 @@
49 (LP: #1050351)50 (LP: #1050351)
5051
51 -- Serge Hallyn <serge.hallyn@ubuntu.com> Thu, 13 Sep 2012 12:02:45 -050052 -- Serge Hallyn <serge.hallyn@ubuntu.com> Thu, 13 Sep 2012 12:02:45 -0500
53=======
54 * Have upstart run lxc instances
55
56 -- Serge Hallyn <serge.hallyn@ubuntu.com> Thu, 06 Sep 2012 22:08:55 -0500
57>>>>>>> MERGE-SOURCE
5258
53lxc (0.8.0~rc1-4ubuntu33) quantal; urgency=low59lxc (0.8.0~rc1-4ubuntu33) quantal; urgency=low
5460
5561
=== added file 'debian/lxc.lxc-instance.upstart'
--- debian/lxc.lxc-instance.upstart 1970-01-01 00:00:00 +0000
+++ debian/lxc.lxc-instance.upstart 2012-09-17 10:17:18 +0000
@@ -0,0 +1,23 @@
1description "lxc instance"
2author "Christian Kampka <chris@emerge-life.de>"
3
4stop on stopping lxc
5
6# wait for 120 seconds for container to shutdown before killing it
7kill timeout 120
8
9# send SIGPWR to container to trigger a shutdown (see lxc-shutdown(1))
10kill signal SIGPWR
11
12
13instance $NAME
14usage "NAME=name of LXC instance, CONFIG=full path to configuration file"
15
16pre-start script
17
18 lxc-info -n $NAME 2>/dev/null | grep state | grep -q "RUNNING" && {stop; exit 0; }
19 [ -f $CONFIG ] || {stop; exit 0; }
20
21end script
22
23exec lxc-start -n $NAME -f $CONFIG
024
=== modified file 'debian/lxc.upstart'
--- debian/lxc.upstart 2012-05-07 21:22:26 +0000
+++ debian/lxc.upstart 2012-09-17 10:17:18 +0000
@@ -5,7 +5,6 @@
5stop on starting rc RUNLEVEL=[016]5stop on starting rc RUNLEVEL=[016]
66
7env LXC_AUTO="false"7env LXC_AUTO="false"
8env LXC_SHUTDOWN_TIMEOUT="120"
98
10pre-start script9pre-start script
11 [ -f /etc/default/lxc ] && . /etc/default/lxc10 [ -f /etc/default/lxc ] && . /etc/default/lxc
@@ -24,20 +23,6 @@
24 ls /etc/lxc/auto/* > /dev/null 2>&1 || exit 0;23 ls /etc/lxc/auto/* > /dev/null 2>&1 || exit 0;
25 for f in /etc/lxc/auto/*; do24 for f in /etc/lxc/auto/*; do
26 c="$(basename $f .conf)"25 c="$(basename $f .conf)"
27 lxc-info -n $c 2>/dev/null | grep state | grep -q "RUNNING" || lxc-start -n $c -f $f -d26 start lxc-instance NAME=$c CONFIG=$f
28 done27 done
29end script
30
31post-stop script
32 [ -f /etc/default/lxc ] && . /etc/default/lxc
33
34 [ "x$LXC_AUTO" = "xtrue" ] || { exit 0; }
35
36 ls /etc/lxc/auto/* > /dev/null 2>&1 || exit 0;
37 for f in /etc/lxc/auto/*; do
38 c="$(basename $f .conf)"
39 lxc-shutdown -n $c -w -t $LXC_SHUTDOWN_TIMEOUT &
40 done
41
42 wait
43end script28end script
4429
=== modified file 'debian/rules'
--- debian/rules 2012-09-13 15:46:54 +0000
+++ debian/rules 2012-09-17 10:17:18 +0000
@@ -92,6 +92,7 @@
92override_dh_installinit:92override_dh_installinit:
93 dh_installinit --no-restart-on-upgrade --name=lxc93 dh_installinit --no-restart-on-upgrade --name=lxc
94 dh_installinit --no-restart-on-upgrade --name=lxc-net94 dh_installinit --no-restart-on-upgrade --name=lxc-net
95 dh_installinit --no-restart-on-upgrade --name=lxc-instance
9596
96override_dh_strip:97override_dh_strip:
97 dh_strip --dbg-package=lxc-dbg98 dh_strip --dbg-package=lxc-dbg

Subscribers

People subscribed via source and target branches