From 231a0f1459eb2a9273dc9b752f10ff184c0b7e35 Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Thu, 17 Jun 2021 13:42:48 -0700 Subject: [PATCH] Drop placement endpoints from relation in train+ When a cloud is deployed earlier than the Train release, the placement service is provided by nova-cloud-controller. As part of an upgrade to Train, the new placement service is added and updates the placement endpoint in the service catalog. The nova-cloud-controller charm no longer advertises the placement service URL, but because the data exists on the relation until removed, the service catalog changes the placement URL to the placement endpoints advertised from nova-cloud-controller. Fix this by explicitly removing the placement service URLs when the placement service is not provided by nova-cloud-controller. Change-Id: Ibb3b1429820a4188fe3d2c1142c295c0de4ee24e Closes-Bug: #1928992 --- hooks/nova_cc_utils.py | 11 +++++++++ unit_tests/test_nova_cc_utils.py | 39 +++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/hooks/nova_cc_utils.py b/hooks/nova_cc_utils.py index 481ddc7b..b7abfef6 100644 --- a/hooks/nova_cc_utils.py +++ b/hooks/nova_cc_utils.py @@ -1575,6 +1575,17 @@ def determine_endpoints(public_url, internal_url, admin_url): 'placement_admin_url': placement_admin_url, 'placement_internal_url': placement_internal_url, }) + else: + # NOTE(wolsen) drop placement endpoints when placement api is not + # enabled. This prevents the ncc charm from overriding services + # from placement in Train and newer. See LP#1928992 + endpoints.update({ + 'placement_service': None, + 'placement_region': None, + 'placement_public_url': None, + 'placement_admin_url': None, + 'placement_internal_url': None, + }) return endpoints diff --git a/unit_tests/test_nova_cc_utils.py b/unit_tests/test_nova_cc_utils.py index e1eff82b..08bb8ed0 100644 --- a/unit_tests/test_nova_cc_utils.py +++ b/unit_tests/test_nova_cc_utils.py @@ -96,7 +96,12 @@ BASE_ENDPOINTS = { 's3_internal_url': 'http://foohost.com:3333', 's3_public_url': 'http://foohost.com:3333', 's3_region': 'RegionOne', - 's3_service': 's3' + 's3_service': 's3', + 'placement_region': None, + 'placement_service': None, + 'placement_admin_url': None, + 'placement_internal_url': None, + 'placement_public_url': None, } QUEENS_ENDPOINTS = { @@ -122,6 +127,29 @@ QUEENS_ENDPOINTS = { 'placement_public_url': 'http://foohost.com:8778', } +TRAIN_ENDPOINTS = { + 'ec2_admin_url': None, + 'ec2_internal_url': None, + 'ec2_public_url': None, + 'ec2_region': None, + 'ec2_service': None, + 'nova_admin_url': 'http://foohost.com:8774/v2.1', + 'nova_internal_url': 'http://foohost.com:8774/v2.1', + 'nova_public_url': 'http://foohost.com:8774/v2.1', + 'nova_region': 'RegionOne', + 'nova_service': 'nova', + 's3_admin_url': None, + 's3_internal_url': None, + 's3_public_url': None, + 's3_region': None, + 's3_service': None, + 'placement_region': None, + 'placement_service': None, + 'placement_admin_url': None, + 'placement_internal_url': None, + 'placement_public_url': None, +} + # Restart map should be constructed such that API services restart # before frontends (haproxy/apache) to avoid port conflicts. RESTART_MAP_ICEHOUSE = OrderedDict([ @@ -840,6 +868,15 @@ class NovaCCUtilsTests(CharmTestCase): 'http://foohost.com', 'http://foohost.com')) + def test_determine_endpoints_train(self): + # Having placement related w/ train disables placement_api + self.relation_ids.return_value = ['placement:1'] + self.os_release.return_value = 'train' + self.assertEqual( + TRAIN_ENDPOINTS, utils.determine_endpoints('http://foohost.com', + 'http://foohost.com', + 'http://foohost.com')) + @patch.object(utils, 'known_hosts') @patch('subprocess.check_output') def test_ssh_known_host_key(self, _check_output, _known_hosts):