Merge lp:~hopem/charms/trusty/percona-cluster/lp1512293 into lp:~openstack-charmers-archive/charms/trusty/percona-cluster/next

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 82
Proposed branch: lp:~hopem/charms/trusty/percona-cluster/lp1512293
Merge into: lp:~openstack-charmers-archive/charms/trusty/percona-cluster/next
Diff against target: 82 lines (+32/-24)
1 file modified
hooks/percona_hooks.py (+32/-24)
To merge this branch: bzr merge lp:~hopem/charms/trusty/percona-cluster/lp1512293
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
OpenStack Charmers Pending
Review via email: mp+277548@code.launchpad.net

This proposal supersedes a proposal from 2015-11-02.

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

See inline comment

review: Needs Fixing
Revision history for this message
Edward Hope-Morley (hopem) : Posted in a previous version of this proposal
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #12923 percona-cluster-next for hopem mp277548
    UNIT OK: passed

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

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

charm_lint_check #13862 percona-cluster-next for hopem mp277548
    LINT OK: passed

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

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

charm_amulet_test #7899 percona-cluster-next for hopem mp277548
    AMULET OK: passed

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

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

Approved.

review: Approve

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-10-29 12:30:18 +0000
3+++ hooks/percona_hooks.py 2015-11-16 10:19:07 +0000
4@@ -356,24 +356,38 @@
5
6
7 def get_db_host(client_hostname):
8+ """Get address of local database host.
9+
10+ If an access-network has been configured, expect selected address to be
11+ on that network. If none can be found, revert to primary address.
12+
13+ If vip(s) are configured, chooses first available.
14+ """
15 vips = config('vip').split() if config('vip') else []
16- client_ip = get_host_ip(client_hostname)
17 access_network = config('access-network')
18- if (access_network is not None and
19- is_address_in_network(access_network, client_ip)):
20- if is_clustered():
21- for vip in vips:
22- if is_address_in_network(access_network, vip):
23- return vip
24- else:
25- return get_address_in_network(access_network)
26- elif is_clustered():
27- return config('vip') # NOTE on private network
28- else:
29- if config('prefer-ipv6'):
30- return get_ipv6_addr(exc_list=vips)[0]
31- else:
32- return unit_get('private-address')
33+ if access_network:
34+ client_ip = get_host_ip(client_hostname)
35+ if is_address_in_network(access_network, client_ip):
36+ if is_clustered():
37+ for vip in vips:
38+ if is_address_in_network(access_network, vip):
39+ return vip
40+
41+ log("Unable to identify a VIP in the access-network '%s'" %
42+ (access_network), level=WARNING)
43+ else:
44+ return get_address_in_network(access_network)
45+ else:
46+ log("Client address '%s' not in access-network '%s'" %
47+ (client_ip, access_network), level=WARNING)
48+
49+ if is_clustered() and vips:
50+ return vips[0] # NOTE on private network
51+
52+ if config('prefer-ipv6'):
53+ return get_ipv6_addr(exc_list=vips)[0]
54+
55+ return unit_get('private-address')
56
57
58 def configure_db_for_hosts(hosts, database, username, db_helper):
59@@ -420,14 +434,6 @@
60 return
61
62 settings = relation_get(unit=unit, rid=relation_id)
63- if is_clustered():
64- db_host = config('vip')
65- else:
66- if config('prefer-ipv6'):
67- db_host = get_ipv6_addr(exc_list=[config('vip')])[0]
68- else:
69- db_host = unit_get('private-address')
70-
71 access_network = config('access-network')
72 db_helper = get_db_helper()
73
74@@ -448,6 +454,8 @@
75 # database access if remote unit has presented a
76 # hostname or ip address thats within the configured
77 # network cidr
78+ log("Host '%s' not in access-network '%s' - ignoring" %
79+ (normalized_address, access_network), level=INFO)
80 return
81
82 # NOTE: do this before querying access grants

Subscribers

People subscribed via source and target branches