Merge lp:~axwalk/juju-core/lp1303735-fix-address-logic-1.18 into lp:juju-core/1.18
- lp1303735-fix-address-logic-1.18
- Merge into 1.18
Status: | Merged |
---|---|
Merged at revision: | 2281 |
Proposed branch: | lp:~axwalk/juju-core/lp1303735-fix-address-logic-1.18 |
Merge into: | lp:juju-core/1.18 |
Diff against target: |
262 lines (+97/-17) 4 files modified
agent/bootstrap.go (+4/-0) agent/bootstrap_test.go (+3/-0) cmd/jujud/bootstrap.go (+17/-0) cmd/jujud/bootstrap_test.go (+73/-17) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1303735-fix-address-logic-1.18 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+215345@code.launchpad.net |
Commit message
Backport fix for lp:1303735
Description of the change
Backport fix for lp:1303735
Andrew Wilkins (axwalk) wrote : | # |
Ian Booth (wallyworld) wrote : | # |
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~axwalk/juju-core/lp1303735-fix-address-logic-1.18 into lp:juju-core/1.18 failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
-------
FAIL: addresses_
addresses_
// The last address is marked public, all others are unknown.
c.Assert(
... obtained instance.
... expected instance.
OOPS: 18 passed, 1 FAILED
--- FAIL: Test (10.25 seconds)
FAIL
FAIL launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~axwalk/juju-core/lp1303735-fix-address-logic-1.18 into lp:juju-core/1.18 failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
Go Bot (go-bot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Andrew Wilkins (axwalk) wrote : | # |
Please take a look.
Andrew Wilkins (axwalk) wrote : | # |
On 2014/04/30 19:26:15, axw wrote:
> Please take a look.
Ignore this...
Preview Diff
1 | === modified file 'agent/bootstrap.go' |
2 | --- agent/bootstrap.go 2014-03-05 16:30:01 +0000 |
3 | +++ agent/bootstrap.go 2014-04-30 19:25:06 +0000 |
4 | @@ -35,6 +35,9 @@ |
5 | // BootstrapMachineConfig holds configuration information |
6 | // to attach to the bootstrap machine. |
7 | type BootstrapMachineConfig struct { |
8 | + // Addresses holds the bootstrap machine's addresses. |
9 | + Addresses []instance.Address |
10 | + |
11 | // Constraints holds the bootstrap machine's constraints. |
12 | // This value is also used for the environment-level constraints. |
13 | Constraints constraints.Value |
14 | @@ -132,6 +135,7 @@ |
15 | jobs[i] = machineJob |
16 | } |
17 | m, err := st.AddOneMachine(state.MachineTemplate{ |
18 | + Addresses: cfg.Addresses, |
19 | Series: version.Current.Series, |
20 | Nonce: state.BootstrapNonce, |
21 | Constraints: cfg.Constraints, |
22 | |
23 | === modified file 'agent/bootstrap_test.go' |
24 | --- agent/bootstrap_test.go 2014-03-13 07:54:56 +0000 |
25 | +++ agent/bootstrap_test.go 2014-04-30 19:25:06 +0000 |
26 | @@ -63,6 +63,7 @@ |
27 | expectConstraints := constraints.MustParse("mem=1024M") |
28 | expectHW := instance.MustParseHardware("mem=2048M") |
29 | mcfg := agent.BootstrapMachineConfig{ |
30 | + Addresses: instance.NewAddresses([]string{"testing.invalid", "0.1.2.3"}), |
31 | Constraints: expectConstraints, |
32 | Jobs: []params.MachineJob{params.JobHostUnits}, |
33 | InstanceId: "i-bootstrap", |
34 | @@ -101,6 +102,8 @@ |
35 | gotHW, err := m.HardwareCharacteristics() |
36 | c.Assert(err, gc.IsNil) |
37 | c.Assert(*gotHW, gc.DeepEquals, expectHW) |
38 | + gotAddrs := m.Addresses() |
39 | + c.Assert(gotAddrs, gc.DeepEquals, mcfg.Addresses) |
40 | |
41 | // Check that the machine agent's config has been written |
42 | // and that we can use it to connect to the state. |
43 | |
44 | === modified file 'cmd/jujud/bootstrap.go' |
45 | --- cmd/jujud/bootstrap.go 2014-03-24 03:15:34 +0000 |
46 | +++ cmd/jujud/bootstrap.go 2014-04-30 19:25:06 +0000 |
47 | @@ -65,6 +65,22 @@ |
48 | if err := c.Conf.read("machine-0"); err != nil { |
49 | return err |
50 | } |
51 | + |
52 | + // Get the bootstrap machine's addresses from the provider. |
53 | + env, err := environs.New(envCfg) |
54 | + if err != nil { |
55 | + return err |
56 | + } |
57 | + instanceId := instance.Id(c.InstanceId) |
58 | + instances, err := env.Instances([]instance.Id{instanceId}) |
59 | + if err != nil { |
60 | + return err |
61 | + } |
62 | + addrs, err := instances[0].Addresses() |
63 | + if err != nil { |
64 | + return err |
65 | + } |
66 | + |
67 | // agent.Jobs is an optional field in the agent config, and was |
68 | // introduced after 1.17.2. We default to allowing units on |
69 | // machine-0 if missing. |
70 | @@ -76,6 +92,7 @@ |
71 | } |
72 | } |
73 | st, _, err := c.Conf.config.InitializeState(envCfg, agent.BootstrapMachineConfig{ |
74 | + Addresses: addrs, |
75 | Constraints: c.Constraints, |
76 | Jobs: jobs, |
77 | InstanceId: instance.Id(c.InstanceId), |
78 | |
79 | === modified file 'cmd/jujud/bootstrap_test.go' |
80 | --- cmd/jujud/bootstrap_test.go 2014-03-21 14:39:23 +0000 |
81 | +++ cmd/jujud/bootstrap_test.go 2014-04-30 19:25:06 +0000 |
82 | @@ -5,16 +5,22 @@ |
83 | |
84 | import ( |
85 | "encoding/base64" |
86 | + "io" |
87 | + "io/ioutil" |
88 | |
89 | jc "github.com/juju/testing/checkers" |
90 | gc "launchpad.net/gocheck" |
91 | "launchpad.net/goyaml" |
92 | |
93 | "launchpad.net/juju-core/agent" |
94 | + "launchpad.net/juju-core/cmd" |
95 | "launchpad.net/juju-core/constraints" |
96 | "launchpad.net/juju-core/environs" |
97 | + "launchpad.net/juju-core/environs/config" |
98 | + envtesting "launchpad.net/juju-core/environs/testing" |
99 | "launchpad.net/juju-core/errors" |
100 | "launchpad.net/juju-core/instance" |
101 | + jujutesting "launchpad.net/juju-core/juju/testing" |
102 | "launchpad.net/juju-core/provider/dummy" |
103 | "launchpad.net/juju-core/state" |
104 | "launchpad.net/juju-core/state/api/params" |
105 | @@ -29,8 +35,11 @@ |
106 | type BootstrapSuite struct { |
107 | testbase.LoggingSuite |
108 | testing.MgoSuite |
109 | - dataDir string |
110 | - logDir string |
111 | + envcfg string |
112 | + instance instance.Instance |
113 | + dataDir string |
114 | + logDir string |
115 | + bootstrapName string |
116 | } |
117 | |
118 | var _ = gc.Suite(&BootstrapSuite{}) |
119 | @@ -38,11 +47,13 @@ |
120 | func (s *BootstrapSuite) SetUpSuite(c *gc.C) { |
121 | s.LoggingSuite.SetUpSuite(c) |
122 | s.MgoSuite.SetUpSuite(c) |
123 | + s.makeTestEnv(c) |
124 | } |
125 | |
126 | func (s *BootstrapSuite) TearDownSuite(c *gc.C) { |
127 | s.MgoSuite.TearDownSuite(c) |
128 | s.LoggingSuite.TearDownSuite(c) |
129 | + dummy.Reset() |
130 | } |
131 | |
132 | func (s *BootstrapSuite) SetUpTest(c *gc.C) { |
133 | @@ -102,7 +113,7 @@ |
134 | |
135 | func (s *BootstrapSuite) TestInitializeEnvironment(c *gc.C) { |
136 | hw := instance.MustParseHardware("arch=amd64 mem=8G") |
137 | - _, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", testConfig, "--instance-id", "anything", "--hardware", hw.String()) |
138 | + _, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.envcfg, "--instance-id", string(s.instance.Id()), "--hardware", hw.String()) |
139 | c.Assert(err, gc.IsNil) |
140 | err = cmd.Run(nil) |
141 | c.Assert(err, gc.IsNil) |
142 | @@ -120,7 +131,7 @@ |
143 | |
144 | instid, err := machines[0].InstanceId() |
145 | c.Assert(err, gc.IsNil) |
146 | - c.Assert(instid, gc.Equals, instance.Id("anything")) |
147 | + c.Assert(instid, gc.Equals, s.instance.Id()) |
148 | |
149 | stateHw, err := machines[0].HardwareCharacteristics() |
150 | c.Assert(err, gc.IsNil) |
151 | @@ -135,8 +146,8 @@ |
152 | func (s *BootstrapSuite) TestSetConstraints(c *gc.C) { |
153 | tcons := constraints.Value{Mem: uint64p(2048), CpuCores: uint64p(2)} |
154 | _, cmd, err := s.initBootstrapCommand(c, nil, |
155 | - "--env-config", testConfig, |
156 | - "--instance-id", "anything", |
157 | + "--env-config", s.envcfg, |
158 | + "--instance-id", string(s.instance.Id()), |
159 | "--constraints", tcons.String(), |
160 | ) |
161 | c.Assert(err, gc.IsNil) |
162 | @@ -170,7 +181,7 @@ |
163 | expectedJobs := []state.MachineJob{ |
164 | state.JobManageEnviron, state.JobHostUnits, |
165 | } |
166 | - _, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", testConfig, "--instance-id", "anything") |
167 | + _, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.envcfg, "--instance-id", string(s.instance.Id())) |
168 | c.Assert(err, gc.IsNil) |
169 | err = cmd.Run(nil) |
170 | c.Assert(err, gc.IsNil) |
171 | @@ -187,9 +198,31 @@ |
172 | c.Assert(m.Jobs(), gc.DeepEquals, expectedJobs) |
173 | } |
174 | |
175 | +func (s *BootstrapSuite) TestMachineAddresses(c *gc.C) { |
176 | + addrs := instance.NewAddresses([]string{"testing.invalid", "0.1.2.3"}) |
177 | + dummy.SetInstanceAddresses(s.instance, addrs) |
178 | + |
179 | + _, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.envcfg, "--instance-id", string(s.instance.Id())) |
180 | + c.Assert(err, gc.IsNil) |
181 | + err = cmd.Run(nil) |
182 | + c.Assert(err, gc.IsNil) |
183 | + |
184 | + st, err := state.Open(&state.Info{ |
185 | + Addrs: []string{testing.MgoServer.Addr()}, |
186 | + CACert: []byte(testing.CACert), |
187 | + Password: testPasswordHash(), |
188 | + }, state.DefaultDialOpts(), environs.NewStatePolicy()) |
189 | + c.Assert(err, gc.IsNil) |
190 | + defer st.Close() |
191 | + |
192 | + m, err := st.Machine("0") |
193 | + c.Assert(err, gc.IsNil) |
194 | + c.Assert(m.Addresses(), gc.DeepEquals, addrs) |
195 | +} |
196 | + |
197 | func (s *BootstrapSuite) TestConfiguredMachineJobs(c *gc.C) { |
198 | jobs := []params.MachineJob{params.JobManageEnviron} |
199 | - _, cmd, err := s.initBootstrapCommand(c, jobs, "--env-config", testConfig, "--instance-id", "anything") |
200 | + _, cmd, err := s.initBootstrapCommand(c, jobs, "--env-config", s.envcfg, "--instance-id", string(s.instance.Id())) |
201 | c.Assert(err, gc.IsNil) |
202 | err = cmd.Run(nil) |
203 | c.Assert(err, gc.IsNil) |
204 | @@ -219,7 +252,7 @@ |
205 | } |
206 | |
207 | func (s *BootstrapSuite) TestInitialPassword(c *gc.C) { |
208 | - machineConf, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", testConfig, "--instance-id", "anything") |
209 | + machineConf, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.envcfg, "--instance-id", string(s.instance.Id())) |
210 | c.Assert(err, gc.IsNil) |
211 | |
212 | err = cmd.Run(nil) |
213 | @@ -333,6 +366,37 @@ |
214 | } |
215 | } |
216 | |
217 | +func (s *BootstrapSuite) makeTestEnv(c *gc.C) { |
218 | + attrs := dummy.SampleConfig().Merge( |
219 | + testing.Attrs{ |
220 | + "agent-version": version.Current.Number.String(), |
221 | + }, |
222 | + ).Delete("admin-secret", "ca-private-key") |
223 | + |
224 | + cfg, err := config.New(config.NoDefaults, attrs) |
225 | + c.Assert(err, gc.IsNil) |
226 | + provider, err := environs.Provider(cfg.Type()) |
227 | + c.Assert(err, gc.IsNil) |
228 | + env, err := provider.Prepare(nullContext(), cfg) |
229 | + c.Assert(err, gc.IsNil) |
230 | + |
231 | + envtesting.MustUploadFakeTools(env.Storage()) |
232 | + inst, _, err := jujutesting.StartInstance(env, "0") |
233 | + c.Assert(err, gc.IsNil) |
234 | + s.instance = inst |
235 | + s.bootstrapName, err = inst.DNSName() |
236 | + c.Assert(err, gc.IsNil) |
237 | + s.envcfg = b64yaml(env.Config().AllAttrs()).encode() |
238 | +} |
239 | + |
240 | +func nullContext() *cmd.Context { |
241 | + ctx, _ := cmd.DefaultContext() |
242 | + ctx.Stdin = io.LimitReader(nil, 0) |
243 | + ctx.Stdout = ioutil.Discard |
244 | + ctx.Stderr = ioutil.Discard |
245 | + return ctx |
246 | +} |
247 | + |
248 | type b64yaml map[string]interface{} |
249 | |
250 | func (m b64yaml) encode() string { |
251 | @@ -342,11 +406,3 @@ |
252 | } |
253 | return base64.StdEncoding.EncodeToString(data) |
254 | } |
255 | - |
256 | -var testConfig = b64yaml( |
257 | - dummy.SampleConfig().Merge( |
258 | - testing.Attrs{ |
259 | - "state-server": false, |
260 | - "agent-version": "3.4.5", |
261 | - }, |
262 | - ).Delete("admin-secret", "ca-private-key")).encode() |
Reviewers: mp+215345_ code.launchpad. net,
Message:
Please take a look.
Description:
Backport fix for lp:1303735
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1303735- fix-address- logic-1. 18/+merge/ 215345
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/86720043/
Affected files (+281, -105 lines): status_ test.go address_ test.go maas/instance. go openstack/ provider. go openstack/ provider_ test.go machiner/ machiner_ test.go /machine/ machiner. go test.go machiner/ machiner. go machiner/ machiner_ test.go peergrouper/ worker_ test.go
A [revision details]
M cmd/juju/
M instance/address.go
M instance/
M provider/
M provider/
M provider/
M state/api/
M state/apiserver
M state/machine.go
M state/machine_
M state/unit_test.go
M worker/
M worker/
M worker/