Merge lp:~wallyworld/juju-core/unit-agent-knows-assigned-machine into lp:~go-bot/juju-core/trunk

Proposed by Ian Booth
Status: Rejected
Rejected by: William Reade
Proposed branch: lp:~wallyworld/juju-core/unit-agent-knows-assigned-machine
Merge into: lp:~go-bot/juju-core/trunk
Prerequisite: lp:~wallyworld/juju-core/machiner-access-for-uniter
Diff against target: 411 lines (+147/-22)
8 files modified
agent/agent.go (+1/-0)
state/api/uniter/unit.go (+43/-19)
state/api/uniter/unit_test.go (+24/-0)
state/api/uniter/uniter.go (+2/-2)
state/apiserver/uniter/uniter.go (+38/-0)
state/apiserver/uniter/uniter_test.go (+32/-0)
worker/deployer/simple.go (+2/-0)
worker/deployer/simple_test.go (+5/-1)
To merge this branch: bzr merge lp:~wallyworld/juju-core/unit-agent-knows-assigned-machine
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+205291@code.launchpad.net

Description of the change

Unit agents know their assigned machine

The unit agent conf file has a new value called
MACHINE_TAG added when the unit is deployed. The
value is the tag of the machine on which the
unit is deployed.

To allow new tools to run on older deployments
without the updated agent conf file, a new Uniter
API is provided which allows the unit agent to
look up the assigned machine over the API.
The API will be removed when it is possible
to have all current unit agent config files
upgraded.

This functionality is used by a downstream
branch which reworks the uniter upgrade worker.

https://codereview.appspot.com/60930043/

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote :

Reviewers: mp+205291_code.launchpad.net,

Message:
Please take a look.

Description:
Unit agents know their assigned machine

The unit agent conf file has a new value called
MACHINE_TAG added when the unit is deployed. The
value is the tag of the machine on which the
unit is deployed.

To allow new tools to run on older deployments
without the updated agent conf file, a new Uniter
API is provided which allows the unit agent to
look up the assigned machine over the API.
The API will be removed when it is possible
to have all current unit agent config files
upgraded.

This functionality is used by a downstream
branch which reworks the uniter upgrade worker.

https://code.launchpad.net/~wallyworld/juju-core/unit-agent-knows-assigned-machine/+merge/205291

Requires:
https://code.launchpad.net/~wallyworld/juju-core/machiner-access-for-uniter/+merge/205290

(do not edit description out of merge proposal)

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

Affected files (+126, -22 lines):
   A [revision details]
   M agent/agent.go
   M state/api/uniter/unit.go
   M state/api/uniter/unit_test.go
   M state/api/uniter/uniter.go
   M state/apiserver/uniter/uniter.go
   M state/apiserver/uniter/uniter_test.go
   M worker/deployer/simple.go
   M worker/deployer/simple_test.go

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Very good direction, but I have some concerns about backward
compatibility with <1.18 API servers.

https://codereview.appspot.com/60930043/diff/1/state/api/uniter/unit.go
File state/api/uniter/unit.go (right):

https://codereview.appspot.com/60930043/diff/1/state/api/uniter/unit.go#newcode456
state/api/uniter/unit.go:456: err := u.st.caller.Call(uniter, "",
"GetAssignedMachine", args, &results)
We need to be careful here for CodeNotImplemented errors, if this is run
against an older API server. What's the appropriate action to take when
we can't read it from the API server?

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter.go
File state/apiserver/uniter/uniter.go (right):

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter.go#newcode1004
state/apiserver/uniter/uniter.go:1004: if canAccess(entity.Tag) {
To reduce the code nesting, you could define a:

func (u *UniterAPI) getOneAssignedMachine(tag string) (string, error) {
     unit, err := u.getUnit(tag)
     if err != nil {
         return "", err
     }
     machineId, err := unit.AssignedMachineId()
     if err != nil {
         return "", err
     }
     return machineId, nil
}

And then reduce the following block to:

machineId, err := u.getOneAssignedMachine(entity.Tag)
if err == nil {
     reslt.Results[i].Result = names.MachineTag(machineId)
}

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter_test.go
File state/apiserver/uniter/uniter_test.go (right):

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter_test.go#newcode1441
state/apiserver/uniter/uniter_test.go:1441: {Tag: "unit-mysql-0"},
I'd like to see a subsequent test in this method that first unassigns
wordpress/0 and then calls GetAssignedMachine again with args =
params.Entities{Entities: []params.Entity{{Tag: "unit-wordpress-0"}}},
so that the returned error is checked to match
apiservertesting.NotAssignedError(..).

https://codereview.appspot.com/60930043/

2306. By Ian Booth

Merge trunk, resolve conflict

2307. By Ian Booth

Merged machiner-access-for-uniter into unit-agent-knows-assigned-machine.

2308. By Ian Booth

Add test

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

Please take a look.

https://codereview.appspot.com/60930043/diff/1/state/api/uniter/unit.go
File state/api/uniter/unit.go (right):

https://codereview.appspot.com/60930043/diff/1/state/api/uniter/unit.go#newcode456
state/api/uniter/unit.go:456: err := u.st.caller.Call(uniter, "",
"GetAssignedMachine", args, &results)
On 2014/02/10 08:55:04, dimitern wrote:
> We need to be careful here for CodeNotImplemented errors, if this is
run against
> an older API server. What's the appropriate action to take when we
can't read it
> from the API server?

When we upgrade, is the API server upgraded first? If so then,
everything is ok. If not, then I don't think there's much choice other
than to let the error propagate and cause the caller (the unit agent) to
be restarted so it can try again. This call needs to succeed before the
new, upgraded unit agent can come up. So I think letting it keep
retrying is ok here?

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter.go
File state/apiserver/uniter/uniter.go (right):

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter.go#newcode1004
state/apiserver/uniter/uniter.go:1004: if canAccess(entity.Tag) {
On 2014/02/10 08:55:04, dimitern wrote:
> To reduce the code nesting, you could define a:

> func (u *UniterAPI) getOneAssignedMachine(tag string) (string, error)
{
> unit, err := u.getUnit(tag)
> if err != nil {
> return "", err
> }
> machineId, err := unit.AssignedMachineId()
> if err != nil {
> return "", err
> }
> return machineId, nil
> }

> And then reduce the following block to:

> machineId, err := u.getOneAssignedMachine(entity.Tag)
> if err == nil {
> reslt.Results[i].Result = names.MachineTag(machineId)
> }

Done.

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter_test.go
File state/apiserver/uniter/uniter_test.go (right):

https://codereview.appspot.com/60930043/diff/1/state/apiserver/uniter/uniter_test.go#newcode1441
state/apiserver/uniter/uniter_test.go:1441: {Tag: "unit-mysql-0"},
On 2014/02/10 08:55:04, dimitern wrote:
> I'd like to see a subsequent test in this method that first unassigns
> wordpress/0 and then calls GetAssignedMachine again with args =
> params.Entities{Entities: []params.Entity{{Tag: "unit-wordpress-0"}}},
so that
> the returned error is checked to match
apiservertesting.NotAssignedError(..).

Done.

https://codereview.appspot.com/60930043/

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

LGTM

https://codereview.appspot.com/60930043/diff/20001/agent/agent.go
File agent/agent.go (right):

https://codereview.appspot.com/60930043/diff/20001/agent/agent.go#newcode34
agent/agent.go:34: BootstrapJobs = "BOOTSTRAP_JOBS"
Where is this coming from? Update the CL description?

https://codereview.appspot.com/60930043/

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

https://codereview.appspot.com/60930043/diff/20001/agent/agent.go
File agent/agent.go (right):

https://codereview.appspot.com/60930043/diff/20001/agent/agent.go#newcode34
agent/agent.go:34: BootstrapJobs = "BOOTSTRAP_JOBS"
On 2014/02/11 09:52:19, dimitern wrote:
> Where is this coming from? Update the CL description?

I merged trunk and shiteveld can't handle such merges properly so it
gets confused. Launchpad has the correct diff.

https://codereview.appspot.com/60930043/

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

On 2014/02/11 10:28:03, wallyworld wrote:
> https://codereview.appspot.com/60930043/diff/20001/agent/agent.go
> File agent/agent.go (right):

https://codereview.appspot.com/60930043/diff/20001/agent/agent.go#newcode34
> agent/agent.go:34: BootstrapJobs = "BOOTSTRAP_JOBS"
> On 2014/02/11 09:52:19, dimitern wrote:
> > Where is this coming from? Update the CL description?

> I merged trunk and shiteveld can't handle such merges properly so it
gets
> confused. Launchpad has the correct diff.

as prereq, not lgtm

https://codereview.appspot.com/60930043/

Unmerged revisions

2308. By Ian Booth

Add test

2307. By Ian Booth

Merged machiner-access-for-uniter into unit-agent-knows-assigned-machine.

2306. By Ian Booth

Merge trunk, resolve conflict

2305. By Ian Booth

Unit agents can find out their assigned machine

2304. By Ian Booth

Unit agents have read access to machines on which their units are deployed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'agent/agent.go'
2--- agent/agent.go 2014-02-05 08:01:22 +0000
3+++ agent/agent.go 2014-02-11 02:38:51 +0000
4@@ -32,6 +32,7 @@
5 MongoServiceName = "MONGO_SERVICE_NAME"
6 RsyslogConfPath = "RSYSLOG_CONF_PATH"
7 BootstrapJobs = "BOOTSTRAP_JOBS"
8+ MachineTag = "MACHINE_TAG"
9 )
10
11 // The Config interface is the sole way that the agent gets access to the
12
13=== modified file 'state/api/uniter/unit.go'
14--- state/api/uniter/unit.go 2013-09-26 17:23:34 +0000
15+++ state/api/uniter/unit.go 2014-02-11 02:38:51 +0000
16@@ -62,7 +62,7 @@
17 {Tag: u.tag, Status: status, Info: info, Data: data},
18 },
19 }
20- err := u.st.caller.Call("Uniter", "", "SetStatus", args, &result)
21+ err := u.st.caller.Call(uniter, "", "SetStatus", args, &result)
22 if err != nil {
23 return err
24 }
25@@ -76,7 +76,7 @@
26 args := params.Entities{
27 Entities: []params.Entity{{Tag: u.tag}},
28 }
29- err := u.st.caller.Call("Uniter", "", "EnsureDead", args, &result)
30+ err := u.st.caller.Call(uniter, "", "EnsureDead", args, &result)
31 if err != nil {
32 return err
33 }
34@@ -89,7 +89,7 @@
35 args := params.Entities{
36 Entities: []params.Entity{{Tag: u.tag}},
37 }
38- err := u.st.caller.Call("Uniter", "", "Watch", args, &results)
39+ err := u.st.caller.Call(uniter, "", "Watch", args, &results)
40 if err != nil {
41 return nil, err
42 }
43@@ -129,7 +129,7 @@
44 args := params.Entities{
45 Entities: []params.Entity{{Tag: u.tag}},
46 }
47- err := u.st.caller.Call("Uniter", "", "ConfigSettings", args, &results)
48+ err := u.st.caller.Call(uniter, "", "ConfigSettings", args, &results)
49 if err != nil {
50 return nil, err
51 }
52@@ -163,7 +163,7 @@
53 args := params.Entities{
54 Entities: []params.Entity{{Tag: u.tag}},
55 }
56- err := u.st.caller.Call("Uniter", "", "Destroy", args, &result)
57+ err := u.st.caller.Call(uniter, "", "Destroy", args, &result)
58 if err != nil {
59 return err
60 }
61@@ -176,7 +176,7 @@
62 args := params.Entities{
63 Entities: []params.Entity{{Tag: u.tag}},
64 }
65- err := u.st.caller.Call("Uniter", "", "DestroyAllSubordinates", args, &result)
66+ err := u.st.caller.Call(uniter, "", "DestroyAllSubordinates", args, &result)
67 if err != nil {
68 return err
69 }
70@@ -192,7 +192,7 @@
71 args := params.Entities{
72 Entities: []params.Entity{{Tag: u.tag}},
73 }
74- err := u.st.caller.Call("Uniter", "", "Resolved", args, &results)
75+ err := u.st.caller.Call(uniter, "", "Resolved", args, &results)
76 if err != nil {
77 return "", err
78 }
79@@ -216,7 +216,7 @@
80 args := params.Entities{
81 Entities: []params.Entity{{Tag: u.tag}},
82 }
83- err := u.st.caller.Call("Uniter", "", "GetPrincipal", args, &results)
84+ err := u.st.caller.Call(uniter, "", "GetPrincipal", args, &results)
85 if err != nil {
86 return false, err
87 }
88@@ -237,7 +237,7 @@
89 args := params.Entities{
90 Entities: []params.Entity{{Tag: u.tag}},
91 }
92- err := u.st.caller.Call("Uniter", "", "HasSubordinates", args, &results)
93+ err := u.st.caller.Call(uniter, "", "HasSubordinates", args, &results)
94 if err != nil {
95 return false, err
96 }
97@@ -264,7 +264,7 @@
98 args := params.Entities{
99 Entities: []params.Entity{{Tag: u.tag}},
100 }
101- err := u.st.caller.Call("Uniter", "", "PublicAddress", args, &results)
102+ err := u.st.caller.Call(uniter, "", "PublicAddress", args, &results)
103 if err != nil {
104 return "", err
105 }
106@@ -289,7 +289,7 @@
107 {Tag: u.tag, Address: address},
108 },
109 }
110- err := u.st.caller.Call("Uniter", "", "SetPublicAddress", args, &result)
111+ err := u.st.caller.Call(uniter, "", "SetPublicAddress", args, &result)
112 if err != nil {
113 return err
114 }
115@@ -309,7 +309,7 @@
116 args := params.Entities{
117 Entities: []params.Entity{{Tag: u.tag}},
118 }
119- err := u.st.caller.Call("Uniter", "", "PrivateAddress", args, &results)
120+ err := u.st.caller.Call(uniter, "", "PrivateAddress", args, &results)
121 if err != nil {
122 return "", err
123 }
124@@ -334,7 +334,7 @@
125 {Tag: u.tag, Address: address},
126 },
127 }
128- err := u.st.caller.Call("Uniter", "", "SetPrivateAddress", args, &result)
129+ err := u.st.caller.Call(uniter, "", "SetPrivateAddress", args, &result)
130 if err != nil {
131 return err
132 }
133@@ -353,7 +353,7 @@
134 {Tag: u.tag, Protocol: protocol, Port: number},
135 },
136 }
137- err := u.st.caller.Call("Uniter", "", "OpenPort", args, &result)
138+ err := u.st.caller.Call(uniter, "", "OpenPort", args, &result)
139 if err != nil {
140 return err
141 }
142@@ -372,7 +372,7 @@
143 {Tag: u.tag, Protocol: protocol, Port: number},
144 },
145 }
146- err := u.st.caller.Call("Uniter", "", "ClosePort", args, &result)
147+ err := u.st.caller.Call(uniter, "", "ClosePort", args, &result)
148 if err != nil {
149 return err
150 }
151@@ -390,7 +390,7 @@
152 args := params.Entities{
153 Entities: []params.Entity{{Tag: u.tag}},
154 }
155- err := u.st.caller.Call("Uniter", "", "CharmURL", args, &results)
156+ err := u.st.caller.Call(uniter, "", "CharmURL", args, &results)
157 if err != nil {
158 return nil, err
159 }
160@@ -423,7 +423,7 @@
161 {Tag: u.tag, CharmURL: curl.String()},
162 },
163 }
164- err := u.st.caller.Call("Uniter", "", "SetCharmURL", args, &result)
165+ err := u.st.caller.Call(uniter, "", "SetCharmURL", args, &result)
166 if err != nil {
167 return err
168 }
169@@ -436,13 +436,37 @@
170 args := params.Entities{
171 Entities: []params.Entity{{Tag: u.tag}},
172 }
173- err := u.st.caller.Call("Uniter", "", "ClearResolved", args, &result)
174+ err := u.st.caller.Call(uniter, "", "ClearResolved", args, &result)
175 if err != nil {
176 return err
177 }
178 return result.OneError()
179 }
180
181+// AssignedMachine returns the tag of this unit's assigned machine (if
182+// any), or a CodeNotAssigned error.
183+// TODO(wallyworld) - this API is needed for backwards compatibility since for > 1.18 the
184+// assigned machine is recorded in the unit agent config file. For < 1.18, this API must
185+// be used instead. Once upgrade infrastructure is in place, this API can be removed.
186+func (u *Unit) AssignedMachine() (string, error) {
187+ var results params.StringResults
188+ args := params.Entities{
189+ Entities: []params.Entity{{Tag: u.tag}},
190+ }
191+ err := u.st.caller.Call(uniter, "", "GetAssignedMachine", args, &results)
192+ if err != nil {
193+ return "", err
194+ }
195+ if len(results.Results) != 1 {
196+ return "", fmt.Errorf("expected one result, got %d", len(results.Results))
197+ }
198+ result := results.Results[0]
199+ if result.Error != nil {
200+ return "", result.Error
201+ }
202+ return result.Result, nil
203+}
204+
205 // WatchConfigSettings returns a watcher for observing changes to the
206 // unit's service configuration settings. The unit must have a charm URL
207 // set before this method is called, and the returned watcher will be
208@@ -452,7 +476,7 @@
209 args := params.Entities{
210 Entities: []params.Entity{{Tag: u.tag}},
211 }
212- err := u.st.caller.Call("Uniter", "", "WatchConfigSettings", args, &results)
213+ err := u.st.caller.Call(uniter, "", "WatchConfigSettings", args, &results)
214 if err != nil {
215 return nil, err
216 }
217
218=== modified file 'state/api/uniter/unit_test.go'
219--- state/api/uniter/unit_test.go 2013-09-27 15:40:55 +0000
220+++ state/api/uniter/unit_test.go 2014-02-11 02:38:51 +0000
221@@ -14,6 +14,7 @@
222 "launchpad.net/juju-core/state/api/uniter"
223 statetesting "launchpad.net/juju-core/state/testing"
224 jc "launchpad.net/juju-core/testing/checkers"
225+ "launchpad.net/juju-core/utils"
226 )
227
228 type unitSuite struct {
229@@ -177,6 +178,29 @@
230 c.Assert(mode, gc.Equals, params.ResolvedNone)
231 }
232
233+func (s *unitSuite) TestAssignedMachine(c *gc.C) {
234+ tag, err := s.apiUnit.AssignedMachine()
235+ c.Assert(err, gc.IsNil)
236+ c.Assert(tag, gc.Equals, s.wordpressMachine.Tag())
237+}
238+
239+func (s *unitSuite) TestAssignedMachineUnassignedUnit(c *gc.C) {
240+ unassignedUnit, err := s.wordpressService.AddUnit()
241+ c.Assert(err, gc.IsNil)
242+ password, err := utils.RandomPassword()
243+ c.Assert(err, gc.IsNil)
244+ err = unassignedUnit.SetPassword(password)
245+ c.Assert(err, gc.IsNil)
246+ st := s.OpenAPIAs(c, unassignedUnit.Tag(), password)
247+ uniter := st.Uniter()
248+ c.Assert(uniter, gc.NotNil)
249+
250+ apiUnit, err := uniter.Unit(unassignedUnit.Tag())
251+ c.Assert(err, gc.IsNil)
252+ _, err = apiUnit.AssignedMachine()
253+ c.Assert(err, jc.Satisfies, params.IsCodeNotAssigned)
254+}
255+
256 func (s *unitSuite) TestIsPrincipal(c *gc.C) {
257 ok, err := s.apiUnit.IsPrincipal()
258 c.Assert(err, gc.IsNil)
259
260=== modified file 'state/api/uniter/uniter.go'
261--- state/api/uniter/uniter.go 2014-02-03 11:45:15 +0000
262+++ state/api/uniter/uniter.go 2014-02-11 02:38:51 +0000
263@@ -156,7 +156,7 @@
264 // Environment returns the environment entity.
265 func (st *State) Environment() (*Environment, error) {
266 var result params.EnvironmentResult
267- err := st.caller.Call("Uniter", "", "CurrentEnvironment", nil, &result)
268+ err := st.caller.Call(uniter, "", "CurrentEnvironment", nil, &result)
269 if params.IsCodeNotImplemented(err) {
270 // Fall back to using the 1.16 API.
271 return st.environment1dot16()
272@@ -177,7 +177,7 @@
273 // using an older API server that does not support CurrentEnvironment API call.
274 func (st *State) environment1dot16() (*Environment, error) {
275 var result params.StringResult
276- err := st.caller.Call("Uniter", "", "CurrentEnvironUUID", nil, &result)
277+ err := st.caller.Call(uniter, "", "CurrentEnvironUUID", nil, &result)
278 if err != nil {
279 return nil, err
280 }
281
282=== modified file 'state/apiserver/uniter/uniter.go'
283--- state/apiserver/uniter/uniter.go 2014-02-03 11:45:15 +0000
284+++ state/apiserver/uniter/uniter.go 2014-02-11 02:38:51 +0000
285@@ -986,3 +986,41 @@
286 Result: service.GetOwnerTag(),
287 }, nil
288 }
289+
290+// GetAssignedMachine returns the assigned machine tag (if any) for each given unit.
291+// TODO(wallyworld) - this API is needed for backwards compatibility since for > 1.18 the
292+// assigned machine is recorded in the unit agent config file. For < 1.18, this API must
293+// be used instead. Once upgrade infrastructure is in place, this API can be removed.
294+func (u *UniterAPI) GetAssignedMachine(args params.Entities) (params.StringResults, error) {
295+ result := params.StringResults{
296+ Results: make([]params.StringResult, len(args.Entities)),
297+ }
298+ canAccess, err := u.accessUnit()
299+ if err != nil {
300+ return params.StringResults{}, err
301+ }
302+ for i, entity := range args.Entities {
303+ err := common.ErrPerm
304+ if canAccess(entity.Tag) {
305+ var machineId string
306+ machineId, err = u.getOneAssignedMachine(entity.Tag)
307+ if err == nil {
308+ result.Results[i].Result = names.MachineTag(machineId)
309+ }
310+ }
311+ result.Results[i].Error = common.ServerError(err)
312+ }
313+ return result, nil
314+}
315+
316+func (u *UniterAPI) getOneAssignedMachine(tag string) (string, error) {
317+ unit, err := u.getUnit(tag)
318+ if err != nil {
319+ return "", err
320+ }
321+ machineId, err := unit.AssignedMachineId()
322+ if err != nil {
323+ return "", err
324+ }
325+ return machineId, nil
326+}
327
328=== modified file 'state/apiserver/uniter/uniter_test.go'
329--- state/apiserver/uniter/uniter_test.go 2014-02-03 11:45:15 +0000
330+++ state/apiserver/uniter/uniter_test.go 2014-02-11 02:38:51 +0000
331@@ -1435,3 +1435,35 @@
332 Result: "user-admin",
333 })
334 }
335+
336+func (s *uniterSuite) TestGetAssignedMachine(c *gc.C) {
337+ args := params.Entities{Entities: []params.Entity{
338+ {Tag: "unit-mysql-0"},
339+ {Tag: "unit-wordpress-0"},
340+ {Tag: "unit-foo-42"},
341+ }}
342+ result, err := s.uniter.GetAssignedMachine(args)
343+ c.Assert(err, gc.IsNil)
344+ c.Assert(result, gc.DeepEquals, params.StringResults{
345+ Results: []params.StringResult{
346+ {Error: apiservertesting.ErrUnauthorized},
347+ {Result: "machine-0", Error: nil},
348+ {Error: apiservertesting.ErrUnauthorized},
349+ },
350+ })
351+}
352+
353+func (s *uniterSuite) TestGetAssignedMachineUnassignedUnit(c *gc.C) {
354+ err := s.wordpressUnit.UnassignFromMachine()
355+ c.Assert(err, gc.IsNil)
356+ args := params.Entities{Entities: []params.Entity{
357+ {Tag: "unit-wordpress-0"},
358+ }}
359+ result, err := s.uniter.GetAssignedMachine(args)
360+ c.Assert(err, gc.IsNil)
361+ c.Assert(result, gc.DeepEquals, params.StringResults{
362+ Results: []params.StringResult{
363+ {Error: apiservertesting.NotAssignedError("wordpress/0")},
364+ },
365+ })
366+}
367
368=== modified file 'worker/deployer/simple.go'
369--- worker/deployer/simple.go 2014-01-22 22:48:54 +0000
370+++ worker/deployer/simple.go 2014-02-11 02:38:51 +0000
371@@ -96,6 +96,7 @@
372 logger.Debugf("API addresses: %q", result.APIAddresses)
373 containerType := ctx.agentConfig.Value(agent.ContainerType)
374 namespace := ctx.agentConfig.Value(agent.Namespace)
375+ machineTag := ctx.AgentConfig().Tag()
376 conf, err := agent.NewAgentConfig(
377 agent.AgentConfigParams{
378 DataDir: dataDir,
379@@ -109,6 +110,7 @@
380 Values: map[string]string{
381 agent.ContainerType: containerType,
382 agent.Namespace: namespace,
383+ agent.MachineTag: machineTag,
384 },
385 })
386 if err != nil {
387
388=== modified file 'worker/deployer/simple_test.go'
389--- worker/deployer/simple_test.go 2013-11-21 03:22:49 +0000
390+++ worker/deployer/simple_test.go 2014-02-11 02:38:51 +0000
391@@ -188,8 +188,11 @@
392 c.Assert(fis, gc.HasLen, count)
393 }
394
395+// The machine to which units are deployed.
396+const machineTag = "machine-tag"
397+
398 func (fix *SimpleToolsFixture) getContext(c *gc.C) *deployer.SimpleContext {
399- config := agentConfig("machine-tag", fix.dataDir)
400+ config := agentConfig(machineTag, fix.dataDir)
401 return deployer.NewTestSimpleContext(config, fix.initDir, fix.logDir, fix.syslogConfigDir)
402 }
403
404@@ -257,6 +260,7 @@
405 c.Assert(err, gc.IsNil)
406 c.Assert(conf.Tag(), gc.Equals, tag)
407 c.Assert(conf.DataDir(), gc.Equals, fix.dataDir)
408+ c.Assert(conf.Value("MACHINE_TAG"), gc.Equals, machineTag)
409
410 jujudData, err := ioutil.ReadFile(jujudPath)
411 c.Assert(err, gc.IsNil)

Subscribers

People subscribed via source and target branches

to status/vote changes: