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):