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
=== modified file 'hooks/charmhelpers/contrib/hahelpers/cluster.py'
--- hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-03-03 02:26:12 +0000
+++ hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-06-08 12:21:34 +0000
@@ -52,6 +52,8 @@
52 bool_from_string,52 bool_from_string,
53)53)
5454
55DC_RESOURCE_NAME = 'DC'
56
5557
56class HAIncompleteConfig(Exception):58class HAIncompleteConfig(Exception):
57 pass59 pass
@@ -95,6 +97,27 @@
95 return False97 return False
9698
9799
100def is_crm_dc():
101 """
102 Determine leadership by querying the pacemaker Designated Controller
103 """
104 cmd = ['crm', 'status']
105 try:
106 status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
107 if not isinstance(status, six.text_type):
108 status = six.text_type(status, "utf-8")
109 except subprocess.CalledProcessError:
110 return False
111 current_dc = ''
112 for line in status.split('\n'):
113 if line.startswith('Current DC'):
114 # Current DC: juju-lytrusty-machine-2 (168108163) - partition with quorum
115 current_dc = line.split(':')[1].split()[0]
116 if current_dc == get_unit_hostname():
117 return True
118 return False
119
120
98@retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound)121@retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound)
99def is_crm_leader(resource, retry=False):122def is_crm_leader(resource, retry=False):
100 """123 """
@@ -104,6 +127,8 @@
104 We allow this operation to be retried to avoid the possibility of getting a127 We allow this operation to be retried to avoid the possibility of getting a
105 false negative. See LP #1396246 for more info.128 false negative. See LP #1396246 for more info.
106 """129 """
130 if resource == DC_RESOURCE_NAME:
131 return is_crm_dc()
107 cmd = ['crm', 'resource', 'show', resource]132 cmd = ['crm', 'resource', 'show', resource]
108 try:133 try:
109 status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)134 status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
110135
=== modified file 'hooks/percona_hooks.py'
--- hooks/percona_hooks.py 2015-04-21 09:29:08 +0000
+++ hooks/percona_hooks.py 2015-06-08 12:21:34 +0000
@@ -56,6 +56,7 @@
56 PerconaClusterHelper,56 PerconaClusterHelper,
57)57)
58from charmhelpers.contrib.hahelpers.cluster import (58from charmhelpers.contrib.hahelpers.cluster import (
59 DC_RESOURCE_NAME,
59 peer_units,60 peer_units,
60 oldest_peer,61 oldest_peer,
61 eligible_leader,62 eligible_leader,
@@ -74,7 +75,6 @@
7475
75hooks = Hooks()76hooks = Hooks()
7677
77LEADER_RES = 'grp_percona_cluster'
78RES_MONITOR_PARAMS = ('params user="sstuser" password="%(sstpass)s" '78RES_MONITOR_PARAMS = ('params user="sstuser" password="%(sstpass)s" '
79 'pid="/var/run/mysqld/mysqld.pid" '79 'pid="/var/run/mysqld/mysqld.pid" '
80 'socket="/var/run/mysqld/mysqld.sock" '80 'socket="/var/run/mysqld/mysqld.sock" '
@@ -207,7 +207,7 @@
207@hooks.hook('db-relation-changed')207@hooks.hook('db-relation-changed')
208@hooks.hook('db-admin-relation-changed')208@hooks.hook('db-admin-relation-changed')
209def db_changed(relation_id=None, unit=None, admin=None):209def db_changed(relation_id=None, unit=None, admin=None):
210 if not eligible_leader(LEADER_RES):210 if not eligible_leader(DC_RESOURCE_NAME):
211 log('Service is peered, clearing db relation'211 log('Service is peered, clearing db relation'
212 ' as this service unit is not the leader')212 ' as this service unit is not the leader')
213 relation_clear(relation_id)213 relation_clear(relation_id)
@@ -269,7 +269,7 @@
269# TODO: This could be a hook common between mysql and percona-cluster269# TODO: This could be a hook common between mysql and percona-cluster
270@hooks.hook('shared-db-relation-changed')270@hooks.hook('shared-db-relation-changed')
271def shared_db_changed(relation_id=None, unit=None):271def shared_db_changed(relation_id=None, unit=None):
272 if not eligible_leader(LEADER_RES):272 if not eligible_leader(DC_RESOURCE_NAME):
273 relation_clear(relation_id)273 relation_clear(relation_id)
274 # Each unit needs to set the db information otherwise if the unit274 # Each unit needs to set the db information otherwise if the unit
275 # with the info dies the settings die with it Bug# 1355848275 # with the info dies the settings die with it Bug# 1355848
@@ -437,7 +437,7 @@
437@hooks.hook('ha-relation-changed')437@hooks.hook('ha-relation-changed')
438def ha_relation_changed():438def ha_relation_changed():
439 clustered = relation_get('clustered')439 clustered = relation_get('clustered')
440 if (clustered and is_leader(LEADER_RES)):440 if (clustered and is_leader(DC_RESOURCE_NAME)):
441 log('Cluster configured, notifying other services')441 log('Cluster configured, notifying other services')
442 # Tell all related services to start using the VIP442 # Tell all related services to start using the VIP
443 for r_id in relation_ids('shared-db'):443 for r_id in relation_ids('shared-db'):

Subscribers

People subscribed via source and target branches

to status/vote changes: