Merge lp:~thedac/charm-helpers/expect-ha into lp:charm-helpers

Proposed by David Ames
Status: Merged
Merged at revision: 691
Proposed branch: lp:~thedac/charm-helpers/expect-ha
Merge into: lp:charm-helpers
Diff against target: 42 lines (+27/-0)
2 files modified
charmhelpers/contrib/openstack/ha/utils.py (+13/-0)
tests/contrib/openstack/ha/test_ha_utils.py (+14/-0)
To merge this branch: bzr merge lp:~thedac/charm-helpers/expect-ha
Reviewer Review Type Date Requested Status
Liam Young (community) Needs Fixing
Review via email: mp+317402@code.launchpad.net

Description of the change

expect_ha function checks for VIP or dns-ha settings

In OpenStack charms that relate to hacluster it may take time for
hacluster to complete. In the meantime the charm needs a way to be
informed to wait for hacluster. Simply checking for the relation is
too racey. This function checks for tell tale configuration
parameters. The charm can then react accordingly.

Partial-bug: #1661392

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

This fails lint and I think expect_ha could be simplified. I'll put up a mp based on this one so we can get the corresponding charm change landed asap

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/ha/utils.py'
2--- charmhelpers/contrib/openstack/ha/utils.py 2016-07-06 14:41:05 +0000
3+++ charmhelpers/contrib/openstack/ha/utils.py 2017-02-15 23:03:03 +0000
4@@ -126,3 +126,16 @@
5 status_set('blocked', msg)
6 raise DNSHAException(msg)
7 return True
8+
9+
10+def expect_ha():
11+ """ Determine if the unit expects to be in HA
12+
13+ Check for VIP or dns-ha settings which indicate the unit should expect to
14+ be related to hacluster.
15+
16+ @returns boolean
17+ """
18+ if config('vip') or config('dns-ha'):
19+ return True
20+ return False
21
22=== modified file 'tests/contrib/openstack/ha/test_ha_utils.py'
23--- tests/contrib/openstack/ha/test_ha_utils.py 2016-06-17 20:10:31 +0000
24+++ tests/contrib/openstack/ha/test_ha_utils.py 2017-02-15 23:03:03 +0000
25@@ -113,3 +113,17 @@
26 lsb_release.return_value = {'DISTRIB_RELEASE': '12.04'}
27 self.assertRaises(ha.DNSHAException,
28 lambda: ha.assert_charm_supports_dns_ha())
29+
30+ def tests_expect_ha(self):
31+ self.conf = {'vip': None,
32+ 'dns-ha': None }
33+ self.assertFalse(ha.expect_ha())
34+
35+ self.conf = {'vip': '10.0.0.1',
36+ 'dns-ha': None}
37+ self.assertTrue(ha.expect_ha())
38+
39+
40+ self.conf = {'vip': None,
41+ 'dns-ha': True}
42+ self.assertTrue(ha.expect_ha())

Subscribers

People subscribed via source and target branches