Merge lp:~gnuoy/charms/trusty/nova-cloud-controller/next-lp-1353135 into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Liam Young
Status: Merged
Merged at revision: 98
Proposed branch: lp:~gnuoy/charms/trusty/nova-cloud-controller/next-lp-1353135
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 75 lines (+32/-1)
2 files modified
hooks/nova_cc_hooks.py (+9/-1)
unit_tests/test_nova_cc_hooks.py (+23/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/nova-cloud-controller/next-lp-1353135
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+232577@code.launchpad.net

Description of the change

Do not attempt db migration if the db service has passed back a list of units who have been granted access and the executing unit is not on the list

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/nova_cc_hooks.py'
2--- hooks/nova_cc_hooks.py 2014-07-31 15:34:23 +0000
3+++ hooks/nova_cc_hooks.py 2014-08-28 14:35:57 +0000
4@@ -15,6 +15,7 @@
5 charm_dir,
6 is_relation_made,
7 log,
8+ local_unit,
9 ERROR,
10 relation_get,
11 relation_ids,
12@@ -212,6 +213,13 @@
13 CONFIGS.write_all()
14
15 if eligible_leader(CLUSTER_RES):
16+ # Bugs 1353135 & 1187508. Dbs can appear to be ready before the units
17+ # acl entry has been added. So, if the db supports passing a list of
18+ # permitted units then check if we're in the list.
19+ allowed_units = relation_get('nova_allowed_units')
20+ if allowed_units and local_unit() not in allowed_units.split():
21+ log('Allowed_units list provided and this unit not present')
22+ return
23 migrate_database()
24 log('Triggering remote cloud-compute restarts.')
25 [compute_joined(rid=rid, remote_restart=True)
26@@ -549,7 +557,7 @@
27 )
28 vip_group.append(vip_key)
29
30- if len(vip_group) > 1:
31+ if len(vip_group) > 0:
32 relation_set(groups={'grp_nova_vips': ' '.join(vip_group)})
33
34 init_services = {
35
36=== modified file 'unit_tests/test_nova_cc_hooks.py'
37--- unit_tests/test_nova_cc_hooks.py 2014-07-29 14:42:08 +0000
38+++ unit_tests/test_nova_cc_hooks.py 2014-08-28 14:35:57 +0000
39@@ -34,6 +34,7 @@
40 'determine_ports',
41 'open_port',
42 'is_relation_made',
43+ 'local_unit',
44 'log',
45 'relation_get',
46 'relation_set',
47@@ -323,6 +324,28 @@
48 self.migrate_database.assert_called_with()
49
50 @patch.object(hooks, 'CONFIGS')
51+ def test_db_changed_allowed(self, configs):
52+ allowed_units = 'nova-cloud-controller/0 nova-cloud-controller/3'
53+ self.test_relation.set({
54+ 'nova_allowed_units': allowed_units,
55+ })
56+ self.local_unit.return_value = 'nova-cloud-controller/3'
57+ self._shared_db_test(configs)
58+ self.assertTrue(configs.write_all.called)
59+ self.migrate_database.assert_called_with()
60+
61+ @patch.object(hooks, 'CONFIGS')
62+ def test_db_changed_not_allowed(self, configs):
63+ allowed_units = 'nova-cloud-controller/0 nova-cloud-controller/3'
64+ self.test_relation.set({
65+ 'nova_allowed_units': allowed_units,
66+ })
67+ self.local_unit.return_value = 'nova-cloud-controller/1'
68+ self._shared_db_test(configs)
69+ self.assertTrue(configs.write_all.called)
70+ self.assertFalse(self.migrate_database.called)
71+
72+ @patch.object(hooks, 'CONFIGS')
73 def test_postgresql_db_changed(self, configs):
74 self._postgresql_db_test(configs)
75 self.assertTrue(configs.write_all.called)

Subscribers

People subscribed via source and target branches