Merge lp:~seyeongkim/charms/trusty/cinder/lp1383801 into lp:~openstack-charmers-archive/charms/trusty/cinder/next

Proposed by Seyeong Kim
Status: Merged
Approved by: Billy Olsen
Approved revision: 113
Merged at revision: 119
Proposed branch: lp:~seyeongkim/charms/trusty/cinder/lp1383801
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder/next
Diff against target: 89 lines (+36/-4)
2 files modified
hooks/cinder_hooks.py (+4/-0)
unit_tests/test_cinder_hooks.py (+32/-4)
To merge this branch: bzr merge lp:~seyeongkim/charms/trusty/cinder/lp1383801
Reviewer Review Type Date Requested Status
Billy Olsen Approve
OpenStack Charmers Pending
Review via email: mp+266344@code.launchpad.net

This proposal supersedes a proposal from 2015-07-29.

Description of the change

add restarting cinder-volume service on config-changed hook

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #7127 cinder-next for xtrusia mp266176
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/7127/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #6622 cinder-next for xtrusia mp266176
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/6622/

Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Adding a service_restart will guarantee that the service gets restarted whenever juju feels the urge to run the config_changed hook, which at the minimum per documentation (https://jujucharms.com/docs/devel/authors-charm-hooks#config-changed) includes:

- after install
- after upgrade charm
- after an agent is restarted
- whenever a configuration value is changed

And not in the documentation but also:
- whenever an agent loses connection with the state server(s)
- whenever a juju backup is created
- whenever else juju feels like it should

The config-changed hook should be expected to be invoked frequently. As such, restarting the cinder service every time will be disruptive.

We may need to see if we can further isolate this scenario a bit -or- use the underlying framework to detect if the value has changed (there is _some_ support in charmhelpers code, but I've little and less experience using it - see charmhelpers/core/unitdata.py iirc).

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #7256 cinder-next for xtrusia mp266344
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/7256/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #6716 cinder-next for xtrusia mp266344
    UNIT FAIL: unit-test failed

UNIT Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full unit test output: http://paste.ubuntu.com/11963789/
Build: http://10.245.162.77:8080/job/charm_unit_test/6716/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #7257 cinder-next for xtrusia mp266344
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/11964374/
Build: http://10.245.162.77:8080/job/charm_lint_check/7257/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #6717 cinder-next for xtrusia mp266344
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/6717/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #7262 cinder-next for xtrusia mp266344
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/7262/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #6722 cinder-next for xtrusia mp266344
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/6722/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #5497 cinder-next for xtrusia mp266344
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11965539/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5497/

Revision history for this message
Billy Olsen (billy-olsen) wrote :

Thanks for the making the changes requested Seyeong. This looks much better and I'm happy to approve it once OSCI gets another vote on it.

Thanks!

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #7327 cinder-next for xtrusia mp266344
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/7327/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #6778 cinder-next for xtrusia mp266344
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/6778/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #5536 cinder-next for xtrusia mp266344
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5536/

Revision history for this message
Billy Olsen (billy-olsen) wrote :

LGTM, thanks Seyeong!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/cinder_hooks.py'
2--- hooks/cinder_hooks.py 2015-07-21 19:28:23 +0000
3+++ hooks/cinder_hooks.py 2015-07-30 07:50:42 +0000
4@@ -143,6 +143,10 @@
5 relation_set(relation_id=rid,
6 upgrade_nonce=uuid.uuid4())
7
8+ # overwrite config is not in conf file. so We can't use restart_on_change
9+ if config_value_changed('overwrite'):
10+ service_restart('cinder-volume')
11+
12 CONFIGS.write_all()
13 configure_https()
14 update_nrpe_config()
15
16=== modified file 'unit_tests/test_cinder_hooks.py'
17--- unit_tests/test_cinder_hooks.py 2015-07-22 19:16:31 +0000
18+++ unit_tests/test_cinder_hooks.py 2015-07-30 07:50:42 +0000
19@@ -147,7 +147,9 @@
20
21 @patch.object(hooks, 'configure_https')
22 @patch.object(hooks, 'git_install_requested')
23- def test_config_changed(self, git_requested, conf_https):
24+ @patch.object(hooks, 'config_value_changed')
25+ def test_config_changed(self, config_val_changed,
26+ git_requested, conf_https):
27 'It writes out all config'
28 git_requested.return_value = False
29 self.openstack_upgrade_available.return_value = False
30@@ -160,7 +162,9 @@
31
32 @patch.object(hooks, 'configure_https')
33 @patch.object(hooks, 'git_install_requested')
34- def test_config_changed_block_devices(self, git_requested, conf_https):
35+ @patch.object(hooks, 'config_value_changed')
36+ def test_config_changed_block_devices(self, config_val_changed,
37+ git_requested, conf_https):
38 'It writes out all config'
39 git_requested.return_value = False
40 self.openstack_upgrade_available.return_value = False
41@@ -178,7 +182,10 @@
42
43 @patch.object(hooks, 'configure_https')
44 @patch.object(hooks, 'git_install_requested')
45- def test_config_changed_uses_remove_missing_force(self, git_requested,
46+ @patch.object(hooks, 'config_value_changed')
47+ def test_config_changed_uses_remove_missing_force(self,
48+ config_val_changed,
49+ git_requested,
50 conf_https):
51 'It uses the remove-missing-force config option'
52 git_requested.return_value = False
53@@ -193,7 +200,9 @@
54
55 @patch.object(hooks, 'configure_https')
56 @patch.object(hooks, 'git_install_requested')
57- def test_config_changed_upgrade_available(self, git_requested, conf_https):
58+ @patch.object(hooks, 'config_value_changed')
59+ def test_config_changed_upgrade_available(self, config_val_changed,
60+ git_requested, conf_https):
61 'It writes out all config with an available OS upgrade'
62 git_requested.return_value = False
63 self.openstack_upgrade_available.return_value = True
64@@ -226,6 +235,25 @@
65 self.assertFalse(self.do_openstack_upgrade.called)
66 self.assertTrue(conf_https.called)
67
68+ @patch('charmhelpers.core.host.service')
69+ @patch.object(hooks, 'configure_https')
70+ @patch.object(hooks, 'git_install_requested')
71+ @patch.object(hooks, 'config_value_changed')
72+ def test_config_changed_overwrite_changed(self, config_val_changed,
73+ git_requested, conf_https,
74+ _services):
75+ 'It uses the overwrite config option'
76+ git_requested.return_value = False
77+ self.openstack_upgrade_available.return_value = False
78+ config_val_changed.return_value = True
79+ hooks.hooks.execute(['hooks/config-changed'])
80+ self.assertTrue(self.CONFIGS.write_all.called)
81+ self.assertTrue(conf_https.called)
82+ self.configure_lvm_storage.assert_called_with(['sdb'],
83+ 'cinder-volumes',
84+ False, False, False)
85+ self.service_restart.assert_called_with('cinder-volume')
86+
87 def test_db_changed(self):
88 'It writes out cinder.conf on db changed'
89 self.relation_get.return_value = 'cinder/0 cinder/1'

Subscribers

People subscribed via source and target branches