From 3bee16780883f51d8218ee769aa587b10eac768d Mon Sep 17 00:00:00 2001 From: Zhang Hua Date: Wed, 5 Jul 2017 16:58:00 +0800 Subject: [PATCH] my_ip should belong to internal-network rather than data-network When defining os-data-network=10.10.1.0/24, os-internal-network=10.12.1.0/24 and not defining os-data-space, private-address of nova-compute units will be in 10.10.1.0/24 because now 10.10.1.0/24 and 10.12.1.0/24 are all in internal-network. nova-cloud-controller units can't collect public keys of nova-compute units because they don't have NIC belonged to 10.10.1.0/24. This will lead to some problems when resizing/migrating VM. This problem can be fixed by defining os-internal-space for cloud-compute because at this time private-address of nova-compute units will be in 10.12.1.0/24. bindings: cloud-compute: *os-internal-space However, the nova-compute charm has an os-internal-network option, this should also be referenced as a way to do this since not everybody uses spaces. This patch is used to deliver this point, then we can fix this problem by running the following command: juju config nova-compute os-internal-network='10.12.1.0/24' Change-Id: I70b096fd709e5ec8d8a47d2d11f71ed3ea780c5d Closes-Bug: 1686882 --- hooks/nova_compute_context.py | 3 ++- hooks/nova_compute_hooks.py | 3 ++- unit_tests/test_nova_compute_contexts.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 528740d8..209f2c7f 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -630,7 +630,8 @@ class HostIPContext(context.OSContextGenerator): ctxt = {} # Use the address used in the cloud-compute relation in templates for # this host - host_ip = get_relation_ip('cloud-compute') + host_ip = get_relation_ip('cloud-compute', + cidr_network=config('os-internal-network')) if host_ip: # NOTE: do not format this even for ipv6 (see bug 1499656) diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index 01a8cd05..f7de45a2 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -316,7 +316,8 @@ def compute_joined(rid=None): # add the hostname configured locally to the relation. settings = { 'hostname': gethostname(), - 'private-address': get_relation_ip('cloud-compute'), + 'private-address': get_relation_ip( + 'cloud-compute', cidr_network=config('os-internal-network')), } if migration_enabled(): diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index 31dae263..7844f651 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -432,7 +432,8 @@ class NovaComputeContextTests(CharmTestCase): self.get_relation_ip.return_value = '172.24.0.79' host_ip = context.HostIPContext() self.assertEqual({'host_ip': '172.24.0.79'}, host_ip()) - self.get_relation_ip.assert_called_with('cloud-compute') + self.get_relation_ip.assert_called_with('cloud-compute', + cidr_network=None) @patch('subprocess.call') def test_host_IP_context_ipv6(self, _call):