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.
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'

Christian Kampka (kampka) wrote :

Thanks for the input, agreed on both points.

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
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
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-09-14 11:45:46 +0000
3+++ debian/changelog 2012-09-17 10:17:18 +0000
4@@ -11,6 +11,7 @@
5
6 [ Serge Hallyn ]
7 * 0214-give-pclose-errno: help debug pclose failures when lxc runs scripts.
8+<<<<<<< TREE
9 * 0215-lxc-clone-name-arg: fix incorrect checking for --name argument.
10 (LP: #1049914)
11 * 0216-hook-kmsg-to-console: link /dev/kmsg to /dev/console so init log
12@@ -49,6 +50,11 @@
13 (LP: #1050351)
14
15 -- Serge Hallyn <serge.hallyn@ubuntu.com> Thu, 13 Sep 2012 12:02:45 -0500
16+=======
17+ * Have upstart run lxc instances
18+
19+ -- Serge Hallyn <serge.hallyn@ubuntu.com> Thu, 06 Sep 2012 22:08:55 -0500
20+>>>>>>> MERGE-SOURCE
21
22 lxc (0.8.0~rc1-4ubuntu33) quantal; urgency=low
23
24
25=== added file 'debian/lxc.lxc-instance.upstart'
26--- debian/lxc.lxc-instance.upstart 1970-01-01 00:00:00 +0000
27+++ debian/lxc.lxc-instance.upstart 2012-09-17 10:17:18 +0000
28@@ -0,0 +1,23 @@
29+description "lxc instance"
30+author "Christian Kampka <chris@emerge-life.de>"
31+
32+stop on stopping lxc
33+
34+# wait for 120 seconds for container to shutdown before killing it
35+kill timeout 120
36+
37+# send SIGPWR to container to trigger a shutdown (see lxc-shutdown(1))
38+kill signal SIGPWR
39+
40+
41+instance $NAME
42+usage "NAME=name of LXC instance, CONFIG=full path to configuration file"
43+
44+pre-start script
45+
46+ lxc-info -n $NAME 2>/dev/null | grep state | grep -q "RUNNING" && {stop; exit 0; }
47+ [ -f $CONFIG ] || {stop; exit 0; }
48+
49+end script
50+
51+exec lxc-start -n $NAME -f $CONFIG
52
53=== modified file 'debian/lxc.upstart'
54--- debian/lxc.upstart 2012-05-07 21:22:26 +0000
55+++ debian/lxc.upstart 2012-09-17 10:17:18 +0000
56@@ -5,7 +5,6 @@
57 stop on starting rc RUNLEVEL=[016]
58
59 env LXC_AUTO="false"
60-env LXC_SHUTDOWN_TIMEOUT="120"
61
62 pre-start script
63 [ -f /etc/default/lxc ] && . /etc/default/lxc
64@@ -24,20 +23,6 @@
65 ls /etc/lxc/auto/* > /dev/null 2>&1 || exit 0;
66 for f in /etc/lxc/auto/*; do
67 c="$(basename $f .conf)"
68- lxc-info -n $c 2>/dev/null | grep state | grep -q "RUNNING" || lxc-start -n $c -f $f -d
69- done
70-end script
71-
72-post-stop script
73- [ -f /etc/default/lxc ] && . /etc/default/lxc
74-
75- [ "x$LXC_AUTO" = "xtrue" ] || { exit 0; }
76-
77- ls /etc/lxc/auto/* > /dev/null 2>&1 || exit 0;
78- for f in /etc/lxc/auto/*; do
79- c="$(basename $f .conf)"
80- lxc-shutdown -n $c -w -t $LXC_SHUTDOWN_TIMEOUT &
81- done
82-
83- wait
84+ start lxc-instance NAME=$c CONFIG=$f
85+ done
86 end script
87
88=== modified file 'debian/rules'
89--- debian/rules 2012-09-13 15:46:54 +0000
90+++ debian/rules 2012-09-17 10:17:18 +0000
91@@ -92,6 +92,7 @@
92 override_dh_installinit:
93 dh_installinit --no-restart-on-upgrade --name=lxc
94 dh_installinit --no-restart-on-upgrade --name=lxc-net
95+ dh_installinit --no-restart-on-upgrade --name=lxc-instance
96
97 override_dh_strip:
98 dh_strip --dbg-package=lxc-dbg

Subscribers

People subscribed via source and target branches