Merge lp:~james-page/charms/trusty/percona-cluster/1497527 into lp:~openstack-charmers-archive/charms/trusty/percona-cluster/next

Proposed by James Page
Status: Merged
Merged at revision: 75
Proposed branch: lp:~james-page/charms/trusty/percona-cluster/1497527
Merge into: lp:~openstack-charmers-archive/charms/trusty/percona-cluster/next
Diff against target: 56 lines (+22/-3)
1 file modified
hooks/percona_hooks.py (+22/-3)
To merge this branch: bzr merge lp:~james-page/charms/trusty/percona-cluster/1497527
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+271772@code.launchpad.net

Description of the change

This change ensures that for configurations using access-network, access is only granted to IP addresses within the access-network CIDR, avoiding race conditions where the db_host presented to remote units get switch to the local access-network IP address for the PXC unit, allowed_hosts containers all remote unit names, but access has not been granted for all remote units for access-network IP addresses.

The old behaviour would grant access for any presented address, and then upgrade the grants to the new IP address once the remote units changed the 'hostname' relation data.

To post a comment you must log in.
76. By James Page

Switch to using get_host_ip

77. By James Page

Tidy lint

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

charm_lint_check #10403 percona-cluster-next for james-page mp271772
    LINT OK: passed

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

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

charm_unit_test #9549 percona-cluster-next for james-page mp271772
    UNIT OK: passed

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

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

charm_amulet_test #6545 percona-cluster-next for james-page mp271772
    AMULET OK: passed

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

Revision history for this message
Liam Young (gnuoy) wrote :

Tested with one glance node and one percona node.

Juju deployment network: 172.16.0.0/24
OS Access Network: 10.10.0.0/24

http://paste.ubuntu.com/12513262/

LGTM

Revision history for this message
Edward Hope-Morley (hopem) wrote :

LGTM +1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/percona_hooks.py'
2--- hooks/percona_hooks.py 2015-09-11 22:42:14 +0000
3+++ hooks/percona_hooks.py 2015-09-21 07:57:49 +0000
4@@ -429,6 +429,9 @@
5 access_network = config('access-network')
6 db_helper = get_db_helper()
7
8+ peer_store_and_set(relation_id=relation_id,
9+ relation_settings={'access-network': access_network})
10+
11 singleset = set(['database', 'username', 'hostname'])
12 if singleset.issubset(settings):
13 # Process a single database configuration
14@@ -436,6 +439,15 @@
15 database = settings['database']
16 username = settings['username']
17
18+ normalized_address = get_host_ip(hostname)
19+ if access_network and not is_address_in_network(access_network,
20+ normalized_address):
21+ # NOTE: for configurations using access-network, only setup
22+ # database access if remote unit has presented a
23+ # hostname or ip address thats within the configured
24+ # network cidr
25+ return
26+
27 # NOTE: do this before querying access grants
28 password = configure_db_for_hosts(hostname, database, username,
29 db_helper)
30@@ -485,6 +497,16 @@
31 hostname = databases[db]['hostname']
32 username = databases[db]['username']
33
34+ normalized_address = get_host_ip(hostname)
35+ if (access_network and
36+ not is_address_in_network(access_network,
37+ normalized_address)):
38+ # NOTE: for configurations using access-network,
39+ # only setup database access if remote unit
40+ # has presented a hostname or ip address
41+ # thats within the configured network cidr
42+ return
43+
44 # NOTE: do this before querying access grants
45 password = configure_db_for_hosts(hostname, database, username,
46 db_helper)
47@@ -509,9 +531,6 @@
48 else:
49 log("No return data - not setting relation settings", level=DEBUG)
50
51- peer_store_and_set(relation_id=relation_id,
52- relation_settings={'access-network': access_network})
53-
54
55 @hooks.hook('ha-relation-joined')
56 def ha_relation_joined():

Subscribers

People subscribed via source and target branches