Merge lp:~james-page/charms/trusty/cinder/lp1521604 into lp:~openstack-charmers-archive/charms/trusty/cinder/next

Proposed by James Page on 2016-01-06
Status: Merged
Merged at revision: 140
Proposed branch: lp:~james-page/charms/trusty/cinder/lp1521604
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder/next
Diff against target: 98 lines (+44/-2)
4 files modified
hooks/cinder_hooks.py (+6/-2)
hooks/cinder_utils.py (+9/-0)
unit_tests/test_cinder_hooks.py (+8/-0)
unit_tests/test_cinder_utils.py (+21/-0)
To merge this branch: bzr merge lp:~james-page/charms/trusty/cinder/lp1521604
Reviewer Review Type Date Requested Status
Liam Young 2016-01-06 Approve on 2016-01-07
Review via email: mp+281799@code.launchpad.net

This proposal supersedes a proposal from 2016-01-06.

Description of the change

Drop requirement for identity service unless api service is enabled.

To post a comment you must log in.
141. By James Page on 2016-01-06

Also avoid overwrite of actual endpoint information for service instances where api service is not enabled

charm_lint_check #16668 cinder-next for james-page mp281799
    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/14424371/
Build: http://10.245.162.77:8080/job/charm_lint_check/16668/

charm_unit_test #15565 cinder-next for james-page mp281799
    UNIT OK: passed

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

charm_amulet_test #8544 cinder-next for james-page mp281799
    AMULET OK: passed

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

142. By James Page on 2016-01-07

Tidy lint

charm_lint_check #16726 cinder-next for james-page mp281799
    LINT OK: passed

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

charm_unit_test #15620 cinder-next for james-page mp281799
    UNIT OK: passed

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

charm_amulet_test #8551 cinder-next for james-page mp281799
    AMULET OK: passed

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

Liam Young (gnuoy) wrote :

LGTM, approved

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-10-08 14:28:50 +0000
3+++ hooks/cinder_hooks.py 2016-01-07 09:37:49 +0000
4@@ -27,7 +27,7 @@
5 setup_ipv6,
6 check_db_initialised,
7 filesystem_mounted,
8- REQUIRED_INTERFACES,
9+ required_interfaces,
10 check_optional_relations,
11 )
12
13@@ -270,6 +270,10 @@
14
15 @hooks.hook('identity-service-relation-joined')
16 def identity_joined(rid=None):
17+ if not service_enabled('api'):
18+ juju_log('api service not enabled; skipping endpoint registration')
19+ return
20+
21 public_url = '{}:{}/v1/$(tenant_id)s'.format(
22 canonical_url(CONFIGS, PUBLIC),
23 config('api-listening-port')
24@@ -553,5 +557,5 @@
25 hooks.execute(sys.argv)
26 except UnregisteredHookError as e:
27 juju_log('Unknown hook {} - skipping.'.format(e))
28- set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
29+ set_os_workload_status(CONFIGS, required_interfaces(),
30 charm_func=check_optional_relations)
31
32=== modified file 'hooks/cinder_utils.py'
33--- hooks/cinder_utils.py 2015-10-08 14:28:50 +0000
34+++ hooks/cinder_utils.py 2016-01-07 09:37:49 +0000
35@@ -168,6 +168,15 @@
36 }
37
38
39+def required_interfaces():
40+ '''Provide the required charm interfaces based on configured roles.'''
41+ _interfaces = copy(REQUIRED_INTERFACES)
42+ if not service_enabled('api'):
43+ # drop requirement for identity interface
44+ _interfaces.pop('identity')
45+ return _interfaces
46+
47+
48 def ceph_config_file():
49 return CHARM_CEPH_CONF.format(service_name())
50
51
52=== modified file 'unit_tests/test_cinder_hooks.py'
53--- unit_tests/test_cinder_hooks.py 2015-10-29 04:46:01 +0000
54+++ unit_tests/test_cinder_hooks.py 2016-01-07 09:37:49 +0000
55@@ -485,6 +485,14 @@
56 }
57 self.relation_set.assert_called_with(**expected)
58
59+ def test_identity_service_joined_no_api(self):
60+ 'endpoint registration is skipped if api service is not enabled'
61+ self.config.side_effect = self.test_config.get
62+ self.service_enabled.return_value = False
63+ hooks.hooks.execute(['hooks/identity-service-relation-joined'])
64+ self.assertFalse(self.relation_set.called)
65+ self.service_enabled.assert_called_with('api')
66+
67 @patch.object(hooks, 'canonical_url')
68 def test_identity_service_joined_icehouse(self, _canonical_url):
69 'It properly requests unclustered endpoint via identity-service'
70
71=== modified file 'unit_tests/test_cinder_utils.py'
72--- unit_tests/test_cinder_utils.py 2015-10-01 13:38:52 +0000
73+++ unit_tests/test_cinder_utils.py 2016-01-07 09:37:49 +0000
74@@ -805,3 +805,24 @@
75 volume_group = "test"
76 cinder_utils.remove_lvm_volume_group(volume_group)
77 _check.assert_called_with(['vgremove', '--force', volume_group])
78+
79+ def test_required_interfaces_api(self):
80+ '''identity-service interface required for api service'''
81+ expected = {
82+ 'database': ['shared-db', 'pgsql-db'],
83+ 'messaging': ['amqp'],
84+ 'identity': ['identity-service'],
85+ }
86+ self.assertEqual(cinder_utils.required_interfaces(), expected)
87+
88+ def test_required_interfaces_no_api(self):
89+ '''
90+ identity-service interface not required for volume
91+ or scheduler service
92+ '''
93+ self.test_config.set('enabled-services', 'volume,scheduler')
94+ expected = {
95+ 'database': ['shared-db', 'pgsql-db'],
96+ 'messaging': ['amqp'],
97+ }
98+ self.assertEqual(cinder_utils.required_interfaces(), expected)

Subscribers

People subscribed via source and target branches