Merge lp:~niedbalski/charms/trusty/rabbitmq-server/fix-lp-1489053 into lp:~openstack-charmers-archive/charms/trusty/rabbitmq-server/next

Proposed by Jorge Niedbalski
Status: Superseded
Proposed branch: lp:~niedbalski/charms/trusty/rabbitmq-server/fix-lp-1489053
Merge into: lp:~openstack-charmers-archive/charms/trusty/rabbitmq-server/next
Diff against target: 96 lines (+26/-20)
3 files modified
hooks/charmhelpers/contrib/network/ip.py (+5/-1)
hooks/rabbit_utils.py (+5/-11)
hooks/rabbitmq_server_relations.py (+16/-8)
To merge this branch: bzr merge lp:~niedbalski/charms/trusty/rabbitmq-server/fix-lp-1489053
Reviewer Review Type Date Requested Status
Ryan Beisner (community) Needs Fixing
Billy Olsen Approve
Felipe Reyes Approve
Review via email: mp+269261@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-01.

Description of the change

- Enforce the update of /etc/hosts file on both cases (now it's just enforced
  on ipv6) for fixing cases like LP: #1489053.

- Remove the socket.gethostname() on cluster_joined relation, this is incorrect
if the intention is to determine the remote unit ip address, instead
uses the charmhelpers.contrib.network.ip.get_hostname method that
makes all the resolution logic.

To post a comment you must log in.
Revision history for this message
Jorge Niedbalski (niedbalski) wrote :

This writes the /etc/hosts file and also makes the cluster relation properly.

https://gist.github.com/niedbalski/5d2ad08efd2af5938862

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

charm_lint_check #8762 rabbitmq-server-next for niedbalski mp269261
    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/12202004/
Build: http://10.245.162.77:8080/job/charm_lint_check/8762/

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

charm_unit_test #8093 rabbitmq-server-next for niedbalski mp269261
    UNIT OK: passed

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

Revision history for this message
Felipe Reyes (freyes) wrote :

Works as expected. Thanks @niedbalski.

 juju run --service rabbit 'cat /etc/hosts'
- MachineId: "10"
  Stderr: "Warning: Permanently added '10.0.3.234' (ECDSA) to the list of known hosts.\r\n"
  Stdout: |
    127.0.0.1 localhost

    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    10.0.3.194 freyes-lxc-machine-8
    10.0.3.204 freyes-lxc-machine-9
  UnitId: rabbit/2
- MachineId: "8"
  Stderr: "Warning: Permanently added '10.0.3.194' (ECDSA) to the list of known hosts.\r\n"
  Stdout: |
    127.0.0.1 localhost

    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    10.0.3.204 freyes-lxc-machine-9
    10.0.3.234 freyes-lxc-machine-10
  UnitId: rabbit/0
- MachineId: "9"
  Stderr: "Warning: Permanently added '10.0.3.204' (ECDSA) to the list of known hosts.\r\n"
  Stdout: |
    127.0.0.1 localhost

    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    10.0.3.194 freyes-lxc-machine-8
    10.0.3.234 freyes-lxc-machine-10
  UnitId: rabbit/1

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

charm_amulet_test #6039 rabbitmq-server-next for niedbalski mp269261
    AMULET OK: passed

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

Revision history for this message
Billy Olsen (billy-olsen) wrote :

I think this change makes sense, especially in the general sense (not just in the OpenStack specific use case). For the openstack deployment case, dns resolution needs to be available for other services to properly work - however it has been argued (and I tend to agree) that simply deploying a rabbitmq-server cluster should "just work".

There's a minor lint issue that needs to be resolved, but other than that I'm happy to land this in the /next branches.

review: Needs Fixing
Revision history for this message
Jorge Niedbalski (niedbalski) wrote :

Fixed the lint issue.

Revision history for this message
Billy Olsen (billy-olsen) wrote :

Thanks for fixing this Jorge.

review: Approve
Revision history for this message
Edward Hope-Morley (hopem) :
Revision history for this message
Ryan Beisner (1chb1n) wrote :

+1 to preserving at least the existing level of user feedback.

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

charm_lint_check #9164 rabbitmq-server-next for niedbalski mp269261
    LINT OK: passed

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

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

charm_unit_test #8469 rabbitmq-server-next for niedbalski mp269261
    UNIT OK: passed

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

Revision history for this message
Ryan Beisner (1chb1n) wrote :

Removal of this conditional:
83 - if config('prefer-ipv6') and rdata.get('hostname'):

Makes this:
hostname = rdata.get('hostname', None)

Throw error:
http://paste.ubuntu.com/12242485/

2015-09-01 01:24:22 INFO leader-settings-changed hostname = rdata.get('hostname', None)
2015-09-01 01:24:22 INFO leader-settings-changed AttributeError: 'NoneType' object has no attribute 'get'

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

charm_amulet_test #6179 rabbitmq-server-next for niedbalski mp269261
    AMULET OK: passed

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

Revision history for this message
Jorge Niedbalski (niedbalski) wrote :

Fixed both comments, @beisner and @dosaboy.

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

charm_unit_test #8476 rabbitmq-server-next for niedbalski mp269261
    UNIT OK: passed

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

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

charm_lint_check #9172 rabbitmq-server-next for niedbalski mp269261
    LINT OK: passed

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

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

charm_amulet_test #6181 rabbitmq-server-next for niedbalski mp269261
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 124
ERROR:root:Make target returned non-zero.

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

110. By Liam Young

[gnuoy,trivial] Charmhelper sync (+1'd by mojo)

111. By Liam Young

[thedac, r=gnuoy] Fix clustering race conditions for LP Bug#1486177

112. By Liam Young

[1chb1n, r=gnuoy] Refactor amulet tests, deprecate old tests

113. By Jorge Niedbalski

Rebased again

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/network/ip.py'
2--- hooks/charmhelpers/contrib/network/ip.py 2015-09-01 04:53:33 +0000
3+++ hooks/charmhelpers/contrib/network/ip.py 2015-09-01 19:52:23 +0000
4@@ -435,8 +435,12 @@
5
6 rev = dns.reversename.from_address(address)
7 result = ns_query(rev)
8+
9 if not result:
10- return None
11+ try:
12+ result = socket.gethostbyaddr(address)[0]
13+ except:
14+ return None
15 else:
16 result = address
17
18
19=== modified file 'hooks/rabbit_utils.py'
20--- hooks/rabbit_utils.py 2015-09-01 04:53:33 +0000
21+++ hooks/rabbit_utils.py 2015-09-01 19:52:23 +0000
22@@ -2,7 +2,6 @@
23 import pwd
24 import grp
25 import re
26-import socket
27 import sys
28 import subprocess
29 import glob
30@@ -270,18 +269,13 @@
31 address = relation_get('private-address',
32 rid=r_id, unit=unit)
33 if address is not None:
34- try:
35- node = get_hostname(address, fqdn=False)
36- except:
37+ node = get_hostname(address, fqdn=False)
38+ if node:
39+ available_nodes.append(node)
40+ else:
41 log('Cannot resolve hostname for {} '
42- 'using DNS servers'.format(address), level='WARNING')
43- log('Falling back to use socket.gethostname()',
44+ 'using DNS servers'.format(address),
45 level='WARNING')
46- # If the private-address is not resolvable using DNS
47- # then use the current hostname
48- node = socket.gethostname()
49-
50- available_nodes.append(node)
51
52 if len(available_nodes) == 0:
53 log('No nodes available to cluster with')
54
55=== modified file 'hooks/rabbitmq_server_relations.py'
56--- hooks/rabbitmq_server_relations.py 2015-09-01 04:53:33 +0000
57+++ hooks/rabbitmq_server_relations.py 2015-09-01 19:52:23 +0000
58@@ -272,11 +272,18 @@
59
60 @hooks.hook('cluster-relation-joined')
61 def cluster_joined(relation_id=None):
62+ relation_settings = {
63+ 'hostname': get_local_nodename(),
64+ }
65+
66 if config('prefer-ipv6'):
67- relation_settings = {'hostname': socket.gethostname(),
68- 'private-address': get_ipv6_addr()[0]}
69- relation_set(relation_id=relation_id,
70- relation_settings=relation_settings)
71+ relation_settings['private-address'] = get_ipv6_addr()[0]
72+ else:
73+ relation_settings['private-address'] = get_host_ip(
74+ unit_get('private-address'))
75+
76+ relation_set(relation_id=relation_id,
77+ relation_settings=relation_settings)
78
79 if is_relation_made('ha') and \
80 config('ha-vip-only') is False:
81@@ -316,10 +323,11 @@
82 return
83
84 rdata = relation_get()
85- if config('prefer-ipv6') and rdata.get('hostname'):
86- private_address = rdata['private-address']
87- hostname = rdata['hostname']
88- if hostname:
89+ if rdata:
90+ hostname = rdata.get('hostname', None)
91+ private_address = rdata.get('private-address', None)
92+
93+ if hostname and private_address:
94 rabbit.update_hosts_file({private_address: hostname})
95
96 # sync passwords

Subscribers

People subscribed via source and target branches