Merge lp:~thumper/juju-core/maas-lxc-trunk 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: 2017
Proposed branch: lp:~thumper/juju-core/maas-lxc-trunk
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 499 lines (+142/-107)
12 files modified
container/lxc/lxc.go (+12/-47)
container/lxc/lxc_test.go (+6/-8)
environs/cloudinit.go (+20/-12)
provider/local/environ.go (+7/-9)
state/api/params/params.go (+8/-0)
state/api/provisioner/provisioner.go (+7/-0)
state/api/provisioner/provisioner_test.go (+8/-0)
state/apiserver/provisioner/provisioner.go (+14/-0)
state/apiserver/provisioner/provisioner_test.go (+8/-0)
worker/provisioner/lxc-broker.go (+27/-7)
worker/provisioner/lxc-broker_test.go (+8/-2)
worker/provisioner/provisioner.go (+17/-22)
To merge this branch: bzr merge lp:~thumper/juju-core/maas-lxc-trunk
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+193502@code.launchpad.net

Commit message

Make LXC containers work on MAAS again.

Cherry pick the r1980 from lp:juju-core/1.16 that fixes
the issue on the release branch.

In addition to those changes, I changed the client api
to return the params struct rather than uppacking the
values.

https://codereview.appspot.com/20480043/

Description of the change

Make LXC containers work on MAAS again.

Cherry pick the r1980 from lp:juju-core/1.16 that fixes
the issue on the release branch.

In addition to those changes, I changed the client api
to return the params struct rather than uppacking the
values.

https://codereview.appspot.com/20480043/

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

Reviewers: mp+193502_code.launchpad.net,

Message:
Please take a look.

Description:
Make LXC containers work on MAAS again.

Cherry pick the r1980 from lp:juju-core/1.16 that fixes
the issue on the release branch.

In addition to those changes, I changed the client api
to return the params struct rather than uppacking the
values.

https://code.launchpad.net/~thumper/juju-core/maas-lxc-trunk/+merge/193502

(do not edit description out of merge proposal)

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

Affected files (+144, -107 lines):
   A [revision details]
   M container/lxc/lxc.go
   M container/lxc/lxc_test.go
   M environs/cloudinit.go
   M provider/local/environ.go
   M state/api/params/params.go
   M state/api/provisioner/provisioner.go
   M state/api/provisioner/provisioner_test.go
   M state/apiserver/provisioner/provisioner.go
   M state/apiserver/provisioner/provisioner_test.go
   M worker/provisioner/lxc-broker.go
   M worker/provisioner/lxc-broker_test.go
   M worker/provisioner/provisioner.go

Revision history for this message
Ian Booth (wallyworld) wrote :

LGTM

https://codereview.appspot.com/20480043/diff/1/state/api/provisioner/provisioner.go
File state/api/provisioner/provisioner.go (right):

https://codereview.appspot.com/20480043/diff/1/state/api/provisioner/provisioner.go#newcode160
state/api/provisioner/provisioner.go:160: func (st *State)
ContainerConfig() (result params.ContainerConfig, err error) {
ContainerConfig is very generic.

Perhaps ContainerCloudInitConfig ?

https://codereview.appspot.com/20480043/

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

https://codereview.appspot.com/20480043/diff/1/state/api/provisioner/provisioner.go
File state/api/provisioner/provisioner.go (right):

https://codereview.appspot.com/20480043/diff/1/state/api/provisioner/provisioner.go#newcode160
state/api/provisioner/provisioner.go:160: func (st *State)
ContainerConfig() (result params.ContainerConfig, err error) {
On 2013/11/04 01:40:24, wallyworld wrote:
> ContainerConfig is very generic.

> Perhaps ContainerCloudInitConfig ?

Yes. Perhaps in the future we'll want to return more than just some
cloud init stuff. Given that we don't yet know, I feel it is better to
leave this a little more generic here for now.

https://codereview.appspot.com/20480043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'container/lxc/lxc.go'
2--- container/lxc/lxc.go 2013-10-01 02:33:14 +0000
3+++ container/lxc/lxc.go 2013-10-31 21:39:38 +0000
4@@ -14,15 +14,9 @@
5 "launchpad.net/golxc"
6 "launchpad.net/loggo"
7
8- "launchpad.net/juju-core/constraints"
9- "launchpad.net/juju-core/environs"
10 "launchpad.net/juju-core/environs/cloudinit"
11- "launchpad.net/juju-core/environs/config"
12 "launchpad.net/juju-core/instance"
13 "launchpad.net/juju-core/names"
14- "launchpad.net/juju-core/state"
15- "launchpad.net/juju-core/state/api"
16- "launchpad.net/juju-core/tools"
17 "launchpad.net/juju-core/utils"
18 )
19
20@@ -83,12 +77,9 @@
21 type ContainerManager interface {
22 // StartContainer creates and starts a new lxc container for the specified machine.
23 StartContainer(
24- machineId, series, nonce string,
25- network *NetworkConfig,
26- tools *tools.Tools,
27- environConfig *config.Config,
28- stateInfo *state.Info,
29- apiInfo *api.Info) (instance.Instance, error)
30+ machineConfig *cloudinit.MachineConfig,
31+ series string,
32+ network *NetworkConfig) (instance.Instance, error)
33 // StopContainer stops and destroyes the lxc container identified by Instance.
34 StopContainer(instance.Instance) error
35 // ListContainers return a list of containers that have been started by
36@@ -113,14 +104,11 @@
37 }
38
39 func (manager *containerManager) StartContainer(
40- machineId, series, nonce string,
41- network *NetworkConfig,
42- tools *tools.Tools,
43- environConfig *config.Config,
44- stateInfo *state.Info,
45- apiInfo *api.Info) (instance.Instance, error) {
46+ machineConfig *cloudinit.MachineConfig,
47+ series string,
48+ network *NetworkConfig) (instance.Instance, error) {
49
50- name := names.MachineTag(machineId)
51+ name := names.MachineTag(machineConfig.MachineId)
52 if manager.name != "" {
53 name = fmt.Sprintf("%s-%s", manager.name, name)
54 }
55@@ -137,7 +125,7 @@
56 return nil, err
57 }
58 logger.Tracef("write cloud-init")
59- userDataFilename, err := writeUserData(directory, machineId, nonce, tools, environConfig, stateInfo, apiInfo)
60+ userDataFilename, err := writeUserData(machineConfig, directory)
61 if err != nil {
62 logger.Errorf("failed to write user data: %v", err)
63 return nil, err
64@@ -300,14 +288,8 @@
65 return configFilename, nil
66 }
67
68-func writeUserData(
69- directory, machineId, nonce string,
70- tools *tools.Tools,
71- environConfig *config.Config,
72- stateInfo *state.Info,
73- apiInfo *api.Info,
74-) (string, error) {
75- userData, err := cloudInitUserData(machineId, nonce, tools, environConfig, stateInfo, apiInfo)
76+func writeUserData(machineConfig *cloudinit.MachineConfig, directory string) (string, error) {
77+ userData, err := cloudInitUserData(machineConfig)
78 if err != nil {
79 logger.Errorf("failed to create user data: %v", err)
80 return "", err
81@@ -320,25 +302,8 @@
82 return userDataFilename, nil
83 }
84
85-func cloudInitUserData(
86- machineId, nonce string,
87- tools *tools.Tools,
88- environConfig *config.Config,
89- stateInfo *state.Info,
90- apiInfo *api.Info,
91-) ([]byte, error) {
92- machineConfig := &cloudinit.MachineConfig{
93- MachineId: machineId,
94- MachineNonce: nonce,
95- MachineContainerType: instance.LXC,
96- StateInfo: stateInfo,
97- APIInfo: apiInfo,
98- DataDir: "/var/lib/juju",
99- Tools: tools,
100- }
101- if err := environs.FinishMachineConfig(machineConfig, environConfig, constraints.Value{}); err != nil {
102- return nil, err
103- }
104+func cloudInitUserData(machineConfig *cloudinit.MachineConfig) ([]byte, error) {
105+ machineConfig.DataDir = "/var/lib/juju"
106 cloudConfig, err := cloudinit.New(machineConfig)
107 if err != nil {
108 return nil, err
109
110=== modified file 'container/lxc/lxc_test.go'
111--- container/lxc/lxc_test.go 2013-10-01 21:21:01 +0000
112+++ container/lxc/lxc_test.go 2013-10-31 21:39:38 +0000
113@@ -16,10 +16,10 @@
114 "launchpad.net/loggo"
115
116 "launchpad.net/juju-core/container/lxc"
117+ "launchpad.net/juju-core/environs"
118 "launchpad.net/juju-core/instance"
119 instancetest "launchpad.net/juju-core/instance/testing"
120 jujutesting "launchpad.net/juju-core/juju/testing"
121- "launchpad.net/juju-core/testing"
122 jc "launchpad.net/juju-core/testing/checkers"
123 "launchpad.net/juju-core/testing/testbase"
124 "launchpad.net/juju-core/tools"
125@@ -65,19 +65,17 @@
126 )
127
128 func StartContainer(c *gc.C, manager lxc.ContainerManager, machineId string) instance.Instance {
129- config := testing.EnvironConfig(c)
130 stateInfo := jujutesting.FakeStateInfo(machineId)
131 apiInfo := jujutesting.FakeAPIInfo(machineId)
132- network := lxc.BridgeNetworkConfig("nic42")
133-
134- series := "series"
135- nonce := "fake-nonce"
136- tools := &tools.Tools{
137+ machineConfig := environs.NewMachineConfig(machineId, "fake-nonce", stateInfo, apiInfo)
138+ machineConfig.Tools = &tools.Tools{
139 Version: version.MustParseBinary("2.3.4-foo-bar"),
140 URL: "http://tools.testing.invalid/2.3.4-foo-bar.tgz",
141 }
142
143- inst, err := manager.StartContainer(machineId, series, nonce, network, tools, config, stateInfo, apiInfo)
144+ series := "series"
145+ network := lxc.BridgeNetworkConfig("nic42")
146+ inst, err := manager.StartContainer(machineConfig, series, network)
147 c.Assert(err, gc.IsNil)
148 return inst
149 }
150
151=== modified file 'environs/cloudinit.go'
152--- environs/cloudinit.go 2013-10-02 19:30:07 +0000
153+++ environs/cloudinit.go 2013-10-31 21:39:38 +0000
154@@ -51,6 +51,23 @@
155 return mcfg
156 }
157
158+func PopulateMachineConfig(mcfg *cloudinit.MachineConfig,
159+ providerType, authorizedKeys string,
160+ sslHostnameVerification bool) error {
161+
162+ if authorizedKeys == "" {
163+ return fmt.Errorf("environment configuration has no authorized-keys")
164+ }
165+ mcfg.AuthorizedKeys = authorizedKeys
166+ if mcfg.AgentEnvironment == nil {
167+ mcfg.AgentEnvironment = make(map[string]string)
168+ }
169+ mcfg.AgentEnvironment[agent.ProviderType] = providerType
170+ mcfg.AgentEnvironment[agent.ContainerType] = string(mcfg.MachineContainerType)
171+ mcfg.DisableSSLHostnameVerification = !sslHostnameVerification
172+ return nil
173+}
174+
175 // FinishMachineConfig sets fields on a MachineConfig that can be determined by
176 // inspecting a plain config.Config and the machine constraints at the last
177 // moment before bootstrapping. It assumes that the supplied Config comes from
178@@ -64,18 +81,9 @@
179 func FinishMachineConfig(mcfg *cloudinit.MachineConfig, cfg *config.Config, cons constraints.Value) (err error) {
180 defer utils.ErrorContextf(&err, "cannot complete machine configuration")
181
182- // Everything needs the environment's authorized keys.
183- authKeys := cfg.AuthorizedKeys()
184- if authKeys == "" {
185- return fmt.Errorf("environment configuration has no authorized-keys")
186- }
187- mcfg.AuthorizedKeys = authKeys
188- if mcfg.AgentEnvironment == nil {
189- mcfg.AgentEnvironment = make(map[string]string)
190- }
191- mcfg.AgentEnvironment[agent.ProviderType] = cfg.Type()
192- mcfg.AgentEnvironment[agent.ContainerType] = string(mcfg.MachineContainerType)
193- mcfg.DisableSSLHostnameVerification = !cfg.SSLHostnameVerification()
194+ if err := PopulateMachineConfig(mcfg, cfg.Type(), cfg.AuthorizedKeys(), cfg.SSLHostnameVerification()); err != nil {
195+ return err
196+ }
197
198 // The following settings are only appropriate at bootstrap time. At the
199 // moment, the only state server is the bootstrap node, but this
200
201=== modified file 'provider/local/environ.go'
202--- provider/local/environ.go 2013-10-31 10:28:40 +0000
203+++ provider/local/environ.go 2013-10-31 21:39:38 +0000
204@@ -261,17 +261,15 @@
205 func (env *localEnviron) StartInstance(cons constraints.Value, possibleTools tools.List,
206 machineConfig *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
207
208- machineId := machineConfig.MachineId
209 series := possibleTools.OneSeries()
210- logger.Debugf("StartInstance: %q, %s", machineId, series)
211- agenttools := possibleTools[0]
212- logger.Debugf("tools: %#v", agenttools)
213-
214+ logger.Debugf("StartInstance: %q, %s", machineConfig.MachineId, series)
215+ machineConfig.Tools = possibleTools[0]
216+ logger.Debugf("tools: %#v", machineConfig.Tools)
217 network := lxc.BridgeNetworkConfig(env.config.networkBridge())
218- inst, err := env.containerManager.StartContainer(
219- machineId, series, machineConfig.MachineNonce, network,
220- agenttools, env.config.Config,
221- machineConfig.StateInfo, machineConfig.APIInfo)
222+ if err := environs.FinishMachineConfig(machineConfig, env.config.Config, cons); err != nil {
223+ return nil, nil, err
224+ }
225+ inst, err := env.containerManager.StartContainer(machineConfig, series, network)
226 if err != nil {
227 return nil, nil, err
228 }
229
230=== modified file 'state/api/params/params.go'
231--- state/api/params/params.go 2013-09-18 15:57:30 +0000
232+++ state/api/params/params.go 2013-10-31 21:39:38 +0000
233@@ -405,3 +405,11 @@
234 Id: i.Tag,
235 }
236 }
237+
238+// ContainerConfig contains information from the environment config that are
239+// needed for container cloud-init.
240+type ContainerConfig struct {
241+ ProviderType string
242+ AuthorizedKeys string
243+ SSLHostnameVerification bool
244+}
245
246=== modified file 'state/api/provisioner/provisioner.go'
247--- state/api/provisioner/provisioner.go 2013-10-02 14:26:55 +0000
248+++ state/api/provisioner/provisioner.go 2013-10-31 21:39:38 +0000
249@@ -154,3 +154,10 @@
250 }
251 return result.Tools, nil
252 }
253+
254+// ContainerConfig returns information from the environment config that are
255+// needed for container cloud-init.
256+func (st *State) ContainerConfig() (result params.ContainerConfig, err error) {
257+ err = st.caller.Call("Provisioner", "", "ContainerConfig", nil, &result)
258+ return result, err
259+}
260
261=== modified file 'state/api/provisioner/provisioner_test.go'
262--- state/api/provisioner/provisioner_test.go 2013-10-17 17:45:41 +0000
263+++ state/api/provisioner/provisioner_test.go 2013-10-31 21:39:38 +0000
264@@ -368,6 +368,14 @@
265 c.Assert(addresses, gc.DeepEquals, apiAddresses)
266 }
267
268+func (s *provisionerSuite) TestContainerConfig(c *gc.C) {
269+ result, err := s.provisioner.ContainerConfig()
270+ c.Assert(err, gc.IsNil)
271+ c.Assert(result.ProviderType, gc.Equals, "dummy")
272+ c.Assert(result.AuthorizedKeys, gc.Equals, "my-keys")
273+ c.Assert(result.SSLHostnameVerification, jc.IsTrue)
274+}
275+
276 func (s *provisionerSuite) TestCACert(c *gc.C) {
277 caCert, err := s.provisioner.CACert()
278 c.Assert(err, gc.IsNil)
279
280=== modified file 'state/apiserver/provisioner/provisioner.go'
281--- state/apiserver/provisioner/provisioner.go 2013-10-02 10:03:25 +0000
282+++ state/apiserver/provisioner/provisioner.go 2013-10-31 21:39:38 +0000
283@@ -182,6 +182,20 @@
284 return result, nil
285 }
286
287+// ContainerConfig returns information from the environment config that are
288+// needed for container cloud-init.
289+func (p *ProvisionerAPI) ContainerConfig() (params.ContainerConfig, error) {
290+ result := params.ContainerConfig{}
291+ config, err := p.st.EnvironConfig()
292+ if err != nil {
293+ return result, err
294+ }
295+ result.ProviderType = config.Type()
296+ result.AuthorizedKeys = config.AuthorizedKeys()
297+ result.SSLHostnameVerification = config.SSLHostnameVerification()
298+ return result, nil
299+}
300+
301 // Status returns the status of each given machine entity.
302 func (p *ProvisionerAPI) Status(args params.Entities) (params.StatusResults, error) {
303 result := params.StatusResults{
304
305=== modified file 'state/apiserver/provisioner/provisioner_test.go'
306--- state/apiserver/provisioner/provisioner_test.go 2013-10-18 14:07:34 +0000
307+++ state/apiserver/provisioner/provisioner_test.go 2013-10-31 21:39:38 +0000
308@@ -679,6 +679,14 @@
309 c.Check(results.Results, gc.HasLen, 0)
310 }
311
312+func (s *provisionerSuite) TestContainerConfig(c *gc.C) {
313+ results, err := s.provisioner.ContainerConfig()
314+ c.Check(err, gc.IsNil)
315+ c.Check(results.ProviderType, gc.Equals, "dummy")
316+ c.Check(results.AuthorizedKeys, gc.Equals, "my-keys")
317+ c.Check(results.SSLHostnameVerification, jc.IsTrue)
318+}
319+
320 func (s *provisionerSuite) TestToolsRefusesWrongAgent(c *gc.C) {
321 anAuthorizer := s.authorizer
322 anAuthorizer.Tag = "machine-12354"
323
324=== modified file 'worker/provisioner/lxc-broker.go'
325--- worker/provisioner/lxc-broker.go 2013-08-30 04:50:15 +0000
326+++ worker/provisioner/lxc-broker.go 2013-10-31 21:39:38 +0000
327@@ -11,8 +11,8 @@
328 "launchpad.net/juju-core/container/lxc"
329 "launchpad.net/juju-core/environs"
330 "launchpad.net/juju-core/environs/cloudinit"
331- "launchpad.net/juju-core/environs/config"
332 "launchpad.net/juju-core/instance"
333+ "launchpad.net/juju-core/state/api/params"
334 "launchpad.net/juju-core/tools"
335 )
336
337@@ -21,10 +21,14 @@
338 var _ environs.InstanceBroker = (*lxcBroker)(nil)
339 var _ tools.HasTools = (*lxcBroker)(nil)
340
341-func NewLxcBroker(config *config.Config, tools *tools.Tools, agentConfig agent.Config) environs.InstanceBroker {
342+type APICalls interface {
343+ ContainerConfig() (params.ContainerConfig, error)
344+}
345+
346+func NewLxcBroker(api APICalls, tools *tools.Tools, agentConfig agent.Config) environs.InstanceBroker {
347 return &lxcBroker{
348 manager: lxc.NewContainerManager(lxc.ManagerConfig{Name: "juju"}),
349- config: config,
350+ api: api,
351 tools: tools,
352 agentConfig: agentConfig,
353 }
354@@ -32,7 +36,7 @@
355
356 type lxcBroker struct {
357 manager lxc.ContainerManager
358- config *config.Config
359+ api APICalls
360 tools *tools.Tools
361 agentConfig agent.Config
362 }
363@@ -56,9 +60,25 @@
364 network := lxc.BridgeNetworkConfig(bridgeDevice)
365
366 series := possibleTools.OneSeries()
367- inst, err := broker.manager.StartContainer(
368- machineId, series, machineConfig.MachineNonce, network, possibleTools[0], broker.config,
369- machineConfig.StateInfo, machineConfig.APIInfo)
370+ machineConfig.MachineContainerType = instance.LXC
371+ machineConfig.Tools = possibleTools[0]
372+
373+ config, err := broker.api.ContainerConfig()
374+ if err != nil {
375+ lxcLogger.Errorf("failed to get container config: %v", err)
376+ return nil, nil, err
377+ }
378+ if err := environs.PopulateMachineConfig(
379+ machineConfig,
380+ config.ProviderType,
381+ config.AuthorizedKeys,
382+ config.SSLHostnameVerification,
383+ ); err != nil {
384+ lxcLogger.Errorf("failed to populate machine config: %v", err)
385+ return nil, nil, err
386+ }
387+
388+ inst, err := broker.manager.StartContainer(machineConfig, series, network)
389 if err != nil {
390 lxcLogger.Errorf("failed to start container: %v", err)
391 return nil, nil, err
392
393=== modified file 'worker/provisioner/lxc-broker_test.go'
394--- worker/provisioner/lxc-broker_test.go 2013-10-31 11:37:11 +0000
395+++ worker/provisioner/lxc-broker_test.go 2013-10-31 21:39:38 +0000
396@@ -22,6 +22,7 @@
397 jujutesting "launchpad.net/juju-core/juju/testing"
398 "launchpad.net/juju-core/names"
399 "launchpad.net/juju-core/state"
400+ "launchpad.net/juju-core/state/api/params"
401 coretesting "launchpad.net/juju-core/testing"
402 jc "launchpad.net/juju-core/testing/checkers"
403 coretools "launchpad.net/juju-core/tools"
404@@ -64,7 +65,6 @@
405 Version: version.MustParseBinary("2.3.4-foo-bar"),
406 URL: "http://tools.testing.invalid/2.3.4-foo-bar.tgz",
407 }
408- config := coretesting.EnvironConfig(c)
409 var err error
410 s.agentConfig, err = agent.NewAgentConfig(
411 agent.AgentConfigParams{
412@@ -76,7 +76,7 @@
413 CACert: []byte(coretesting.CACert),
414 })
415 c.Assert(err, gc.IsNil)
416- s.broker = provisioner.NewLxcBroker(config, tools, s.agentConfig)
417+ s.broker = provisioner.NewLxcBroker(&fakeAPI{}, tools, s.agentConfig)
418 }
419
420 func (s *lxcBrokerSuite) startInstance(c *gc.C, machineId string) instance.Instance {
421@@ -277,3 +277,9 @@
422 s.expectStopped(c, instId)
423 s.waitRemoved(c, container)
424 }
425+
426+type fakeAPI struct{}
427+
428+func (*fakeAPI) ContainerConfig() (params.ContainerConfig, error) {
429+ return params.ContainerConfig{"fake", "my-keys", true}, nil
430+}
431
432=== modified file 'worker/provisioner/provisioner.go'
433--- worker/provisioner/provisioner.go 2013-10-02 10:03:25 +0000
434+++ worker/provisioner/provisioner.go 2013-10-31 21:39:38 +0000
435@@ -15,6 +15,7 @@
436 "launchpad.net/juju-core/environs/config"
437 "launchpad.net/juju-core/instance"
438 apiprovisioner "launchpad.net/juju-core/state/api/provisioner"
439+ apiwatcher "launchpad.net/juju-core/state/api/watcher"
440 "launchpad.net/juju-core/state/watcher"
441 coretools "launchpad.net/juju-core/tools"
442 "launchpad.net/juju-core/worker"
443@@ -75,26 +76,21 @@
444 }
445
446 func (p *Provisioner) loop() error {
447- environWatcher, err := p.st.WatchForEnvironConfigChanges()
448- if err != nil {
449- return err
450- }
451- environConfigChanges := environWatcher.Changes()
452- defer watcher.Stop(environWatcher, &p.tomb)
453-
454- p.environ, err = worker.WaitForEnviron(environWatcher, p.st, p.tomb.Dying())
455- if err != nil {
456- return err
457- }
458-
459- if p.pt != ENVIRON {
460- // Only the environment provisioner cares about
461- // changes to the environment configuration.
462- if err := environWatcher.Stop(); err != nil {
463- return err
464- }
465- // Don't wait for changes on the channel below.
466- environConfigChanges = nil
467+ // Only wait for the environment if we are an environmental provisioner.
468+ var environConfigChanges <-chan struct{}
469+ var environWatcher apiwatcher.NotifyWatcher
470+ if p.pt == ENVIRON {
471+ environWatcher, err := p.st.WatchForEnvironConfigChanges()
472+ if err != nil {
473+ return err
474+ }
475+ environConfigChanges = environWatcher.Changes()
476+ defer watcher.Stop(environWatcher, &p.tomb)
477+
478+ p.environ, err = worker.WaitForEnviron(environWatcher, p.st, p.tomb.Dying())
479+ if err != nil {
480+ return err
481+ }
482 }
483
484 auth, err := NewAPIAuthenticator(p.st)
485@@ -177,13 +173,12 @@
486 case ENVIRON:
487 return p.environ, nil
488 case LXC:
489- config := p.environ.Config()
490 tools, err := p.getAgentTools()
491 if err != nil {
492 logger.Errorf("cannot get tools from machine for lxc broker")
493 return nil, err
494 }
495- return NewLxcBroker(config, tools, p.agentConfig), nil
496+ return NewLxcBroker(p.st, tools, p.agentConfig), nil
497 }
498 return nil, fmt.Errorf("unknown provisioner type")
499 }

Subscribers

People subscribed via source and target branches

to status/vote changes: