Merge lp:~thedac/charms/trusty/hacluster/workload-status into lp:~openstack-charmers/charms/trusty/hacluster/next

Proposed by David Ames on 2015-10-08
Status: Merged
Merged at revision: 58
Proposed branch: lp:~thedac/charms/trusty/hacluster/workload-status
Merge into: lp:~openstack-charmers/charms/trusty/hacluster/next
Diff against target: 151 lines (+45/-11)
2 files modified
hooks/hooks.py (+21/-1)
hooks/utils.py (+24/-10)
To merge this branch: bzr merge lp:~thedac/charms/trusty/hacluster/workload-status
Reviewer Review Type Date Requested Status
Corey Bryant 2015-10-08 Approve on 2015-10-08
Review via email: mp+273889@code.launchpad.net

Description of the Change

Workload Status

To post a comment you must log in.

charm_lint_check #11546 hacluster-next for thedac mp273889
    LINT OK: passed

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

charm_unit_test #10738 hacluster-next for thedac mp273889
    UNIT OK: passed

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

Corey Bryant (corey.bryant) wrote :

This looks good to me but I'm going to defer to someone with more hacluster expertise to take a look and land it.

review: Approve

charm_amulet_test #7247 hacluster-next for thedac mp273889
    AMULET OK: passed

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2015-06-03 12:18:49 +0000
3+++ hooks/hooks.py 2015-10-08 17:53:13 +0000
4@@ -22,6 +22,7 @@
5 Hooks,
6 UnregisteredHookError,
7 local_unit,
8+ status_set,
9 )
10
11 from charmhelpers.core.host import (
12@@ -84,6 +85,7 @@
13 def install():
14 # NOTE(dosaboy): we currently disallow upgrades due to bug #1382842. This
15 # should be removed once the pacemaker package is fixed.
16+ status_set('maintenance', 'Installing apt packages')
17 apt_install(filter_installed_packages(PACKAGES), fatal=True)
18 # NOTE(adam_g) rbd OCF only included with newer versions of
19 # ceph-resource-agents. Bundle /w charm until we figure out a
20@@ -99,6 +101,7 @@
21 if val not in ['udp', 'udpu']:
22 msg = ("Unsupported corosync_transport type '%s' - supported "
23 "types are: %s" % (transport, ', '.join(SUPPORTED_TRANSPORTS)))
24+ status_set('blocked', msg)
25 raise ValueError(msg)
26 return val
27
28@@ -122,7 +125,9 @@
29
30 corosync_key = config('corosync_key')
31 if not corosync_key:
32- raise Exception('No Corosync key supplied, cannot proceed')
33+ message = 'No Corosync key supplied, cannot proceed'
34+ status_set('blocked', message)
35+ raise Exception(message)
36
37 enable_lsb_services('pacemaker')
38
39@@ -130,6 +135,7 @@
40 for rid in relation_ids('hanode'):
41 ensure_ipv6_requirements(rid)
42
43+ status_set('maintenance', "Setting up corosync")
44 if configure_corosync():
45 pcmk.wait_for_pcmk()
46 configure_cluster_global()
47@@ -400,8 +406,22 @@
48 nrpe_setup.write()
49
50
51+def assess_status():
52+ '''Assess status of current unit'''
53+ node_count = int(config('cluster_count'))
54+ # not enough peers
55+ for relid in relation_ids('hanode'):
56+ if len(related_units(relid)) + 1 < node_count:
57+ status_set('blocked', 'Insufficient peer units for ha cluster '
58+ '(require {})'.format(node_count))
59+ return
60+
61+ status_set('active', 'Unit is ready and clustered')
62+
63+
64 if __name__ == '__main__':
65 try:
66 hooks.execute(sys.argv)
67 except UnregisteredHookError as e:
68 log('Unknown hook {} - skipping.'.format(e), level=DEBUG)
69+ assess_status()
70
71=== modified file 'hooks/utils.py'
72--- hooks/utils.py 2015-09-04 00:30:23 +0000
73+++ hooks/utils.py 2015-10-08 17:53:13 +0000
74@@ -21,6 +21,7 @@
75 relation_ids,
76 config,
77 unit_get,
78+ status_set,
79 )
80 from charmhelpers.contrib.openstack.utils import get_host_ip
81 from charmhelpers.core.host import (
82@@ -149,9 +150,13 @@
83 return str(IPNetwork(network).network)
84
85 except ValueError:
86- raise Exception("Invalid interface '%s'" % iface)
87+ msg = "Invalid interface '%s'" % iface
88+ status_set('blocked', msg)
89+ raise Exception(msg)
90
91- raise Exception("No valid network found for interface '%s'" % iface)
92+ msg = "No valid network found for interface '%s'" % iface
93+ status_set('blocked', msg)
94+ raise Exception(msg)
95
96
97 def get_corosync_id(unit_name):
98@@ -276,8 +281,10 @@
99 def assert_charm_supports_ipv6():
100 """Check whether we are able to support charms ipv6."""
101 if lsb_release()['DISTRIB_CODENAME'].lower() < "trusty":
102- raise Exception("IPv6 is not supported in the charms for Ubuntu "
103- "versions less than Trusty 14.04")
104+ msg = "IPv6 is not supported in the charms for Ubuntu " \
105+ "versions less than Trusty 14.04"
106+ status_set('blocked', msg)
107+ raise Exception(msg)
108
109
110 def get_transport():
111@@ -287,6 +294,7 @@
112 if val not in ['udp', 'udpu']:
113 msg = ("Unsupported corosync_transport type '%s' - supported "
114 "types are: %s" % (transport, ', '.join(SUPPORTED_TRANSPORTS)))
115+ status_set('blocked', msg)
116 raise ValueError(msg)
117
118 return val
119@@ -378,20 +386,26 @@
120 url = config('maas_url')
121 creds = config('maas_credentials')
122 if None in [url, creds]:
123- raise Exception('maas_url and maas_credentials must be set '
124- 'in config to enable STONITH.')
125+ msg = 'maas_url and maas_credentials must be set ' \
126+ 'in config to enable STONITH.'
127+ status_set('blocked', msg)
128+ raise Exception(msg)
129
130 nodes = maas.MAASHelper(url, creds).list_nodes()
131 if not nodes:
132- raise Exception('Could not obtain node inventory from '
133- 'MAAS @ %s.' % url)
134+ msg = 'Could not obtain node inventory from ' \
135+ 'MAAS @ %s.' % url
136+ status_set('blocked', msg)
137+ raise Exception(msg)
138
139 cluster_nodes = pcmk.list_nodes()
140 for node in cluster_nodes:
141 rsc, constraint = pcmk.maas_stonith_primitive(nodes, node)
142 if not rsc:
143- raise Exception('Failed to determine STONITH primitive for '
144- 'node %s' % node)
145+ msg = 'Failed to determine STONITH primitive for ' \
146+ 'node %s' % node
147+ status_set('blocked', msg)
148+ raise Exception(msg)
149
150 rsc_name = str(rsc).split(' ')[1]
151 if not pcmk.is_resource_present(rsc_name):

Subscribers

People subscribed via source and target branches

to all changes: