Merge lp:~gnuoy/charms/trusty/percona-cluster/use-dc-stable into lp:~openstack-charmers-archive/charms/trusty/percona-cluster/trunk

Proposed by Liam Young
Status: Merged
Merged at revision: 61
Proposed branch: lp:~gnuoy/charms/trusty/percona-cluster/use-dc-stable
Merge into: lp:~openstack-charmers-archive/charms/trusty/percona-cluster/trunk
Diff against target: 96 lines (+29/-4)
2 files modified
hooks/charmhelpers/contrib/hahelpers/cluster.py (+25/-0)
hooks/percona_hooks.py (+4/-4)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/percona-cluster/use-dc-stable
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+261372@code.launchpad.net
To post a comment you must log in.
62. By Liam Young

Revert unconnected charmhelpers/contrib/database/mysql.py

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

charm_lint_check #5123 percona-cluster for gnuoy mp261372
    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/11648258/
Build: http://10.245.162.77:8080/job/charm_lint_check/5123/

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

charm_unit_test #4802 percona-cluster for gnuoy mp261372
    UNIT OK: passed

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

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

charm_amulet_test #4530 percona-cluster for gnuoy mp261372
    AMULET FAIL: amulet-test missing

AMULET Results (max last 2 lines):
INFO:root:Search string not found in makefile target commands.
ERROR:root:No make target was executed.

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

Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/hahelpers/cluster.py'
2--- hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-03-03 02:26:12 +0000
3+++ hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-06-08 12:21:34 +0000
4@@ -52,6 +52,8 @@
5 bool_from_string,
6 )
7
8+DC_RESOURCE_NAME = 'DC'
9+
10
11 class HAIncompleteConfig(Exception):
12 pass
13@@ -95,6 +97,27 @@
14 return False
15
16
17+def is_crm_dc():
18+ """
19+ Determine leadership by querying the pacemaker Designated Controller
20+ """
21+ cmd = ['crm', 'status']
22+ try:
23+ status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
24+ if not isinstance(status, six.text_type):
25+ status = six.text_type(status, "utf-8")
26+ except subprocess.CalledProcessError:
27+ return False
28+ current_dc = ''
29+ for line in status.split('\n'):
30+ if line.startswith('Current DC'):
31+ # Current DC: juju-lytrusty-machine-2 (168108163) - partition with quorum
32+ current_dc = line.split(':')[1].split()[0]
33+ if current_dc == get_unit_hostname():
34+ return True
35+ return False
36+
37+
38 @retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound)
39 def is_crm_leader(resource, retry=False):
40 """
41@@ -104,6 +127,8 @@
42 We allow this operation to be retried to avoid the possibility of getting a
43 false negative. See LP #1396246 for more info.
44 """
45+ if resource == DC_RESOURCE_NAME:
46+ return is_crm_dc()
47 cmd = ['crm', 'resource', 'show', resource]
48 try:
49 status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
50
51=== modified file 'hooks/percona_hooks.py'
52--- hooks/percona_hooks.py 2015-04-21 09:29:08 +0000
53+++ hooks/percona_hooks.py 2015-06-08 12:21:34 +0000
54@@ -56,6 +56,7 @@
55 PerconaClusterHelper,
56 )
57 from charmhelpers.contrib.hahelpers.cluster import (
58+ DC_RESOURCE_NAME,
59 peer_units,
60 oldest_peer,
61 eligible_leader,
62@@ -74,7 +75,6 @@
63
64 hooks = Hooks()
65
66-LEADER_RES = 'grp_percona_cluster'
67 RES_MONITOR_PARAMS = ('params user="sstuser" password="%(sstpass)s" '
68 'pid="/var/run/mysqld/mysqld.pid" '
69 'socket="/var/run/mysqld/mysqld.sock" '
70@@ -207,7 +207,7 @@
71 @hooks.hook('db-relation-changed')
72 @hooks.hook('db-admin-relation-changed')
73 def db_changed(relation_id=None, unit=None, admin=None):
74- if not eligible_leader(LEADER_RES):
75+ if not eligible_leader(DC_RESOURCE_NAME):
76 log('Service is peered, clearing db relation'
77 ' as this service unit is not the leader')
78 relation_clear(relation_id)
79@@ -269,7 +269,7 @@
80 # TODO: This could be a hook common between mysql and percona-cluster
81 @hooks.hook('shared-db-relation-changed')
82 def shared_db_changed(relation_id=None, unit=None):
83- if not eligible_leader(LEADER_RES):
84+ if not eligible_leader(DC_RESOURCE_NAME):
85 relation_clear(relation_id)
86 # Each unit needs to set the db information otherwise if the unit
87 # with the info dies the settings die with it Bug# 1355848
88@@ -437,7 +437,7 @@
89 @hooks.hook('ha-relation-changed')
90 def ha_relation_changed():
91 clustered = relation_get('clustered')
92- if (clustered and is_leader(LEADER_RES)):
93+ if (clustered and is_leader(DC_RESOURCE_NAME)):
94 log('Cluster configured, notifying other services')
95 # Tell all related services to start using the VIP
96 for r_id in relation_ids('shared-db'):

Subscribers

People subscribed via source and target branches

to status/vote changes: