Merge lp:~mskalka/juju-ci-tools/remove-constraints-from-bootstrap into lp:juju-ci-tools
- remove-constraints-from-bootstrap
- Merge into trunk
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~mskalka/juju-ci-tools/remove-constraints-from-bootstrap | ||||
Merge into: | lp:juju-ci-tools | ||||
Diff against target: |
374 lines (+53/-51) (has conflicts) 6 files modified
jujupy/client.py (+12/-12) jujupy/tests/test_client.py (+16/-23) jujupy/version_client.py (+9/-0) tests/test_assess_cloud.py (+3/-3) tests/test_deploy_stack.py (+11/-11) tests/test_industrial_test.py (+2/-2) Text conflict in jujupy/tests/test_client.py |
||||
To merge this branch: | bzr merge lp:~mskalka/juju-ci-tools/remove-constraints-from-bootstrap | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Curtis Hovey (community) | code | Approve | |
Review via email: mp+321768@code.launchpad.net |
Commit message
Description of the change
Removes forced constraints from Jujupy 2.x bootstraps with the exception of MaaS and Joyent environments where minimal constraints are needed. This forces Juju to determine its own instance type on bootstrap.
Michael Skalka (mskalka) wrote : | # |
Going back to the bug Aaron submitted, if we have a substrate that Juju is pulling invalid instance-types for then that needs to be fixed in Juju, not our tests. If that means our tests break until they fix it then that's what happens. I agree with his statement that Juju should work 'out of the box' in all 2.0 cases.
Regarding being used in models, is that in our own code? I'm not sure what you mean there.
I'm going to revert the restore_backup change, but I would like to hear your thoughts before I merge this.
- 1972. By Michael Skalka
-
reverted restore backup change
Unmerged revisions
- 1972. By Michael Skalka
-
reverted restore backup change
- 1971. By Michael Skalka
-
removed constraints from 2.x juju client bootstraps
Preview Diff
1 | === modified file 'jujupy/client.py' |
2 | --- jujupy/client.py 2017-04-05 23:07:51 +0000 |
3 | +++ jujupy/client.py 2017-04-06 14:39:27 +0000 |
4 | @@ -1858,11 +1858,13 @@ |
5 | cloud_region = self.get_cloud_region(self.env.get_cloud(), |
6 | self.env.get_region()) |
7 | # Note cloud_region before controller name |
8 | - args = ['--constraints', constraints, |
9 | - cloud_region, |
10 | - self.env.environment, |
11 | - '--config', config_filename, |
12 | - '--default-model', self.env.environment] |
13 | + args = [] |
14 | + if constraints: |
15 | + args.extend(['--constraints', constraints]) |
16 | + args.extend([cloud_region, |
17 | + self.env.environment, |
18 | + '--config', config_filename, |
19 | + '--default-model', self.env.environment]) |
20 | if upload_tools: |
21 | if agent_version is not None: |
22 | raise ValueError( |
23 | @@ -2338,18 +2340,17 @@ |
24 | def _get_substrate_constraints(self): |
25 | if self.env.joyent: |
26 | # Only accept kvm packages by requiring >1 cpu core, see lp:1446264 |
27 | - return 'mem=2G cpu-cores=1' |
28 | + return 'cpu-cores=1' |
29 | elif self.env.maas and self._maas_spaces_enabled(): |
30 | # For now only maas support spaces in a meaningful way. |
31 | - return 'mem=2G spaces={}'.format(','.join( |
32 | + return 'spaces={}'.format(','.join( |
33 | '^' + space for space in sorted(self.excluded_spaces))) |
34 | else: |
35 | - return 'mem=2G' |
36 | + return None |
37 | |
38 | def quickstart(self, bundle_template, upload_tools=False): |
39 | bundle = self.format_bundle(bundle_template) |
40 | - constraints = 'mem=2G' |
41 | - args = ('--constraints', constraints) |
42 | + args = () |
43 | if upload_tools: |
44 | args = ('--upload-tools',) + args |
45 | args = args + ('--no-browser', bundle,) |
46 | @@ -2715,8 +2716,7 @@ |
47 | ('-b', '--constraints', 'mem=2G', '--file', backup_file)) |
48 | |
49 | def restore_backup_async(self, backup_file): |
50 | - return self.juju_async('restore-backup', ('-b', '--constraints', |
51 | - 'mem=2G', '--file', backup_file)) |
52 | + return self.juju_async('restore-backup', ('-b', '--file', backup_file)) |
53 | |
54 | def enable_ha(self): |
55 | self.juju( |
56 | |
57 | === modified file 'jujupy/tests/test_client.py' |
58 | --- jujupy/tests/test_client.py 2017-03-28 00:51:36 +0000 |
59 | +++ jujupy/tests/test_client.py 2017-04-06 14:39:27 +0000 |
60 | @@ -668,7 +668,7 @@ |
61 | client.bootstrap() |
62 | mock.assert_called_with( |
63 | 'bootstrap', ( |
64 | - '--constraints', 'mem=2G spaces=^endpoint-bindings-data,' |
65 | + '--constraints', 'spaces=^endpoint-bindings-data,' |
66 | '^endpoint-bindings-public', |
67 | 'foo/asdf', 'maas', |
68 | '--config', config_file.name, '--default-model', 'maas', |
69 | @@ -686,7 +686,6 @@ |
70 | client.bootstrap() |
71 | mock.assert_called_with( |
72 | 'bootstrap', ( |
73 | - '--constraints', 'mem=2G', |
74 | 'foo/asdf', 'maas', |
75 | '--config', config_file.name, '--default-model', 'maas', |
76 | '--agent-version', '2.0'), |
77 | @@ -701,8 +700,13 @@ |
78 | with observable_temp_file() as config_file: |
79 | client.bootstrap() |
80 | mock.assert_called_once_with( |
81 | +<<<<<<< TREE |
82 | 'bootstrap', ( |
83 | '--constraints', 'mem=2G cpu-cores=1', |
84 | +======= |
85 | + client, 'bootstrap', ( |
86 | + '--constraints', 'cpu-cores=1', |
87 | +>>>>>>> MERGE-SOURCE |
88 | 'joyent/foo', 'joyent', |
89 | '--config', config_file.name, |
90 | '--default-model', 'joyent', '--agent-version', '2.0', |
91 | @@ -715,8 +719,7 @@ |
92 | client = ModelClient(env, '2.0-zeta1', None) |
93 | client.bootstrap() |
94 | mock.assert_called_with( |
95 | - 'bootstrap', ('--constraints', 'mem=2G', |
96 | - 'bar/baz', 'foo', |
97 | + 'bootstrap', ('bar/baz', 'foo', |
98 | '--config', config_file.name, |
99 | '--default-model', 'foo', |
100 | '--agent-version', '2.0'), include_e=False) |
101 | @@ -732,7 +735,7 @@ |
102 | client.bootstrap(upload_tools=True) |
103 | mock.assert_called_with( |
104 | 'bootstrap', ( |
105 | - '--upload-tools', '--constraints', 'mem=2G', |
106 | + '--upload-tools', |
107 | 'foo/baz', 'foo', |
108 | '--config', config_file.name, |
109 | '--default-model', 'foo'), include_e=False) |
110 | @@ -745,7 +748,6 @@ |
111 | client.bootstrap(credential='credential_name') |
112 | mock.assert_called_with( |
113 | 'bootstrap', ( |
114 | - '--constraints', 'mem=2G', |
115 | 'foo/baz', 'foo', |
116 | '--config', config_file.name, |
117 | '--default-model', 'foo', '--agent-version', '2.0', |
118 | @@ -759,7 +761,6 @@ |
119 | client.bootstrap(bootstrap_series='angsty') |
120 | mock.assert_called_with( |
121 | 'bootstrap', ( |
122 | - '--constraints', 'mem=2G', |
123 | 'bar/baz', 'foo', |
124 | '--config', config_file.name, '--default-model', 'foo', |
125 | '--agent-version', '2.0', |
126 | @@ -773,7 +774,6 @@ |
127 | client.bootstrap(auto_upgrade=True) |
128 | mock.assert_called_with( |
129 | 'bootstrap', ( |
130 | - '--constraints', 'mem=2G', |
131 | 'bar/baz', 'foo', |
132 | '--config', config_file.name, '--default-model', 'foo', |
133 | '--agent-version', '2.0', '--auto-upgrade'), include_e=False) |
134 | @@ -786,7 +786,6 @@ |
135 | client.bootstrap(no_gui=True) |
136 | mock.assert_called_with( |
137 | 'bootstrap', ( |
138 | - '--constraints', 'mem=2G', |
139 | 'bar/baz', 'foo', |
140 | '--config', config_file.name, '--default-model', 'foo', |
141 | '--agent-version', '2.0', '--no-gui'), include_e=False) |
142 | @@ -799,7 +798,6 @@ |
143 | client.bootstrap(metadata_source='/var/test-source') |
144 | mock.assert_called_with( |
145 | 'bootstrap', ( |
146 | - '--constraints', 'mem=2G', |
147 | 'bar/baz', 'foo', |
148 | '--config', config_file.name, '--default-model', 'foo', |
149 | '--agent-version', '2.0', |
150 | @@ -812,8 +810,7 @@ |
151 | args = client.get_bootstrap_args( |
152 | upload_tools=False, config_filename='config') |
153 | self.assertEqual( |
154 | - ('--constraints', 'mem=2G', 'bar/baz', 'foo', |
155 | - '--config', 'config', '--default-model', 'foo', |
156 | + ('bar/baz', 'foo', '--config', 'config', '--default-model', 'foo', |
157 | '--agent-version', '2.0', '--to', 'zone=fnord'), |
158 | args) |
159 | |
160 | @@ -826,7 +823,6 @@ |
161 | with client.bootstrap_async(): |
162 | mock.assert_called_once_with( |
163 | client, 'bootstrap', ( |
164 | - '--constraints', 'mem=2G', |
165 | 'bar/baz', 'foo', |
166 | '--config', config_file.name, |
167 | '--default-model', 'foo', |
168 | @@ -840,7 +836,7 @@ |
169 | with client.bootstrap_async(upload_tools=True): |
170 | mock.assert_called_with( |
171 | client, 'bootstrap', ( |
172 | - '--upload-tools', '--constraints', 'mem=2G', |
173 | + '--upload-tools', |
174 | 'bar/baz', 'foo', |
175 | '--config', config_file.name, |
176 | '--default-model', 'foo', |
177 | @@ -854,7 +850,7 @@ |
178 | config_filename='config', |
179 | bootstrap_series='angsty') |
180 | self.assertEqual(args, ( |
181 | - '--upload-tools', '--constraints', 'mem=2G', |
182 | + '--upload-tools', |
183 | 'bar/baz', 'foo', |
184 | '--config', 'config', '--default-model', 'foo', |
185 | '--bootstrap-series', 'angsty')) |
186 | @@ -865,8 +861,7 @@ |
187 | args = client.get_bootstrap_args(upload_tools=False, |
188 | config_filename='config', |
189 | agent_version='2.0-lambda1') |
190 | - self.assertEqual(('--constraints', 'mem=2G', |
191 | - 'bar/baz', 'foo', |
192 | + self.assertEqual(('bar/baz', 'foo', |
193 | '--config', 'config', '--default-model', 'foo', |
194 | '--agent-version', '2.0-lambda1'), args) |
195 | |
196 | @@ -2988,7 +2983,7 @@ |
197 | with patch.object(client, 'juju_async') as gjo_mock: |
198 | result = client.restore_backup_async('quxx') |
199 | gjo_mock.assert_called_once_with('restore-backup', ( |
200 | - '-b', '--constraints', 'mem=2G', '--file', 'quxx')) |
201 | + '-b', '--file', 'quxx')) |
202 | self.assertIs(gjo_mock.return_value, result) |
203 | |
204 | def test_enable_ha(self): |
205 | @@ -3123,7 +3118,7 @@ |
206 | with patch.object(ModelClient, 'juju') as mock: |
207 | client.quickstart('bundle:~juju-qa/some-bundle') |
208 | mock.assert_called_with( |
209 | - 'quickstart', ('--constraints', 'mem=2G', '--no-browser', |
210 | + 'quickstart', ('--no-browser', |
211 | 'bundle:~juju-qa/some-bundle'), |
212 | extra_env={'JUJU': '/juju'}) |
213 | |
214 | @@ -3133,8 +3128,7 @@ |
215 | with patch.object(ModelClient, 'juju') as mock: |
216 | client.quickstart('bundle:~juju-qa/some-bundle') |
217 | mock.assert_called_with( |
218 | - 'quickstart', ('--constraints', 'mem=2G', '--no-browser', |
219 | - 'bundle:~juju-qa/some-bundle'), |
220 | + 'quickstart', ('--no-browser', 'bundle:~juju-qa/some-bundle'), |
221 | extra_env={'JUJU': '/juju'}) |
222 | |
223 | def test_quickstart_template(self): |
224 | @@ -3143,8 +3137,7 @@ |
225 | with patch.object(ModelClient, 'juju') as mock: |
226 | client.quickstart('bundle:~juju-qa/some-{container}-bundle') |
227 | mock.assert_called_with( |
228 | - 'quickstart', ('--constraints', 'mem=2G', '--no-browser', |
229 | - 'bundle:~juju-qa/some-lxd-bundle'), |
230 | + 'quickstart', ('--no-browser', 'bundle:~juju-qa/some-lxd-bundle'), |
231 | extra_env={'JUJU': '/juju'}) |
232 | |
233 | def test_action_do(self): |
234 | |
235 | === modified file 'jujupy/version_client.py' |
236 | --- jujupy/version_client.py 2017-04-05 23:07:51 +0000 |
237 | +++ jujupy/version_client.py 2017-04-06 14:39:27 +0000 |
238 | @@ -432,6 +432,15 @@ |
239 | else: |
240 | return 'mem=2G' |
241 | |
242 | + def quickstart(self, bundle_template, upload_tools=False): |
243 | + bundle = self.format_bundle(bundle_template) |
244 | + constraints = 'mem=2G' |
245 | + args = ('--constraints', constraints) |
246 | + if upload_tools: |
247 | + args = ('--upload-tools',) + args |
248 | + args = args + ('--no-browser', bundle,) |
249 | + self.juju('quickstart', args, extra_env={'JUJU': self.full_path}) |
250 | + |
251 | def get_bootstrap_args(self, upload_tools, bootstrap_series=None, |
252 | credential=None): |
253 | """Return the bootstrap arguments for the substrate.""" |
254 | |
255 | === modified file 'tests/test_assess_cloud.py' |
256 | --- tests/test_assess_cloud.py 2017-03-02 16:11:04 +0000 |
257 | +++ tests/test_assess_cloud.py 2017-04-06 14:39:27 +0000 |
258 | @@ -79,7 +79,7 @@ |
259 | test_case.assertEqual([ |
260 | backend_call( |
261 | client, 'bootstrap', ( |
262 | - '--constraints', 'mem=2G', 'foo/bar', 'foo', '--config', |
263 | + 'foo/bar', 'foo', '--config', |
264 | config_file.name, '--default-model', 'foo', |
265 | '--agent-version', client.version)), |
266 | backend_call(client, 'deploy', 'ubuntu', 'foo:foo'), |
267 | @@ -107,7 +107,7 @@ |
268 | test_case.assertEqual([ |
269 | backend_call( |
270 | client, 'bootstrap', ( |
271 | - '--constraints', 'mem=2G', 'foo/bar', 'foo', '--config', |
272 | + 'foo/bar', 'foo', '--config', |
273 | config_file.name, '--default-model', 'foo', |
274 | '--agent-version', client.version)), |
275 | backend_call( |
276 | @@ -144,7 +144,7 @@ |
277 | expected = [ |
278 | backend_call( |
279 | client, 'bootstrap', ( |
280 | - '--constraints', 'mem=2G', 'foo/bar', 'foo', '--config', |
281 | + 'foo/bar', 'foo', '--config', |
282 | config_file.name, '--default-model', 'foo', |
283 | '--agent-version', client.version)), |
284 | ] + series_calls + [ |
285 | |
286 | === modified file 'tests/test_deploy_stack.py' |
287 | --- tests/test_deploy_stack.py 2017-04-05 23:07:51 +0000 |
288 | +++ tests/test_deploy_stack.py 2017-04-06 14:39:27 +0000 |
289 | @@ -2342,8 +2342,8 @@ |
290 | upload_tools=False): |
291 | pass |
292 | assert_juju_call(self, cc_mock, client, ( |
293 | - 'path', '--show-log', 'bootstrap', '--constraints', |
294 | - 'mem=2G', 'paas/qux', 'bar', '--config', config_file.name, |
295 | + 'path', '--show-log', 'bootstrap', 'paas/qux', 'bar', |
296 | + '--config', config_file.name, |
297 | '--default-model', 'bar', '--agent-version', '1.23'), 0) |
298 | assert_juju_call(self, cc_mock, client, ( |
299 | 'path', '--show-log', 'list-controllers'), 1) |
300 | @@ -2381,8 +2381,8 @@ |
301 | None, keep_env=True, upload_tools=False): |
302 | pass |
303 | assert_juju_call(self, cc_mock, client, ( |
304 | - 'path', '--show-log', 'bootstrap', '--constraints', |
305 | - 'mem=2G', 'paas/qux', 'bar', '--config', config_file.name, |
306 | + 'path', '--show-log', 'bootstrap', 'paas/qux', |
307 | + 'bar', '--config', config_file.name, |
308 | '--default-model', 'bar', '--agent-version', '1.23'), 0) |
309 | assert_juju_call(self, cc_mock, client, ( |
310 | 'path', '--show-log', 'list-controllers'), 1) |
311 | @@ -2421,7 +2421,7 @@ |
312 | pass |
313 | assert_juju_call(self, cc_mock, client, ( |
314 | 'path', '--show-log', 'bootstrap', '--upload-tools', |
315 | - '--constraints', 'mem=2G', 'paas/qux', 'bar', '--config', |
316 | + 'paas/qux', 'bar', '--config', |
317 | config_file.name, '--default-model', 'bar'), 0) |
318 | |
319 | def test_upload_tools_non_jes(self): |
320 | @@ -2433,8 +2433,8 @@ |
321 | keep_env=False, upload_tools=True): |
322 | pass |
323 | assert_juju_call(self, cc_mock, client, ( |
324 | - 'path', '--show-log', 'bootstrap', '-e', 'bar', '--upload-tools', |
325 | - '--constraints', 'mem=2G'), 0) |
326 | + 'path', '--show-log', 'bootstrap', '-e', 'bar', |
327 | + '--upload-tools', '--constraints', 'mem=2G'), 0) |
328 | |
329 | def test_calls_update_env_2(self): |
330 | cc_mock = self.addContext(patch('subprocess.check_call')) |
331 | @@ -2452,7 +2452,7 @@ |
332 | client.env, 'bar', agent_url='url', agent_stream='devel', |
333 | series='wacky', bootstrap_host=None, region=None) |
334 | assert_juju_call(self, cc_mock, client, ( |
335 | - 'path', '--show-log', 'bootstrap', '--constraints', 'mem=2G', |
336 | + 'path', '--show-log', 'bootstrap', |
337 | 'paas/qux', 'bar', '--config', config_file.name, |
338 | '--default-model', 'bar', '--agent-version', '1.23', |
339 | '--bootstrap-series', 'wacky'), 0) |
340 | @@ -2616,9 +2616,9 @@ |
341 | pass |
342 | self.assertIs(ctx.exception, error) |
343 | assert_juju_call(self, cc_mock, client, ( |
344 | - 'path', '--show-log', 'bootstrap', '--constraints', |
345 | - 'mem=2G', 'paas/qux', 'bar', '--config', config_file.name, |
346 | - '--default-model', 'bar', '--agent-version', '1.23'), 0) |
347 | + 'path', '--show-log', 'bootstrap', 'paas/qux', 'bar', |
348 | + '--config', config_file.name, '--default-model', 'bar', |
349 | + '--agent-version', '1.23'), 0) |
350 | assert_juju_call(self, cc_mock, client, ( |
351 | 'path', '--show-log', 'list-controllers'), 1) |
352 | assert_juju_call(self, cc_mock, client, ( |
353 | |
354 | === modified file 'tests/test_industrial_test.py' |
355 | --- tests/test_industrial_test.py 2017-04-04 04:30:31 +0000 |
356 | +++ tests/test_industrial_test.py 2017-04-06 14:39:27 +0000 |
357 | @@ -1212,7 +1212,7 @@ |
358 | with patch('subprocess.Popen') as popen_mock: |
359 | self.assertEqual(boot_iter.next(), {'test_id': 'bootstrap'}) |
360 | assert_juju_call(self, popen_mock, client, ( |
361 | - 'juju', '--show-log', 'bootstrap', '--constraints', 'mem=2G', |
362 | + 'juju', '--show-log', 'bootstrap', |
363 | 'fake/regionx', 'steve', '--config', config_file.name, |
364 | '--default-model', 'steve', '--agent-version', '1.2')) |
365 | statuses = [ |
366 | @@ -1967,7 +1967,7 @@ |
367 | self.assertEqual({'test_id': 'prepare-upgrade-juju'}, |
368 | puj_iterator.next()) |
369 | assert_juju_call(self, po_mock, future_client, ( |
370 | - 'juju', '--show-log', 'bootstrap', '--constraints', 'mem=2G', |
371 | + 'juju', '--show-log', 'bootstrap', |
372 | 'fake/regionx', 'steve', '--config', config_file.name, |
373 | '--default-model', 'steve', '--agent-version', '2.0.0')) |
374 | po_mock.return_value.wait.return_value = 0 |
This is fine to merge, but you must also be prepare to revert. While mem=2G is being ignored by Juju 2 because it does not satisfy juju controller minimums, the value is still used in models. We may find some tests fail in some substrates because our tests do not set a minimum requirement.
If add_basic_ testing_ arguments( ) provided --constraints, could tune tests for substrates. This will be a requirement if you need to revert.