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
=== modified file 'hooks/charmhelpers/contrib/network/ip.py'
--- hooks/charmhelpers/contrib/network/ip.py 2015-09-01 04:53:33 +0000
+++ hooks/charmhelpers/contrib/network/ip.py 2015-09-01 19:52:23 +0000
@@ -435,8 +435,12 @@
435435
436 rev = dns.reversename.from_address(address)436 rev = dns.reversename.from_address(address)
437 result = ns_query(rev)437 result = ns_query(rev)
438
438 if not result:439 if not result:
439 return None440 try:
441 result = socket.gethostbyaddr(address)[0]
442 except:
443 return None
440 else:444 else:
441 result = address445 result = address
442446
443447
=== modified file 'hooks/rabbit_utils.py'
--- hooks/rabbit_utils.py 2015-09-01 04:53:33 +0000
+++ hooks/rabbit_utils.py 2015-09-01 19:52:23 +0000
@@ -2,7 +2,6 @@
2import pwd2import pwd
3import grp3import grp
4import re4import re
5import socket
6import sys5import sys
7import subprocess6import subprocess
8import glob7import glob
@@ -270,18 +269,13 @@
270 address = relation_get('private-address',269 address = relation_get('private-address',
271 rid=r_id, unit=unit)270 rid=r_id, unit=unit)
272 if address is not None:271 if address is not None:
273 try:272 node = get_hostname(address, fqdn=False)
274 node = get_hostname(address, fqdn=False)273 if node:
275 except:274 available_nodes.append(node)
275 else:
276 log('Cannot resolve hostname for {} '276 log('Cannot resolve hostname for {} '
277 'using DNS servers'.format(address), level='WARNING')277 'using DNS servers'.format(address),
278 log('Falling back to use socket.gethostname()',
279 level='WARNING')278 level='WARNING')
280 # If the private-address is not resolvable using DNS
281 # then use the current hostname
282 node = socket.gethostname()
283
284 available_nodes.append(node)
285279
286 if len(available_nodes) == 0:280 if len(available_nodes) == 0:
287 log('No nodes available to cluster with')281 log('No nodes available to cluster with')
288282
=== modified file 'hooks/rabbitmq_server_relations.py'
--- hooks/rabbitmq_server_relations.py 2015-09-01 04:53:33 +0000
+++ hooks/rabbitmq_server_relations.py 2015-09-01 19:52:23 +0000
@@ -272,11 +272,18 @@
272272
273@hooks.hook('cluster-relation-joined')273@hooks.hook('cluster-relation-joined')
274def cluster_joined(relation_id=None):274def cluster_joined(relation_id=None):
275 relation_settings = {
276 'hostname': get_local_nodename(),
277 }
278
275 if config('prefer-ipv6'):279 if config('prefer-ipv6'):
276 relation_settings = {'hostname': socket.gethostname(),280 relation_settings['private-address'] = get_ipv6_addr()[0]
277 'private-address': get_ipv6_addr()[0]}281 else:
278 relation_set(relation_id=relation_id,282 relation_settings['private-address'] = get_host_ip(
279 relation_settings=relation_settings)283 unit_get('private-address'))
284
285 relation_set(relation_id=relation_id,
286 relation_settings=relation_settings)
280287
281 if is_relation_made('ha') and \288 if is_relation_made('ha') and \
282 config('ha-vip-only') is False:289 config('ha-vip-only') is False:
@@ -316,10 +323,11 @@
316 return323 return
317324
318 rdata = relation_get()325 rdata = relation_get()
319 if config('prefer-ipv6') and rdata.get('hostname'):326 if rdata:
320 private_address = rdata['private-address']327 hostname = rdata.get('hostname', None)
321 hostname = rdata['hostname']328 private_address = rdata.get('private-address', None)
322 if hostname:329
330 if hostname and private_address:
323 rabbit.update_hosts_file({private_address: hostname})331 rabbit.update_hosts_file({private_address: hostname})
324332
325 # sync passwords333 # sync passwords

Subscribers

People subscribed via source and target branches