Merge lp:~thumper/juju-core/selectively-install-lxc 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: 1474
Proposed branch: lp:~thumper/juju-core/selectively-install-lxc
Merge into: lp:~go-bot/juju-core/trunk
Prerequisite: lp:~thumper/juju-core/lxc-identity
Diff against target: 417 lines (+77/-30)
17 files modified
cmd/juju/bootstrap.go (+2/-1)
cmd/jujud/machine.go (+1/-1)
cmd/jujud/upgradevalidation.go (+19/-1)
environs/azure/customdata_test.go (+1/-0)
environs/cloudinit.go (+1/-0)
environs/cloudinit/cloudinit.go (+7/-1)
environs/cloudinit/cloudinit_test.go (+9/-4)
environs/cloudinit_test.go (+1/-0)
environs/local/config_test.go (+2/-1)
environs/local/environ.go (+3/-1)
environs/local/environprovider.go (+2/-1)
environs/local/instance.go (+0/-12)
environs/local/local_test.go (+2/-1)
environs/maas/util_test.go (+6/-5)
environs/provider/provider.go (+13/-0)
upstart/service.go (+4/-1)
worker/deployer/simple.go (+4/-0)
To merge this branch: bzr merge lp:~thumper/juju-core/selectively-install-lxc
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+174928@code.launchpad.net

Commit message

Conditionally install lxc

There are two primary situations where we don't want
the machine agent to install lxc:
 1. when the machine agent is inside an lxc container
    as known by state
 2. when the machine has been provisioned by the local
    provider (because it is an lxc container)

When lxc is installed inside a container, it adds a
bridge network device with the same defaults as the
host. This kills any routing in or out of the container.

Upstart provides support for setting environment variables
as part of the config, and we use this to pass the provider
type through.

https://codereview.appspot.com/11330043/

Description of the change

Conditionally install lxc

There are two primary situations where we don't want
the machine agent to install lxc:
 1. when the machine agent is inside an lxc container
    as known by state
 2. when the machine has been provisioned by the local
    provider (because it is an lxc container)

When lxc is installed inside a container, it adds a
bridge network device with the same defaults as the
host. This kills any routing in or out of othe container.

Upstart provides support for setting environment variables
as part of the config, and we use this to pass the provider
type through.

https://codereview.appspot.com/11330043/

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

Reviewers: mp+174928_code.launchpad.net,

Message:
Please take a look.

Description:
Conditionally install lxc

There are two primary situations where we don't want
the machine agent to install lxc:
  1. when the machine agent is inside an lxc container
     as known by state
  2. when the machine has been provisioned by the local
     provider (because it is an lxc container)

When lxc is installed inside a container, it adds a
bridge network device with the same defaults as the
host. This kills any routing in or out of othe container.

Upstart provides support for setting environment variables
as part of the config, and we use this to pass the provider
type through.

https://code.launchpad.net/~thumper/juju-core/selectively-install-lxc/+merge/174928

Requires:
https://code.launchpad.net/~thumper/juju-core/lxc-identity/+merge/174922

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M cmd/jujud/machine.go
   M cmd/jujud/upgradevalidation.go
   M environs/azure/customdata_test.go
   M environs/cloudinit.go
   M environs/cloudinit/cloudinit.go
   M environs/cloudinit/cloudinit_test.go
   M environs/cloudinit_test.go
   M environs/local/environ.go
   M environs/local/environprovider.go
   M environs/maas/util_test.go
   M upstart/service.go
   M worker/deployer/simple.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.go
=== modified file 'environs/cloudinit.go'
--- environs/cloudinit.go 2013-07-16 03:28:34 +0000
+++ environs/cloudinit.go 2013-07-16 06:18:45 +0000
@@ -38,6 +38,7 @@
    return fmt.Errorf("environment configuration has no authorized-keys")
   }
   mcfg.AuthorizedKeys = authKeys
+ mcfg.ProviderType = cfg.Type()
   if !mcfg.StateServer {
    return nil
   }

Index: cmd/jujud/machine.go
=== modified file 'cmd/jujud/machine.go'
--- cmd/jujud/machine.go 2013-07-11 16:09:00 +0000
+++ cmd/jujud/machine.go 2013-07-16 06:18:45 +0000
@@ -80,7 +80,7 @@
   if err := a.Conf.read(a.Tag()); err != nil {
    return err
   }
- if err := EnsureWeHaveLXC(a.Conf.DataDir); err != nil {
+ if err := EnsureWeHaveLXC(a.Conf.DataDir, a.Tag()); err != nil {
    log.Errorf("we were unable to install the lxc package, unable to
continue: %v", err)
    return err
   }

Index: cmd/jujud/upgradevalidation.go
=== modified file 'cmd/jujud/upgradevalidation.go'
--- cmd/jujud/upgradevalidation.go 2013-07-15 01:16:52 +0000
+++ cmd/jujud/upgradevalidation.go 2013-07-16 06:18:45 +0000
@@ -4,12 +4,15 @@
  package main

  import (
+ "os"
   "path/filepath"
   "time"

   "launchpad.net/loggo"

   "launchpad.net/juju-core/container/lxc"
+ "launchpad.net/juju-core/instance"
+ "launchpad.net/juju-core/state"
   "launchpad.net/juju-core/utils"
   "launchpad.net/juju-core/utils/fslock"
  )
@@ -44,7 +47,21 @@
  // dataDir is the root location where data files are put. It i...

Revision history for this message
Martin Packman (gz) wrote :

LGTM

https://codereview.appspot.com/11330043/diff/1/cmd/jujud/upgradevalidation.go
File cmd/jujud/upgradevalidation.go (right):

https://codereview.appspot.com/11330043/diff/1/cmd/jujud/upgradevalidation.go#newcode62
cmd/jujud/upgradevalidation.go:62: if providerType == "local" ||
containerType == instance.LXC {
It's a little surprising that these are two different condiditions.
Should the local provider 'machines' not be aware that they're lxc
containers anyway?

https://codereview.appspot.com/11330043/diff/1/environs/cloudinit/cloudinit_test.go
File environs/cloudinit/cloudinit_test.go (right):

https://codereview.appspot.com/11330043/diff/1/environs/cloudinit/cloudinit_test.go#newcode108
environs/cloudinit/cloudinit_test.go:108: cat >>
/etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0
agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on
runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit
0\\nenv JUJU_PROVIDER_TYPE="dummy"\\n\\nlimit nofile 20000
20000\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file
'/var/log/juju/machine-0\.log' --data-dir '/var/lib/juju' --machine-id 0
  --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
These test assertions are so bad...

https://codereview.appspot.com/11330043/diff/1/environs/local/environ.go
File environs/local/environ.go (right):

https://codereview.appspot.com/11330043/diff/1/environs/local/environ.go#newcode382
environs/local/environ.go:382: agent.Env["HOME"] = os.Getenv("HOME")
Not strictly releated to this proposal?

https://codereview.appspot.com/11330043/

Revision history for this message
Frank Mueller (themue) wrote :

LGTM together with Martins comments.

https://codereview.appspot.com/11330043/diff/1/cmd/jujud/upgradevalidation.go
File cmd/jujud/upgradevalidation.go (right):

https://codereview.appspot.com/11330043/diff/1/cmd/jujud/upgradevalidation.go#newcode62
cmd/jujud/upgradevalidation.go:62: if providerType == "local" ||
containerType == instance.LXC {
Please change "local" to a constant usable in the whole system.

https://codereview.appspot.com/11330043/diff/1/environs/cloudinit/cloudinit_test.go
File environs/cloudinit/cloudinit_test.go (right):

https://codereview.appspot.com/11330043/diff/1/environs/cloudinit/cloudinit_test.go#newcode108
environs/cloudinit/cloudinit_test.go:108: cat >>
/etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0
agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on
runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit
0\\nenv JUJU_PROVIDER_TYPE="dummy"\\n\\nlimit nofile 20000
20000\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file
'/var/log/juju/machine-0\.log' --data-dir '/var/lib/juju' --machine-id 0
  --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
On 2013/07/16 08:45:23, gz wrote:
> These test assertions are so bad...

+1

As it grows we should take time to find a more elegant way checking the
script content, e.g. different contains() with regex or so.

https://codereview.appspot.com/11330043/diff/1/environs/local/environprovider.go
File environs/local/environprovider.go (right):

https://codereview.appspot.com/11330043/diff/1/environs/local/environprovider.go#newcode18
environs/local/environprovider.go:18: const ProviderType = "local"
Ah, my wanted constant. ;)

https://codereview.appspot.com/11330043/

Revision history for this message
Tim Penhey (thumper) wrote :

https://codereview.appspot.com/11330043/diff/1/cmd/jujud/upgradevalidation.go
File cmd/jujud/upgradevalidation.go (right):

https://codereview.appspot.com/11330043/diff/1/cmd/jujud/upgradevalidation.go#newcode62
cmd/jujud/upgradevalidation.go:62: if providerType == "local" ||
containerType == instance.LXC {
On 2013/07/16 08:45:23, gz wrote:
> It's a little surprising that these are two different condiditions.
Should the
> local provider 'machines' not be aware that they're lxc containers
anyway?

Ideally yes, and hopefully relatively soon.

When we get multi-provider environments, the machines should know which
provider had created them. The more interesting bit here is that we
don't have access to the machine doc here, so can't check anyway.

https://codereview.appspot.com/11330043/diff/1/cmd/jujud/upgradevalidation.go#newcode62
cmd/jujud/upgradevalidation.go:62: if providerType == "local" ||
containerType == instance.LXC {
On 2013/07/16 10:52:37, mue wrote:
> Please change "local" to a constant usable in the whole system.

This adds a bucket load of dependencies that it shouldn't have.

I propose that RSN, we change the way we do some constants.

I'll think about the best solution, but may well be independent packages
that have no other dependencies.

https://codereview.appspot.com/11330043/diff/1/environs/cloudinit/cloudinit_test.go
File environs/cloudinit/cloudinit_test.go (right):

https://codereview.appspot.com/11330043/diff/1/environs/cloudinit/cloudinit_test.go#newcode108
environs/cloudinit/cloudinit_test.go:108: cat >>
/etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0
agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on
runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit
0\\nenv JUJU_PROVIDER_TYPE="dummy"\\n\\nlimit nofile 20000
20000\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file
'/var/log/juju/machine-0\.log' --data-dir '/var/lib/juju' --machine-id 0
  --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
On 2013/07/16 10:52:37, mue wrote:
> On 2013/07/16 08:45:23, gz wrote:
> > These test assertions are so bad...

> +1

> As it grows we should take time to find a more elegant way checking
the script
> content, e.g. different contains() with regex or so.

I agree, it is just getting crazy.

Certainly worth spending some time on later.

https://codereview.appspot.com/11330043/diff/1/environs/local/environ.go
File environs/local/environ.go (right):

https://codereview.appspot.com/11330043/diff/1/environs/local/environ.go#newcode382
environs/local/environ.go:382: agent.Env["HOME"] = os.Getenv("HOME")
On 2013/07/16 08:45:23, gz wrote:
> Not strictly releated to this proposal?

Not entirely, no.

https://codereview.appspot.com/11330043/

Revision history for this message
Go Bot (go-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/juju/bootstrap.go'
2--- cmd/juju/bootstrap.go 2013-07-17 02:36:28 +0000
3+++ cmd/juju/bootstrap.go 2013-07-17 02:36:28 +0000
4@@ -11,6 +11,7 @@
5 "launchpad.net/juju-core/constraints"
6 "launchpad.net/juju-core/environs"
7 "launchpad.net/juju-core/environs/config"
8+ "launchpad.net/juju-core/environs/provider"
9 "launchpad.net/juju-core/utils/set"
10 "launchpad.net/juju-core/version"
11 "os"
12@@ -69,7 +70,7 @@
13 return err
14 }
15 // If we are using a local provider, always upload tools.
16- if environ.Config().Type() == "local" {
17+ if environ.Config().Type() == provider.Local {
18 c.UploadTools = true
19 }
20 if c.UploadTools {
21
22=== modified file 'cmd/jujud/machine.go'
23--- cmd/jujud/machine.go 2013-07-11 16:09:00 +0000
24+++ cmd/jujud/machine.go 2013-07-17 02:36:28 +0000
25@@ -80,7 +80,7 @@
26 if err := a.Conf.read(a.Tag()); err != nil {
27 return err
28 }
29- if err := EnsureWeHaveLXC(a.Conf.DataDir); err != nil {
30+ if err := EnsureWeHaveLXC(a.Conf.DataDir, a.Tag()); err != nil {
31 log.Errorf("we were unable to install the lxc package, unable to continue: %v", err)
32 return err
33 }
34
35=== modified file 'cmd/jujud/upgradevalidation.go'
36--- cmd/jujud/upgradevalidation.go 2013-07-17 02:36:28 +0000
37+++ cmd/jujud/upgradevalidation.go 2013-07-17 02:36:28 +0000
38@@ -4,12 +4,16 @@
39 package main
40
41 import (
42+ "os"
43 "path/filepath"
44 "time"
45
46 "launchpad.net/loggo"
47
48 "launchpad.net/juju-core/container/lxc"
49+ "launchpad.net/juju-core/environs/provider"
50+ "launchpad.net/juju-core/instance"
51+ "launchpad.net/juju-core/state"
52 "launchpad.net/juju-core/utils"
53 "launchpad.net/juju-core/utils/fslock"
54 )
55@@ -44,7 +48,21 @@
56 // dataDir is the root location where data files are put. It is used to grab
57 // the uniter-hook-execution lock so that we don't try run to apt-get at the
58 // same time that a hook might want to run it.
59-func EnsureWeHaveLXC(dataDir string) error {
60+func EnsureWeHaveLXC(dataDir, machineTag string) error {
61+ // We need to short circuit this in two places:
62+ // 1. if we are running a local provider, then the machines are lxc
63+ // containers, and if we install lxc on them, it adds an lxc bridge
64+ // network device with the same ip address as the hosts bridge. This
65+ // screws up all the networking routes.
66+ // 2. if the machine is an lxc container, we need to avoid installing lxc
67+ // package for exactly the same reasons.
68+ // Later, post-precise LTS, when we have updated lxc, we can bring this
69+ // back in to have nested lxc, but until then, we have to avoid it.
70+ containerType := state.ContainerTypeFromId(state.MachineIdFromTag(machineTag))
71+ providerType := os.Getenv("JUJU_PROVIDER_TYPE")
72+ if providerType == provider.Local || containerType == instance.LXC {
73+ return nil
74+ }
75 manager := lxc.NewContainerManager(lxc.ManagerConfig{Name: "lxc-test"})
76 if _, err := manager.ListContainers(); err == nil {
77 validationLogger.Debugf("found lxc, not installing")
78
79=== modified file 'environs/azure/customdata_test.go'
80--- environs/azure/customdata_test.go 2013-07-11 11:35:42 +0000
81+++ environs/azure/customdata_test.go 2013-07-17 02:36:28 +0000
82@@ -38,6 +38,7 @@
83 Addrs: []string{"127.0.0.1:123"},
84 Tag: state.MachineTag(machineID),
85 },
86+ ProviderType: "azure",
87 }
88 }
89
90
91=== modified file 'environs/cloudinit.go'
92--- environs/cloudinit.go 2013-07-17 00:44:30 +0000
93+++ environs/cloudinit.go 2013-07-17 02:36:28 +0000
94@@ -55,6 +55,7 @@
95 return fmt.Errorf("environment configuration has no authorized-keys")
96 }
97 mcfg.AuthorizedKeys = authKeys
98+ mcfg.ProviderType = cfg.Type()
99 if !mcfg.StateServer {
100 return nil
101 }
102
103=== modified file 'environs/cloudinit/cloudinit.go'
104--- environs/cloudinit/cloudinit.go 2013-07-11 22:23:18 +0000
105+++ environs/cloudinit/cloudinit.go 2013-07-17 02:36:28 +0000
106@@ -84,6 +84,9 @@
107 // commands cannot work.
108 AuthorizedKeys string
109
110+ // ProviderType refers to the type of the provider that created the machine.
111+ ProviderType string
112+
113 // Config holds the initial environment configuration.
114 Config *config.Config
115
116@@ -277,7 +280,7 @@
117 addScripts(c, fmt.Sprintf("ln -s %v %s", cfg.Tools.Binary, shquote(toolsDir)))
118
119 name := "jujud-" + tag
120- conf := upstart.MachineAgentUpstartService(name, toolsDir, cfg.DataDir, "/var/log/juju/", tag, machineId, logConfig)
121+ conf := upstart.MachineAgentUpstartService(name, toolsDir, cfg.DataDir, "/var/log/juju/", tag, machineId, logConfig, cfg.ProviderType)
122 cmds, err := conf.InstallCommands()
123 if err != nil {
124 return fmt.Errorf("cannot make cloud-init upstart script for the %s agent: %v", tag, err)
125@@ -383,6 +386,9 @@
126 if len(cfg.APIInfo.CACert) == 0 {
127 return fmt.Errorf("missing API CA certificate")
128 }
129+ if cfg.ProviderType == "" {
130+ return fmt.Errorf("missing provider type")
131+ }
132 if cfg.StateServer {
133 if cfg.Config == nil {
134 return fmt.Errorf("missing environment configuration")
135
136=== modified file 'environs/cloudinit/cloudinit_test.go'
137--- environs/cloudinit/cloudinit_test.go 2013-07-12 09:58:12 +0000
138+++ environs/cloudinit/cloudinit_test.go 2013-07-17 02:36:28 +0000
139@@ -57,6 +57,7 @@
140 cfg: cloudinit.MachineConfig{
141 MachineId: "0",
142 AuthorizedKeys: "sshkey1",
143+ ProviderType: "dummy",
144 // precise currently needs mongo from PPA
145 Tools: newSimpleTools("1.2.3-precise-amd64"),
146 StateServer: true,
147@@ -104,7 +105,7 @@
148 /var/lib/juju/tools/1\.2\.3-precise-amd64/jujud bootstrap-state --data-dir '/var/lib/juju' --env-config '[^']*' --constraints 'mem=2048M' --debug
149 rm -rf '/var/lib/juju/agents/bootstrap'
150 ln -s 1\.2\.3-precise-amd64 '/var/lib/juju/tools/machine-0'
151-cat >> /etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0 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-0/jujud machine --log-file '/var/log/juju/machine-0\.log' --data-dir '/var/lib/juju' --machine-id 0 --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
152+cat >> /etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0 agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\nenv JUJU_PROVIDER_TYPE="dummy"\\n\\nlimit nofile 20000 20000\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file '/var/log/juju/machine-0\.log' --data-dir '/var/lib/juju' --machine-id 0 --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
153 start jujud-machine-0
154 `,
155 }, {
156@@ -112,6 +113,7 @@
157 cfg: cloudinit.MachineConfig{
158 MachineId: "0",
159 AuthorizedKeys: "sshkey1",
160+ ProviderType: "dummy",
161 // raring provides mongo in the archive
162 Tools: newSimpleTools("1.2.3-raring-amd64"),
163 StateServer: true,
164@@ -159,13 +161,14 @@
165 /var/lib/juju/tools/1\.2\.3-raring-amd64/jujud bootstrap-state --data-dir '/var/lib/juju' --env-config '[^']*' --constraints 'mem=2048M' --debug
166 rm -rf '/var/lib/juju/agents/bootstrap'
167 ln -s 1\.2\.3-raring-amd64 '/var/lib/juju/tools/machine-0'
168-cat >> /etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0 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-0/jujud machine --log-file '/var/log/juju/machine-0\.log' --data-dir '/var/lib/juju' --machine-id 0 --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
169+cat >> /etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0 agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\nenv JUJU_PROVIDER_TYPE="dummy"\\n\\nlimit nofile 20000 20000\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file '/var/log/juju/machine-0\.log' --data-dir '/var/lib/juju' --machine-id 0 --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
170 start jujud-machine-0
171 `,
172 }, {
173 cfg: cloudinit.MachineConfig{
174 MachineId: "99",
175 AuthorizedKeys: "sshkey1",
176+ ProviderType: "dummy",
177 DataDir: environs.DataDir,
178 StateServer: false,
179 Tools: newSimpleTools("1.2.3-linux-amd64"),
180@@ -197,7 +200,7 @@
181 echo 'datadir: /var/lib/juju\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - state-addr\.testing\.invalid:12345\\n cacert:\\n[^']+ tag: machine-99\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - state-addr\.testing\.invalid:54321\\n cacert:\\n[^']+ tag: machine-99\\n password: ""\\n' > '/var/lib/juju/agents/machine-99/agent\.conf'
182 chmod 600 '/var/lib/juju/agents/machine-99/agent\.conf'
183 ln -s 1\.2\.3-linux-amd64 '/var/lib/juju/tools/machine-99'
184-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
185+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\\nenv JUJU_PROVIDER_TYPE="dummy"\\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
186 start jujud-machine-99
187 `,
188 }, {
189@@ -205,6 +208,7 @@
190 MachineId: "2/lxc/1",
191 MachineContainerType: "lxc",
192 AuthorizedKeys: "sshkey1",
193+ ProviderType: "dummy",
194 DataDir: environs.DataDir,
195 StateServer: false,
196 Tools: newSimpleTools("1.2.3-linux-amd64"),
197@@ -236,7 +240,7 @@
198 echo 'datadir: /var/lib/juju\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - state-addr\.testing\.invalid:12345\\n cacert:\\n[^']+ tag: machine-2-lxc-1\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - state-addr\.testing\.invalid:54321\\n cacert:\\n[^']+ tag: machine-2-lxc-1\\n password: ""\\n' > '/var/lib/juju/agents/machine-2-lxc-1/agent\.conf'
199 chmod 600 '/var/lib/juju/agents/machine-2-lxc-1/agent\.conf'
200 ln -s 1\.2\.3-linux-amd64 '/var/lib/juju/tools/machine-2-lxc-1'
201-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
202+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\\nenv JUJU_PROVIDER_TYPE="dummy"\\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
203 start jujud-machine-2-lxc-1
204 `,
205 },
206@@ -554,6 +558,7 @@
207 MachineId: "99",
208 Tools: newSimpleTools("9.9.9-linux-arble"),
209 AuthorizedKeys: "sshkey1",
210+ ProviderType: "dummy",
211 StateInfo: &state.Info{
212 Addrs: []string{"host:98765"},
213 CACert: []byte(testing.CACert),
214
215=== modified file 'environs/cloudinit_test.go'
216--- environs/cloudinit_test.go 2013-07-09 10:32:23 +0000
217+++ environs/cloudinit_test.go 2013-07-17 02:36:28 +0000
218@@ -40,6 +40,7 @@
219 c.Assert(err, IsNil)
220 c.Assert(mcfg, DeepEquals, &cloudinit.MachineConfig{
221 AuthorizedKeys: "we-are-the-keys",
222+ ProviderType: "dummy",
223 StateInfo: &state.Info{Tag: "not touched"},
224 APIInfo: &api.Info{Tag: "not touched"},
225 })
226
227=== modified file 'environs/local/config_test.go'
228--- environs/local/config_test.go 2013-07-16 21:56:22 +0000
229+++ environs/local/config_test.go 2013-07-17 02:36:28 +0000
230@@ -13,6 +13,7 @@
231
232 "launchpad.net/juju-core/environs/config"
233 "launchpad.net/juju-core/environs/local"
234+ "launchpad.net/juju-core/environs/provider"
235 "launchpad.net/juju-core/testing"
236 )
237
238@@ -38,7 +39,7 @@
239 func minimalConfigValues() map[string]interface{} {
240 return map[string]interface{}{
241 "name": "test",
242- "type": "local",
243+ "type": provider.Local,
244 // While the ca-cert bits aren't entirely minimal, they avoid the need
245 // to set up a fake home.
246 "ca-cert": testing.CACert,
247
248=== modified file 'environs/local/environ.go'
249--- environs/local/environ.go 2013-07-17 02:36:28 +0000
250+++ environs/local/environ.go 2013-07-17 02:36:28 +0000
251@@ -378,7 +378,9 @@
252 logConfig := "--debug" // TODO(thumper): specify loggo config
253 agent := upstart.MachineAgentUpstartService(
254 env.machineAgentServiceName(),
255- toolsDir, dataDir, logDir, tag, machineId, logConfig)
256+ toolsDir, dataDir, logDir, tag, machineId, logConfig, env.config.Type())
257+ agent.Env["USER"] = env.config.user
258+ agent.Env["HOME"] = os.Getenv("HOME")
259
260 agent.InitDir = upstartScriptLocation
261 logger.Infof("installing service %s to %s", env.machineAgentServiceName(), agent.InitDir)
262
263=== modified file 'environs/local/environprovider.go'
264--- environs/local/environprovider.go 2013-07-17 02:36:28 +0000
265+++ environs/local/environprovider.go 2013-07-17 02:36:28 +0000
266@@ -10,6 +10,7 @@
267
268 "launchpad.net/juju-core/environs"
269 "launchpad.net/juju-core/environs/config"
270+ constants "launchpad.net/juju-core/environs/provider"
271 "launchpad.net/juju-core/instance"
272 "launchpad.net/juju-core/utils"
273 "launchpad.net/juju-core/version"
274@@ -24,7 +25,7 @@
275 var provider environProvider
276
277 func init() {
278- environs.RegisterProvider("local", &environProvider{})
279+ environs.RegisterProvider(constants.Local, &environProvider{})
280 }
281
282 // Open implements environs.EnvironProvider.Open.
283
284=== modified file 'environs/local/instance.go'
285--- environs/local/instance.go 2013-07-17 02:36:28 +0000
286+++ environs/local/instance.go 2013-07-17 02:36:28 +0000
287@@ -39,31 +39,19 @@
288
289 // WaitDNSName implements instance.Instance.WaitDNSName.
290 func (inst *localInstance) WaitDNSName() (string, error) {
291-<<<<<<< TREE
292 return environs.WaitDNSName(inst)
293-=======
294- return inst.DNSName()
295->>>>>>> MERGE-SOURCE
296 }
297
298 // OpenPorts implements instance.Instance.OpenPorts.
299 func (inst *localInstance) OpenPorts(machineId string, ports []instance.Port) error {
300-<<<<<<< TREE
301 logger.Infof("OpenPorts called for %s:%v", machineId, ports)
302 return nil
303-=======
304- return fmt.Errorf("instance open ports not implemented")
305->>>>>>> MERGE-SOURCE
306 }
307
308 // ClosePorts implements instance.Instance.ClosePorts.
309 func (inst *localInstance) ClosePorts(machineId string, ports []instance.Port) error {
310-<<<<<<< TREE
311 logger.Infof("ClosePorts called for %s:%v", machineId, ports)
312 return nil
313-=======
314- return fmt.Errorf("instance close not implemented")
315->>>>>>> MERGE-SOURCE
316 }
317
318 // Ports implements instance.Instance.Ports.
319
320=== modified file 'environs/local/local_test.go'
321--- environs/local/local_test.go 2013-07-03 00:15:19 +0000
322+++ environs/local/local_test.go 2013-07-17 02:36:28 +0000
323@@ -10,6 +10,7 @@
324
325 "launchpad.net/juju-core/environs"
326 "launchpad.net/juju-core/environs/local"
327+ "launchpad.net/juju-core/environs/provider"
328 "launchpad.net/juju-core/testing"
329 )
330
331@@ -24,7 +25,7 @@
332 var _ = Suite(&localSuite{})
333
334 func (*localSuite) TestProviderRegistered(c *C) {
335- provider, error := environs.Provider("local")
336+ provider, error := environs.Provider(provider.Local)
337 c.Assert(error, IsNil)
338 c.Assert(provider, DeepEquals, &local.Provider)
339 }
340
341=== modified file 'environs/maas/util_test.go'
342--- environs/maas/util_test.go 2013-07-12 10:10:40 +0000
343+++ environs/maas/util_test.go 2013-07-17 02:36:28 +0000
344@@ -70,11 +70,12 @@
345 Password: "pw2",
346 CACert: []byte("CA CERT\n" + testing.CACert),
347 },
348- DataDir: environs.DataDir,
349- Config: envConfig,
350- StatePort: envConfig.StatePort(),
351- APIPort: envConfig.APIPort(),
352- StateServer: true,
353+ DataDir: environs.DataDir,
354+ Config: envConfig,
355+ StatePort: envConfig.StatePort(),
356+ APIPort: envConfig.APIPort(),
357+ StateServer: true,
358+ ProviderType: "maas",
359 }
360 script1 := "script1"
361 script2 := "script2"
362
363=== added directory 'environs/provider'
364=== added file 'environs/provider/provider.go'
365--- environs/provider/provider.go 1970-01-01 00:00:00 +0000
366+++ environs/provider/provider.go 2013-07-17 02:36:28 +0000
367@@ -0,0 +1,13 @@
368+// Copyright 2013 Canonical Ltd.
369+// Licensed under the AGPLv3, see LICENCE file for details.
370+
371+package provider
372+
373+const (
374+ Local = "local"
375+ Dummy = "dummy"
376+ EC2 = "ec2"
377+ MAAS = "maas"
378+ Azure = "azure"
379+ OpenStack = "openstack"
380+)
381
382=== modified file 'upstart/service.go'
383--- upstart/service.go 2013-07-08 22:34:11 +0000
384+++ upstart/service.go 2013-07-17 02:36:28 +0000
385@@ -42,7 +42,7 @@
386
387 // MachineAgentUpstartService returns the upstart config for a machine agent
388 // based on the tag and machineId passed in.
389-func MachineAgentUpstartService(name, toolsDir, dataDir, logDir, tag, machineId, logConfig string) *Conf {
390+func MachineAgentUpstartService(name, toolsDir, dataDir, logDir, tag, machineId, logConfig, providerType string) *Conf {
391 svc := NewService(name)
392 logFile := filepath.Join(logDir, tag+".log")
393 return &Conf{
394@@ -58,5 +58,8 @@
395 " --machine-id " + machineId +
396 " " + logConfig,
397 Out: logFile,
398+ Env: map[string]string{
399+ "JUJU_PROVIDER_TYPE": providerType,
400+ },
401 }
402 }
403
404=== modified file 'worker/deployer/simple.go'
405--- worker/deployer/simple.go 2013-07-09 11:31:00 +0000
406+++ worker/deployer/simple.go 2013-07-17 02:36:28 +0000
407@@ -142,6 +142,10 @@
408 Desc: "juju unit agent for " + unitName,
409 Cmd: cmd,
410 Out: logPath,
411+ // Propagate the provider type enviroment variable.
412+ Env: map[string]string{
413+ "JUJU_PROVIDER_TYPE": os.Getenv("JUJU_PROVIDER_TYPE"),
414+ },
415 }
416 return uconf.Install()
417 }

Subscribers

People subscribed via source and target branches

to status/vote changes: