From 0e58e267d1eb0acd55d943e0abd208bf41377285 Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Tue, 14 Apr 2020 15:37:49 +0000 Subject: [PATCH] Fix ServerAddressOutputMapping for private clusters Following changes were introduced in Train release: - Allow setting network, subnet and FIP when creating cluster (I11579ff6b83d133c71c2cbf49ee4b20996dfb918) - ng-7: Adapt parameter and output mappings (I45cf765977c7f5a92f28ae12c469b98435763163) The first change allowed setting cluster.floating_ip_enabled but the second change introduced ServerAddressOutputMapping conditional on cluster_template.floating_ip_enabled which leads to an edge case where if floating_ip_enabled is overriden to False when a cluster is created when it is True in the cluster_template scope, we see this error in the conductor logs: ValueError: Field `node_addresses[0]' cannot be None and the cluster remains forever stuck in CREATE_IN_PROGRESS status despite Heat reaching CREATE_COMPLETE. This commit addresses this issue by correctly referring to the cluster.floating_ip_enabled. Change-Id: Ic83f625178786d4750a66dd6dd6db35c05bc0272 Story: 2007550 Task: 39401 --- contrib/drivers/heat/dcos_centos_template_def.py | 2 +- magnum/drivers/heat/k8s_template_def.py | 2 +- magnum/drivers/heat/swarm_mode_template_def.py | 4 ++-- magnum/tests/unit/drivers/test_template_definition.py | 2 ++ ...outputmapping-for-private-clusters-73a874bb4827d568.yaml | 6 ++++++ 5 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix-serveraddressoutputmapping-for-private-clusters-73a874bb4827d568.yaml diff --git a/contrib/drivers/heat/dcos_centos_template_def.py b/contrib/drivers/heat/dcos_centos_template_def.py index 0c203d0525..d1e7ecd62c 100644 --- a/contrib/drivers/heat/dcos_centos_template_def.py +++ b/contrib/drivers/heat/dcos_centos_template_def.py @@ -28,7 +28,7 @@ class ServerAddressOutputMapping(template_def.OutputMapping): self.heat_output = self.public_ip_output_key def set_output(self, stack, cluster_template, cluster): - if not cluster_template.floating_ip_enabled: + if not cluster.floating_ip_enabled: self.heat_output = self.private_ip_output_key LOG.debug("Using heat_output: %s", self.heat_output) diff --git a/magnum/drivers/heat/k8s_template_def.py b/magnum/drivers/heat/k8s_template_def.py index 11d1454431..36985cccc7 100644 --- a/magnum/drivers/heat/k8s_template_def.py +++ b/magnum/drivers/heat/k8s_template_def.py @@ -65,7 +65,7 @@ class ServerAddressOutputMapping(template_def.NodeGroupOutputMapping): self.is_stack_param = False def set_output(self, stack, cluster_template, cluster): - if not cluster_template.floating_ip_enabled: + if not cluster.floating_ip_enabled: self.heat_output = self.private_ip_output_key LOG.debug("Using heat_output: %s", self.heat_output) diff --git a/magnum/drivers/heat/swarm_mode_template_def.py b/magnum/drivers/heat/swarm_mode_template_def.py index 04337229d6..9b466922de 100644 --- a/magnum/drivers/heat/swarm_mode_template_def.py +++ b/magnum/drivers/heat/swarm_mode_template_def.py @@ -57,7 +57,7 @@ class MasterAddressOutputMapping(ServerAddressOutputMapping): 'swarm_secondary_masters_private'] def set_output(self, stack, cluster_template, cluster): - if not cluster_template.floating_ip_enabled: + if not cluster.floating_ip_enabled: self.heat_output = self.private_ip_output_key LOG.debug("Using heat_output: %s", self.heat_output) @@ -76,7 +76,7 @@ class NodeAddressOutputMapping(ServerAddressOutputMapping): private_ip_output_key = 'swarm_nodes_private' def set_output(self, stack, cluster_template, cluster): - if not cluster_template.floating_ip_enabled: + if not cluster.floating_ip_enabled: self.heat_output = self.private_ip_output_key LOG.debug("Using heat_output: %s", self.heat_output) diff --git a/magnum/tests/unit/drivers/test_template_definition.py b/magnum/tests/unit/drivers/test_template_definition.py index cde62e70c1..2a4a4052c1 100644 --- a/magnum/tests/unit/drivers/test_template_definition.py +++ b/magnum/tests/unit/drivers/test_template_definition.py @@ -369,6 +369,7 @@ class BaseK8sTemplateDefinitionTestCase(base.TestCase): mock_stack.to_dict.return_value = {'outputs': outputs} mock_cluster_template = mock.MagicMock() mock_cluster_template.floating_ip_enabled = floating_ip_enabled + self.mock_cluster.floating_ip_enabled = floating_ip_enabled definition.update_outputs(mock_stack, mock_cluster_template, self.mock_cluster) @@ -1633,6 +1634,7 @@ class AtomicSwarmModeTemplateDefinitionTestCase(base.TestCase): mock_stack.to_dict.return_value = {'outputs': outputs} mock_cluster_template = mock.MagicMock() mock_cluster_template.floating_ip_enabled = floating_ip_enabled + self.mock_cluster.floating_ip_enabled = floating_ip_enabled definition.update_outputs(mock_stack, mock_cluster_template, self.mock_cluster) diff --git a/releasenotes/notes/fix-serveraddressoutputmapping-for-private-clusters-73a874bb4827d568.yaml b/releasenotes/notes/fix-serveraddressoutputmapping-for-private-clusters-73a874bb4827d568.yaml new file mode 100644 index 0000000000..2d7cf4fd17 --- /dev/null +++ b/releasenotes/notes/fix-serveraddressoutputmapping-for-private-clusters-73a874bb4827d568.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fix an issue with private clusters getting stuck in CREATE_IN_PROGRESS + status where floating_ip_enabled=True in the cluster template but this is + disabled when the cluster is created.