Merge lp:~jjo/charms/trusty/neutron-gateway/add-hostname-resolution-to-etc_hosts-lp1489598 into lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next

Proposed by JuanJo Ciarlante
Status: Rejected
Rejected by: James Page
Proposed branch: lp:~jjo/charms/trusty/neutron-gateway/add-hostname-resolution-to-etc_hosts-lp1489598
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next
Diff against target: 129 lines (+55/-0)
3 files modified
hooks/neutron_hooks.py (+2/-0)
hooks/neutron_utils.py (+50/-0)
unit_tests/test_neutron_hooks.py (+3/-0)
To merge this branch: bzr merge lp:~jjo/charms/trusty/neutron-gateway/add-hostname-resolution-to-etc_hosts-lp1489598
Reviewer Review Type Date Requested Status
Liam Young (community) Disapprove
Review via email: mp+269551@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #8940 neutron-gateway-next for jjo mp269551
    LINT OK: passed

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

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

charm_unit_test #8260 neutron-gateway-next for jjo mp269551
    UNIT FAIL: unit-test failed

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

Full unit test output: http://paste.ubuntu.com/12217794/
Build: http://10.245.162.77:8080/job/charm_unit_test/8260/

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

charm_lint_check #8941 neutron-gateway-next for jjo mp269551
    LINT OK: passed

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

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

charm_unit_test #8261 neutron-gateway-next for jjo mp269551
    UNIT FAIL: unit-test failed

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

Full unit test output: http://paste.ubuntu.com/12218049/
Build: http://10.245.162.77:8080/job/charm_unit_test/8261/

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

charm_amulet_test #6084 neutron-gateway-next for jjo mp269551
    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/12218226/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6084/

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

charm_lint_check #8942 neutron-gateway-next for jjo mp269551
    LINT OK: passed

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

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

charm_unit_test #8262 neutron-gateway-next for jjo mp269551
    UNIT OK: passed

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

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

charm_amulet_test #6086 neutron-gateway-next for jjo mp269551
    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/12218513/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6086/

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

charm_amulet_test #6085 neutron-gateway-next for jjo mp269551
    AMULET OK: passed

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

136. By JuanJo Ciarlante

[jjo] update /etc/hosts with own unit's hostname, fixes lp#1489598

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

charm_lint_check #9040 neutron-gateway-next for jjo mp269551
    LINT OK: passed

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

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

charm_unit_test #8353 neutron-gateway-next for jjo mp269551
    UNIT OK: passed

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

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

I'd rather not try and manage the host file in the charm. I'm inclined to agree with https://bugs.launchpad.net/charms/+source/neutron-gateway/+bug/1489598/comments/2 and this should be fixed elsewhere

review: Disapprove

Unmerged revisions

136. By JuanJo Ciarlante

[jjo] update /etc/hosts with own unit's hostname, fixes lp#1489598

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/neutron_hooks.py'
--- hooks/neutron_hooks.py 2015-05-07 09:27:07 +0000
+++ hooks/neutron_hooks.py 2015-08-30 01:44:37 +0000
@@ -64,6 +64,7 @@
64 reassign_agent_resources,64 reassign_agent_resources,
65 stop_neutron_ha_monitor_daemon,65 stop_neutron_ha_monitor_daemon,
66 use_l3ha,66 use_l3ha,
67 update_etc_hosts,
67)68)
6869
69hooks = Hooks()70hooks = Hooks()
@@ -107,6 +108,7 @@
107 do_openstack_upgrade()108 do_openstack_upgrade()
108 CONFIGS.write_all()109 CONFIGS.write_all()
109110
111 update_etc_hosts()
110 update_nrpe_config()112 update_nrpe_config()
111113
112 sysctl_dict = config('sysctl')114 sysctl_dict = config('sysctl')
113115
=== modified file 'hooks/neutron_utils.py'
--- hooks/neutron_utils.py 2015-07-09 11:02:45 +0000
+++ hooks/neutron_utils.py 2015-08-30 01:44:37 +0000
@@ -1,6 +1,8 @@
1import os1import os
2import shutil2import shutil
3import subprocess3import subprocess
4import tempfile
5import socket
4from shutil import copy26from shutil import copy2
5from charmhelpers.core.host import (7from charmhelpers.core.host import (
6 adduser,8 adduser,
@@ -23,6 +25,7 @@
23 relations_of_type,25 relations_of_type,
24 unit_private_ip,26 unit_private_ip,
25 is_relation_made,27 is_relation_made,
28 unit_get,
26)29)
27from charmhelpers.core.templating import render30from charmhelpers.core.templating import render
28from charmhelpers.fetch import (31from charmhelpers.fetch import (
@@ -220,6 +223,7 @@
220 'quantum-metadata-agent',223 'quantum-metadata-agent',
221 'quantum-plugin-openvswitch-agent',224 'quantum-plugin-openvswitch-agent',
222]225]
226HOSTS_FILE = '/etc/hosts'
223227
224228
225def get_early_packages():229def get_early_packages():
@@ -279,6 +283,52 @@
279def use_l3ha():283def use_l3ha():
280 return NeutronAPIContext()()['enable_l3ha']284 return NeutronAPIContext()()['enable_l3ha']
281285
286
287def update_etc_hosts():
288 hostname = socket.gethostname()
289 addr = unit_get('private-address')
290 hosts_map = {addr: hostname}
291 # only need to add myself to /etc/hosts
292 update_hosts_file(hosts_map)
293
294
295def update_hosts_file(map):
296 """neutron-gateway needs own hostname resolution to work properly,
297 see https://bugs.launchpad.net/charms/+source/neutron-gateway/+bug/1489598
298 """
299 with open(HOSTS_FILE, 'r') as hosts:
300 lines = hosts.readlines()
301
302 log("Updating %s with: %s (current: %s)" % (HOSTS_FILE, map, lines),
303 level=DEBUG)
304
305 newlines = []
306 for ip, hostname in map.items():
307 if not ip or not hostname:
308 continue
309
310 keepers = []
311 for line in lines:
312 _line = line.split()
313 if len(line) < 2 or not (_line[0] == ip or hostname in _line[1:]):
314 keepers.append(line)
315 else:
316 log("Marking line '%s' for update or removal" % (line.strip()),
317 level=DEBUG)
318
319 lines = keepers
320 newlines.append("%s %s\n" % (ip, hostname))
321
322 lines += newlines
323
324 with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
325 with open(tmpfile.name, 'w') as hosts:
326 for line in lines:
327 hosts.write(line)
328
329 os.rename(tmpfile.name, HOSTS_FILE)
330 os.chmod(HOSTS_FILE, 0o644)
331
282EXT_PORT_CONF = '/etc/init/ext-port.conf'332EXT_PORT_CONF = '/etc/init/ext-port.conf'
283PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf'333PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf'
284TEMPLATES = 'templates'334TEMPLATES = 'templates'
285335
=== modified file 'unit_tests/test_neutron_hooks.py'
--- unit_tests/test_neutron_hooks.py 2015-07-09 11:02:45 +0000
+++ unit_tests/test_neutron_hooks.py 2015-08-30 01:44:37 +0000
@@ -51,6 +51,7 @@
51 'cleanup_ovs_netns',51 'cleanup_ovs_netns',
52 'stop_neutron_ha_monitor_daemon',52 'stop_neutron_ha_monitor_daemon',
53 'use_l3ha',53 'use_l3ha',
54 'update_etc_hosts',
54]55]
5556
5657
@@ -157,6 +158,7 @@
157 self._call_hook('config-changed')158 self._call_hook('config-changed')
158 self.assertTrue(self.do_openstack_upgrade.called)159 self.assertTrue(self.do_openstack_upgrade.called)
159 self.assertTrue(self.configure_ovs.called)160 self.assertTrue(self.configure_ovs.called)
161 self.assertTrue(self.update_etc_hosts.called)
160 self.assertTrue(_db_joined.called)162 self.assertTrue(_db_joined.called)
161 self.assertTrue(_pgsql_db_joined.called)163 self.assertTrue(_pgsql_db_joined.called)
162 self.assertTrue(_amqp_joined.called)164 self.assertTrue(_amqp_joined.called)
@@ -172,6 +174,7 @@
172 self._call_hook('config-changed')174 self._call_hook('config-changed')
173 self.assertTrue(self.do_openstack_upgrade.called)175 self.assertTrue(self.do_openstack_upgrade.called)
174 self.assertTrue(self.configure_ovs.called)176 self.assertTrue(self.configure_ovs.called)
177 self.assertTrue(self.update_etc_hosts.called)
175178
176 @patch.object(hooks, 'git_install_requested')179 @patch.object(hooks, 'git_install_requested')
177 def test_config_changed_n1kv(self, git_requested):180 def test_config_changed_n1kv(self, git_requested):

Subscribers

People subscribed via source and target branches