Merge lp:~thedac/charms/trusty/nova-compute/workload-status into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
- Trusty Tahr (14.04)
- workload-status
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 163 |
Proposed branch: | lp:~thedac/charms/trusty/nova-compute/workload-status |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-compute/next |
Diff against target: |
411 lines (+135/-3) 5 files modified
hooks/charmhelpers/contrib/openstack/templating.py (+2/-1) hooks/charmhelpers/contrib/openstack/utils.py (+55/-1) hooks/nova_compute_hooks.py (+47/-0) hooks/nova_compute_utils.py (+28/-1) unit_tests/test_utils.py (+3/-0) |
To merge this branch: | bzr merge lp:~thedac/charms/trusty/nova-compute/workload-status |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Liam Young (community) | Approve | ||
Review via email: mp+272496@code.launchpad.net |
Commit message
Description of the change
Workload Status
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9962 nova-compute-next for thedac mp272496
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6789 nova-compute-next for thedac mp272496
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 124
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
- 163. By David Ames
-
Check for neutron plugin relation
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #10970 nova-compute-next for thedac mp272496
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10185 nova-compute-next for thedac mp272496
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6864 nova-compute-next for thedac mp272496
AMULET OK: passed
Build: http://
- 164. By David Ames
-
Database is optional for nova-compute. Fix decorator ordering
Preview Diff
1 | === modified file 'hooks/charmhelpers/contrib/openstack/templating.py' |
2 | --- hooks/charmhelpers/contrib/openstack/templating.py 2015-09-17 11:20:02 +0000 |
3 | +++ hooks/charmhelpers/contrib/openstack/templating.py 2015-09-29 15:14:47 +0000 |
4 | @@ -18,7 +18,7 @@ |
5 | |
6 | import six |
7 | |
8 | -from charmhelpers.fetch import apt_install |
9 | +from charmhelpers.fetch import apt_install, apt_update |
10 | from charmhelpers.core.hookenv import ( |
11 | log, |
12 | ERROR, |
13 | @@ -29,6 +29,7 @@ |
14 | try: |
15 | from jinja2 import FileSystemLoader, ChoiceLoader, Environment, exceptions |
16 | except ImportError: |
17 | + apt_update(fatal=True) |
18 | apt_install('python-jinja2', fatal=True) |
19 | from jinja2 import FileSystemLoader, ChoiceLoader, Environment, exceptions |
20 | |
21 | |
22 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' |
23 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-28 07:56:16 +0000 |
24 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-09-29 15:14:47 +0000 |
25 | @@ -25,6 +25,7 @@ |
26 | import re |
27 | |
28 | import six |
29 | +import traceback |
30 | import yaml |
31 | |
32 | from charmhelpers.contrib.network import ip |
33 | @@ -34,6 +35,8 @@ |
34 | ) |
35 | |
36 | from charmhelpers.core.hookenv import ( |
37 | + action_fail, |
38 | + action_set, |
39 | config, |
40 | log as juju_log, |
41 | charm_dir, |
42 | @@ -51,7 +54,8 @@ |
43 | ) |
44 | |
45 | from charmhelpers.contrib.network.ip import ( |
46 | - get_ipv6_addr |
47 | + get_ipv6_addr, |
48 | + is_ipv6, |
49 | ) |
50 | |
51 | from charmhelpers.contrib.python.packages import ( |
52 | @@ -516,6 +520,12 @@ |
53 | relation_prefix=None): |
54 | hosts = get_ipv6_addr(dynamic_only=False) |
55 | |
56 | + if config('vip'): |
57 | + vips = config('vip').split() |
58 | + for vip in vips: |
59 | + if vip and is_ipv6(vip): |
60 | + hosts.append(vip) |
61 | + |
62 | kwargs = {'database': database, |
63 | 'username': database_user, |
64 | 'hostname': json.dumps(hosts)} |
65 | @@ -921,3 +931,47 @@ |
66 | for i in incomplete_relations: |
67 | incomplete_context_data[i] = configs.get_incomplete_context_data(required_interfaces[i]) |
68 | return incomplete_context_data |
69 | + |
70 | + |
71 | +def do_action_openstack_upgrade(package, upgrade_callback, configs): |
72 | + """Perform action-managed OpenStack upgrade. |
73 | + |
74 | + Upgrades packages to the configured openstack-origin version and sets |
75 | + the corresponding action status as a result. |
76 | + |
77 | + If the charm was installed from source we cannot upgrade it. |
78 | + For backwards compatibility a config flag (action-managed-upgrade) must |
79 | + be set for this code to run, otherwise a full service level upgrade will |
80 | + fire on config-changed. |
81 | + |
82 | + @param package: package name for determining if upgrade available |
83 | + @param upgrade_callback: function callback to charm's upgrade function |
84 | + @param configs: templating object derived from OSConfigRenderer class |
85 | + |
86 | + @return: True if upgrade successful; False if upgrade failed or skipped |
87 | + """ |
88 | + ret = False |
89 | + |
90 | + if git_install_requested(): |
91 | + action_set({'outcome': 'installed from source, skipped upgrade.'}) |
92 | + else: |
93 | + if openstack_upgrade_available(package): |
94 | + if config('action-managed-upgrade'): |
95 | + juju_log('Upgrading OpenStack release') |
96 | + |
97 | + try: |
98 | + upgrade_callback(configs=configs) |
99 | + action_set({'outcome': 'success, upgrade completed.'}) |
100 | + ret = True |
101 | + except: |
102 | + action_set({'outcome': 'upgrade failed, see traceback.'}) |
103 | + action_set({'traceback': traceback.format_exc()}) |
104 | + action_fail('do_openstack_upgrade resulted in an ' |
105 | + 'unexpected error') |
106 | + else: |
107 | + action_set({'outcome': 'action-managed-upgrade config is ' |
108 | + 'False, skipped upgrade.'}) |
109 | + else: |
110 | + action_set({'outcome': 'no upgrade available.'}) |
111 | + |
112 | + return ret |
113 | |
114 | === modified file 'hooks/nova_compute_hooks.py' |
115 | --- hooks/nova_compute_hooks.py 2015-09-22 13:53:11 +0000 |
116 | +++ hooks/nova_compute_hooks.py 2015-09-29 15:14:47 +0000 |
117 | @@ -13,6 +13,7 @@ |
118 | service_name, |
119 | unit_get, |
120 | UnregisteredHookError, |
121 | + status_set, |
122 | ) |
123 | from charmhelpers.core.host import ( |
124 | restart_on_change, |
125 | @@ -32,6 +33,7 @@ |
126 | git_install_requested, |
127 | openstack_upgrade_available, |
128 | os_requires_version, |
129 | + os_workload_status, |
130 | ) |
131 | |
132 | from charmhelpers.contrib.storage.linux.ceph import ( |
133 | @@ -66,6 +68,8 @@ |
134 | assert_charm_supports_ipv6, |
135 | manage_ovs, |
136 | install_hugepages, |
137 | + REQUIRED_INTERFACES, |
138 | + check_optional_relations, |
139 | ) |
140 | |
141 | from charmhelpers.contrib.network.ip import ( |
142 | @@ -86,28 +90,38 @@ |
143 | |
144 | |
145 | @hooks.hook('install.real') |
146 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
147 | + charm_func=check_optional_relations) |
148 | def install(): |
149 | + status_set('maintenance', 'Executing pre-install') |
150 | execd_preinstall() |
151 | configure_installation_source(config('openstack-origin')) |
152 | |
153 | + status_set('maintenance', 'Installing apt packages') |
154 | apt_update() |
155 | apt_install(determine_packages(), fatal=True) |
156 | |
157 | + status_set('maintenance', 'Git install') |
158 | git_install(config('openstack-origin-git')) |
159 | |
160 | |
161 | @hooks.hook('config-changed') |
162 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
163 | + charm_func=check_optional_relations) |
164 | @restart_on_change(restart_map()) |
165 | def config_changed(): |
166 | if config('prefer-ipv6'): |
167 | + status_set('maintenance', 'configuring ipv6') |
168 | assert_charm_supports_ipv6() |
169 | |
170 | global CONFIGS |
171 | if git_install_requested(): |
172 | if config_value_changed('openstack-origin-git'): |
173 | + status_set('maintenance', 'Running Git install') |
174 | git_install(config('openstack-origin-git')) |
175 | else: |
176 | if openstack_upgrade_available('nova-common'): |
177 | + status_set('maintenance', 'Running openstack upgrade') |
178 | CONFIGS = do_openstack_upgrade() |
179 | |
180 | sysctl_dict = config('sysctl') |
181 | @@ -117,11 +131,13 @@ |
182 | if migration_enabled() and config('migration-auth-type') == 'ssh': |
183 | # Check-in with nova-c-c and register new ssh key, if it has just been |
184 | # generated. |
185 | + status_set('maintenance', 'SSH key exchange') |
186 | initialize_ssh_keys() |
187 | import_authorized_keys() |
188 | |
189 | if config('enable-resize') is True: |
190 | enable_shell(user='nova') |
191 | + status_set('maintenance', 'SSH key exchange') |
192 | initialize_ssh_keys(user='nova') |
193 | import_authorized_keys(user='nova', prefix='nova') |
194 | else: |
195 | @@ -132,6 +148,7 @@ |
196 | fix_path_ownership(fp, user='nova') |
197 | |
198 | if config('virt-type').lower() == 'lxd': |
199 | + status_set('maintenance', 'Configure LXD') |
200 | configure_lxd(user='nova') |
201 | |
202 | [compute_joined(rid) for rid in relation_ids('cloud-compute')] |
203 | @@ -148,6 +165,8 @@ |
204 | |
205 | |
206 | @hooks.hook('amqp-relation-joined') |
207 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
208 | + charm_func=check_optional_relations) |
209 | def amqp_joined(relation_id=None): |
210 | relation_set(relation_id=relation_id, |
211 | username=config('rabbit-user'), |
212 | @@ -156,6 +175,8 @@ |
213 | |
214 | @hooks.hook('amqp-relation-changed') |
215 | @hooks.hook('amqp-relation-departed') |
216 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
217 | + charm_func=check_optional_relations) |
218 | @restart_on_change(restart_map()) |
219 | def amqp_changed(): |
220 | if 'amqp' not in CONFIGS.complete_contexts(): |
221 | @@ -171,6 +192,8 @@ |
222 | |
223 | |
224 | @hooks.hook('shared-db-relation-joined') |
225 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
226 | + charm_func=check_optional_relations) |
227 | def db_joined(rid=None): |
228 | if is_relation_made('pgsql-db'): |
229 | # error, postgresql is used |
230 | @@ -186,6 +209,8 @@ |
231 | |
232 | |
233 | @hooks.hook('pgsql-db-relation-joined') |
234 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
235 | + charm_func=check_optional_relations) |
236 | def pgsql_db_joined(): |
237 | if is_relation_made('shared-db'): |
238 | # raise error |
239 | @@ -198,6 +223,8 @@ |
240 | |
241 | |
242 | @hooks.hook('shared-db-relation-changed') |
243 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
244 | + charm_func=check_optional_relations) |
245 | @restart_on_change(restart_map()) |
246 | def db_changed(): |
247 | if 'shared-db' not in CONFIGS.complete_contexts(): |
248 | @@ -207,6 +234,8 @@ |
249 | |
250 | |
251 | @hooks.hook('pgsql-db-relation-changed') |
252 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
253 | + charm_func=check_optional_relations) |
254 | @restart_on_change(restart_map()) |
255 | def postgresql_db_changed(): |
256 | if 'pgsql-db' not in CONFIGS.complete_contexts(): |
257 | @@ -216,6 +245,8 @@ |
258 | |
259 | |
260 | @hooks.hook('image-service-relation-changed') |
261 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
262 | + charm_func=check_optional_relations) |
263 | @restart_on_change(restart_map()) |
264 | def image_service_changed(): |
265 | if 'image-service' not in CONFIGS.complete_contexts(): |
266 | @@ -257,8 +288,11 @@ |
267 | |
268 | |
269 | @hooks.hook('ceph-relation-joined') |
270 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
271 | + charm_func=check_optional_relations) |
272 | @restart_on_change(restart_map()) |
273 | def ceph_joined(): |
274 | + status_set('maintenance', 'Installing apt packages') |
275 | apt_install(filter_installed_packages(['ceph-common']), fatal=True) |
276 | # Bug 1427660 |
277 | service_restart('libvirt-bin') |
278 | @@ -272,6 +306,8 @@ |
279 | |
280 | |
281 | @hooks.hook('ceph-relation-changed') |
282 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
283 | + charm_func=check_optional_relations) |
284 | @restart_on_change(restart_map()) |
285 | def ceph_changed(): |
286 | if 'ceph' not in CONFIGS.complete_contexts(): |
287 | @@ -306,6 +342,8 @@ |
288 | |
289 | |
290 | @hooks.hook('ceph-relation-broken') |
291 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
292 | + charm_func=check_optional_relations) |
293 | def ceph_broken(): |
294 | service = service_name() |
295 | delete_keyring(service=service) |
296 | @@ -316,6 +354,8 @@ |
297 | 'image-service-relation-broken', |
298 | 'shared-db-relation-broken', |
299 | 'pgsql-db-relation-broken') |
300 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
301 | + charm_func=check_optional_relations) |
302 | @restart_on_change(restart_map()) |
303 | def relation_broken(): |
304 | CONFIGS.write_all() |
305 | @@ -324,6 +364,7 @@ |
306 | @hooks.hook('upgrade-charm') |
307 | def upgrade_charm(): |
308 | # NOTE: ensure psutil install for hugepages configuration |
309 | + status_set('maintenance', 'Installing apt packages') |
310 | apt_install(filter_installed_packages(['python-psutil'])) |
311 | for r_id in relation_ids('amqp'): |
312 | amqp_joined(relation_id=r_id) |
313 | @@ -339,6 +380,8 @@ |
314 | |
315 | |
316 | @hooks.hook('zeromq-configuration-relation-joined') |
317 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
318 | + charm_func=check_optional_relations) |
319 | @os_requires_version('kilo', 'nova-common') |
320 | def zeromq_configuration_relation_joined(relid=None): |
321 | relation_set(relation_id=relid, |
322 | @@ -347,6 +390,8 @@ |
323 | |
324 | |
325 | @hooks.hook('zeromq-configuration-relation-changed') |
326 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
327 | + charm_func=check_optional_relations) |
328 | @restart_on_change(restart_map()) |
329 | def zeromq_configuration_relation_changed(): |
330 | CONFIGS.write(NOVA_CONF) |
331 | @@ -365,6 +410,8 @@ |
332 | |
333 | |
334 | @hooks.hook('neutron-plugin-relation-changed') |
335 | +@os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
336 | + charm_func=check_optional_relations) |
337 | @restart_on_change(restart_map()) |
338 | def neutron_plugin_changed(): |
339 | settings = relation_get() |
340 | |
341 | === modified file 'hooks/nova_compute_utils.py' |
342 | --- hooks/nova_compute_utils.py 2015-09-17 11:21:15 +0000 |
343 | +++ hooks/nova_compute_utils.py 2015-09-29 15:14:47 +0000 |
344 | @@ -32,6 +32,7 @@ |
345 | relation_get, |
346 | DEBUG, |
347 | INFO, |
348 | + status_get, |
349 | ) |
350 | |
351 | from charmhelpers.core.templating import render |
352 | @@ -48,7 +49,8 @@ |
353 | git_src_dir, |
354 | git_pip_venv_dir, |
355 | git_yaml_value, |
356 | - os_release |
357 | + os_release, |
358 | + set_os_workload_status, |
359 | ) |
360 | |
361 | from charmhelpers.contrib.python.packages import ( |
362 | @@ -248,6 +250,13 @@ |
363 | 'lxc': 'lxc:///', |
364 | } |
365 | |
366 | +# The interface is said to be satisfied if anyone of the interfaces in the |
367 | +# list has a complete context. |
368 | +REQUIRED_INTERFACES = { |
369 | + 'message': ['amqp', 'zeromq-configuration'], |
370 | + 'image': ['image-service'], |
371 | +} |
372 | + |
373 | |
374 | def resource_map(): |
375 | ''' |
376 | @@ -829,3 +838,21 @@ |
377 | ) |
378 | subprocess.check_call('/etc/init.d/qemu-hugefsdir') |
379 | subprocess.check_call(['update-rc.d', 'qemu-hugefsdir', 'defaults']) |
380 | + |
381 | + |
382 | +def check_optional_relations(configs): |
383 | + required_interfaces = {} |
384 | + if relation_ids('ceph'): |
385 | + required_interfaces['storage-backend'] = ['ceph'] |
386 | + |
387 | + if relation_ids('neutron-plugin'): |
388 | + required_interfaces['neutron-plugin'] = ['neutron-plugin'] |
389 | + |
390 | + if relation_ids('shared-db') or relation_ids('pgsql-db'): |
391 | + required_interfaces['database'] = ['shared-db', 'pgsql-db'] |
392 | + |
393 | + if required_interfaces: |
394 | + set_os_workload_status(configs, required_interfaces) |
395 | + return status_get() |
396 | + else: |
397 | + return 'unknown', 'No optional relations' |
398 | |
399 | === modified file 'unit_tests/test_utils.py' |
400 | --- unit_tests/test_utils.py 2013-11-17 21:47:29 +0000 |
401 | +++ unit_tests/test_utils.py 2015-09-29 15:14:47 +0000 |
402 | @@ -6,6 +6,9 @@ |
403 | from contextlib import contextmanager |
404 | from mock import patch, MagicMock |
405 | |
406 | +patch('charmhelpers.contrib.openstack.utils.set_os_workload_status').start() |
407 | +patch('charmhelpers.core.hookenv.status_set').start() |
408 | + |
409 | |
410 | def load_config(): |
411 | ''' |
charm_lint_check #10785 nova-compute-next for thedac mp272496
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/10785/