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: Merged
Merged at revision: 113
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: 79 lines (+22/-19)
2 files modified
hooks/rabbit_utils.py (+5/-11)
hooks/rabbitmq_server_relations.py (+17/-8)
To merge this branch: bzr merge lp:~niedbalski/charms/trusty/rabbitmq-server/fix-lp-1489053
Reviewer Review Type Date Requested Status
Billy Olsen Approve
OpenStack Charmers Pending
Felipe Reyes Pending
Ryan Beisner Pending
Review via email: mp+269801@code.launchpad.net

This proposal supersedes a proposal from 2015-08-26.

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

Fixed the lint issue.

Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Thanks for fixing this Jorge.

review: Approve
Revision history for this message
Edward Hope-Morley (hopem) : Posted in a previous version of this proposal
Revision history for this message
Ryan Beisner (1chb1n) wrote : Posted in a previous version of this proposal

+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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

Fixed both comments, @beisner and @dosaboy.

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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_unit_test #8478 rabbitmq-server-next for niedbalski mp269801
    UNIT OK: passed

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

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

charm_lint_check #9174 rabbitmq-server-next for niedbalski mp269801
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

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/

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

charm_amulet_test #6183 rabbitmq-server-next for niedbalski mp269801
    AMULET OK: passed

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

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

Take note that the amulet results here are prone to representing false-passes, and should be ignored.

As discussed on irc, we will revisit this proposal after landing fixes for the critical bug 1486177, including refactored amulet tests.

Thanks for your patience, and for your work on this.

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

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

charm_unit_test #9295 rabbitmq-server-next for niedbalski mp269801
    UNIT OK: passed

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

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

charm_lint_check #10133 rabbitmq-server-next for niedbalski mp269801
    LINT OK: passed

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

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

charm_amulet_test #6470 rabbitmq-server-next for niedbalski mp269801
    AMULET FAIL: amulet-test failed

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

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

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

Looking through the amulet results, it seems that these tests are still somewhat racey. From what I can tell, it looks like there was a failure to cluster - but the code makes an assumption that the rabbit service is up at the time. That appears to be a separate issue outside of this particular merge proposal.

As an example, running the tests in sts-stack results in a successful pass for all tests as seen http://paste.ubuntu.com/12439865/ (note: just the latest results are shown).

Moving on to the code itself, the code itself looks good and brings the ipv4 and ipv6 paths into the same path, thus I'm happy to merge this.

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

Thanks Billy!

Preview Diff

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

Subscribers

People subscribed via source and target branches