Merge lp:~thumper/juju-core/lxc-cloud-init into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1286
Proposed branch: lp:~thumper/juju-core/lxc-cloud-init
Merge into: lp:~go-bot/juju-core/trunk
Prerequisite: lp:~thumper/juju-core/machine-id-from-tag
Diff against target: 86 lines (+51/-0)
2 files modified
environs/cloudinit/cloudinit.go (+9/-0)
environs/cloudinit/cloudinit_test.go (+42/-0)
To merge this branch: bzr merge lp:~thumper/juju-core/lxc-cloud-init
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+169328@code.launchpad.net

Commit message

Add lxc to our cloud-init packages

However don't add lxc if the machine itself is an
lxc container as the install fails on precise causing
the lxc container to fail to start.

https://codereview.appspot.com/10235047/

Description of the change

Add lxc to our cloud-init packages

However don't add lxc if the machine itself is an
lxc container as the install fails on precise causing
the lxc container to fail to start.

https://codereview.appspot.com/10235047/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Reviewers: mp+169328_code.launchpad.net,

Message:
Please take a look.

Description:
Add lxc to our cloud-init packages

However don't add lxc if the machine itself is an
lxc container as the install fails on precise causing
the lxc container to fail to start.

https://code.launchpad.net/~thumper/juju-core/lxc-cloud-init/+merge/169328

Requires:
https://code.launchpad.net/~thumper/juju-core/machine-id-from-tag/+merge/169327

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/10235047/

Affected files:
   A [revision details]
   M environs/cloudinit/cloudinit.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: environs/cloudinit/cloudinit.go
=== modified file 'environs/cloudinit/cloudinit.go'
--- environs/cloudinit/cloudinit.go 2013-06-04 21:43:25 +0000
+++ environs/cloudinit/cloudinit.go 2013-06-14 02:32:16 +0000
@@ -74,6 +74,10 @@
   // MachineId identifies the new machine.
   MachineId string

+ // MachineContainerType specifies the type of container that the machine
+ // is. If the machine is not a container, then the type is "".
+ MachineContainerType string
+
   // AuthorizedKeys specifies the keys that are allowed to
   // connect to the machine (see cloudinit.SSHAddAuthorizedKeys)
   // If no keys are supplied, there can be no ssh access to the node.
@@ -115,6 +119,11 @@
   }
   c.AddSSHAuthorizedKeys(cfg.AuthorizedKeys)
   c.AddPackage("git")
+ // Perfectly reasonable to install lxc on environment instances and kvm
+ // containers.
+ if cfg.MachineContainerType != "lxc" {
+ c.AddPackage("lxc")
+ }

   addScripts(c,
    "set -xe", // ensure we run all the scripts or abort.

Revision history for this message
William Reade (fwereade) wrote :

Needs a CheckPackage in a test somewhere

https://codereview.appspot.com/10235047/

Revision history for this message
John A Meinel (jameinel) wrote :

LGTM caveat William's request.

https://codereview.appspot.com/10235047/

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

Hi,

Not installing lxc by default if you're already inside a container is
reasonable, since you may well not have been able to control the
environment of the first container.

However, if you are able to control the creation of the first container
(as you are in juju), then you can make lxc installable inside that
container. It amounts to:

1. set lxc.aa_profile = lxc-container-default-with-nesting
2. set lxc.mount.hook = /usr/share/lxc/hooks/mountcgroups
3. the lxc package should set up a lxcbr0 which does not conflict with
the parent container's address. The saucy package does this by default.
  If it is needed, we could try to SRU that change to precise's lxc.
Alternatively, you could hack the lxc network configuration settings by
hand (from cloud-init or from juju install script) by either modifying
/etc/default/lxc after the fact, or creating a suitable one ahead of
time so that lxc does not overwrite it on install.

cloud-init can detect that 1 and 2 are satisified ( by looking at
/proc/1/attr/current to check the aa profile and by checking whether
cgroups are mounted).

https://codereview.appspot.com/10235047/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/cloudinit/cloudinit.go'
2--- environs/cloudinit/cloudinit.go 2013-06-04 21:43:25 +0000
3+++ environs/cloudinit/cloudinit.go 2013-06-16 22:30:37 +0000
4@@ -74,6 +74,10 @@
5 // MachineId identifies the new machine.
6 MachineId string
7
8+ // MachineContainerType specifies the type of container that the machine
9+ // is. If the machine is not a container, then the type is "".
10+ MachineContainerType string
11+
12 // AuthorizedKeys specifies the keys that are allowed to
13 // connect to the machine (see cloudinit.SSHAddAuthorizedKeys)
14 // If no keys are supplied, there can be no ssh access to the node.
15@@ -115,6 +119,11 @@
16 }
17 c.AddSSHAuthorizedKeys(cfg.AuthorizedKeys)
18 c.AddPackage("git")
19+ // Perfectly reasonable to install lxc on environment instances and kvm
20+ // containers.
21+ if cfg.MachineContainerType != "lxc" {
22+ c.AddPackage("lxc")
23+ }
24
25 addScripts(c,
26 "set -xe", // ensure we run all the scripts or abort.
27
28=== modified file 'environs/cloudinit/cloudinit_test.go'
29--- environs/cloudinit/cloudinit_test.go 2013-05-31 08:15:19 +0000
30+++ environs/cloudinit/cloudinit_test.go 2013-06-16 22:30:37 +0000
31@@ -199,6 +199,45 @@
32 cat >> /etc/init/jujud-machine-99\.conf << 'EOF'\\ndescription "juju machine-99 agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nlimit nofile 20000 20000\\n\\nexec /var/lib/juju/tools/machine-99/jujud machine --log-file /var/log/juju/machine-99\.log --data-dir '/var/lib/juju' --machine-id 99 --debug >> /var/log/juju/machine-99\.log 2>&1\\nEOF\\n
33 start jujud-machine-99
34 `,
35+ }, {
36+ cfg: cloudinit.MachineConfig{
37+ MachineId: "2/lxc/1",
38+ MachineContainerType: "lxc",
39+ AuthorizedKeys: "sshkey1",
40+ DataDir: "/var/lib/juju",
41+ StateServer: false,
42+ Tools: newSimpleTools("1.2.3-linux-amd64"),
43+ MachineNonce: "FAKE_NONCE",
44+ StateInfo: &state.Info{
45+ Addrs: []string{"state-addr.example.com:12345"},
46+ Tag: "machine-2-lxc-1",
47+ Password: "arble",
48+ CACert: []byte("CA CERT\n" + testing.CACert),
49+ },
50+ APIInfo: &api.Info{
51+ Addrs: []string{"state-addr.example.com:54321"},
52+ Tag: "machine-2-lxc-1",
53+ Password: "bletch",
54+ CACert: []byte("CA CERT\n" + testing.CACert),
55+ },
56+ },
57+ expectScripts: `
58+set -xe
59+mkdir -p /var/lib/juju
60+mkdir -p /var/log/juju
61+bin='/var/lib/juju/tools/1\.2\.3-linux-amd64'
62+mkdir -p \$bin
63+wget --no-verbose -O - 'http://foo\.com/tools/juju1\.2\.3-linux-amd64\.tgz' \| tar xz -C \$bin
64+echo -n 'http://foo\.com/tools/juju1\.2\.3-linux-amd64\.tgz' > \$bin/downloaded-url\.txt
65+cat > /etc/rsyslog.d/25-juju.conf << 'EOF'\\n\\n\$ModLoad imfile\\n\\n\$InputFilePollInterval 5\\n\$InputFileName /var/log/juju/machine-2-lxc-1.log\\n\$InputFileTag juju-machine-2-lxc-1:\\n\$InputFileStateFile machine-2-lxc-1\\n\$InputRunFileMonitor\\n\\n:syslogtag, startswith, \"juju-\" @state-addr.example.com:514\\n& ~\\nEOF\\n
66+restart rsyslog
67+mkdir -p '/var/lib/juju/agents/machine-2-lxc-1'
68+echo 'datadir: /var/lib/juju\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - state-addr\.example\.com:12345\\n cacert:\\n[^']+ tag: machine-2-lxc-1\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - state-addr\.example\.com:54321\\n cacert:\\n[^']+ tag: machine-2-lxc-1\\n password: ""\\n' > '/var/lib/juju/agents/machine-2-lxc-1/agent\.conf'
69+chmod 600 '/var/lib/juju/agents/machine-2-lxc-1/agent\.conf'
70+ln -s 1\.2\.3-linux-amd64 '/var/lib/juju/tools/machine-2-lxc-1'
71+cat >> /etc/init/jujud-machine-2-lxc-1\.conf << 'EOF'\\ndescription "juju machine-2-lxc-1 agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nlimit nofile 20000 20000\\n\\nexec /var/lib/juju/tools/machine-2-lxc-1/jujud machine --log-file /var/log/juju/machine-2-lxc-1\.log --data-dir '/var/lib/juju' --machine-id 2/lxc/1 --debug >> /var/log/juju/machine-2-lxc-1\.log 2>&1\\nEOF\\n
72+start jujud-machine-2-lxc-1
73+`,
74 },
75 }
76
77@@ -260,6 +299,9 @@
78 checkEnvConfig(c, test.cfg.Config, x, scripts)
79 }
80 checkPackage(c, x, "git", true)
81+ // The lxc package should only be there if the machine container type is not lxc.
82+ hasLxc := test.cfg.MachineContainerType != "lxc"
83+ checkPackage(c, x, "lxc", hasLxc)
84 if test.cfg.StateServer {
85 checkPackage(c, x, "mongodb-server", true)
86 source := struct{ source, key string }{

Subscribers

People subscribed via source and target branches

to status/vote changes: