Browse Source

Remove cluster floating_ip_enabled default value

There shouldn't be a default value for floating_ip_enabled when creating
cluster. By default, when it's not set, the cluster's floating_ip_enabled
attribute should be set with the value of cluster template. It's fixed
by removing the default value from Magnum API.

Task: 36500
Story: 2006208

Change-Id: I4077783c6a19a413d534f77f287da587353df0af
tags/9.0.0.0rc1
Feilong Wang 8 months ago
parent
commit
e59e3e070f
4 changed files with 32 additions and 3 deletions
  1. +1
    -1
      magnum/api/controllers/v1/cluster.py
  2. +1
    -1
      magnum/drivers/heat/template_def.py
  3. +23
    -1
      magnum/tests/unit/drivers/test_template_definition.py
  4. +7
    -0
      releasenotes/notes/fix-cluster-floating-ip-enabled-default-value-4e24d4bf09fc08c8.yaml

+ 1
- 1
magnum/api/controllers/v1/cluster.py View File

@@ -180,7 +180,7 @@ class Cluster(base.APIBase):
fixed_subnet = wtypes.StringType(min_length=1, max_length=255)
"""The fixed subnet name to attach to the Cluster"""

floating_ip_enabled = wsme.wsattr(types.boolean, default=True)
floating_ip_enabled = wsme.wsattr(types.boolean)
"""Indicates whether created clusters should have a floating ip or not."""

def __init__(self, **kwargs):


+ 1
- 1
magnum/drivers/heat/template_def.py View File

@@ -510,7 +510,7 @@ def add_etcd_volume_env_file(env_files, cluster):
def add_fip_env_file(env_files, cluster_template, cluster):
lb_fip_enabled = cluster.labels.get(
"master_lb_floating_ip_enabled",
cluster_template.floating_ip_enabled
cluster.floating_ip_enabled
)
master_lb_fip_enabled = strutils.bool_from_string(lb_fip_enabled)



+ 23
- 1
magnum/tests/unit/drivers/test_template_definition.py View File

@@ -203,7 +203,7 @@ class TemplateDefinitionTestCase(base.TestCase):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=True,
master_lb_enabled=True,
labels={})
mock_cluster = mock.MagicMock(labels={})
mock_cluster = mock.MagicMock(floating_ip_enabled=True, labels={})
env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template,
mock_cluster)
@@ -289,6 +289,28 @@ class TemplateDefinitionTestCase(base.TestCase):
env_files
)

def test_add_fip_env_lb_enable_lbfip_template_disable_cluster_enable(self):
mock_cluster_template = mock.MagicMock(
floating_ip_enabled=False,
master_lb_enabled=True,
labels={}
)
mock_cluster = mock.MagicMock(
floating_ip_enabled=True,
labels={})
env_files = []

cmn_tdef.add_fip_env_file(env_files, mock_cluster_template,
mock_cluster)

self.assertEqual(
[
cmn_tdef.COMMON_ENV_PATH + 'enable_floating_ip.yaml',
cmn_tdef.COMMON_ENV_PATH + 'enable_lb_floating_ip.yaml'
],
env_files
)

@mock.patch('magnum.drivers.common.driver.Driver.get_driver')
def test_base_get_scale_params(self, mock_driver):
mock_context = mock.MagicMock()


+ 7
- 0
releasenotes/notes/fix-cluster-floating-ip-enabled-default-value-4e24d4bf09fc08c8.yaml View File

@@ -0,0 +1,7 @@
---
fixes:
- |
There shouldn't be a default value for floating_ip_enabled when creating
cluster. By default, when it's not set, the cluster's floating_ip_enabled
attribute should be set with the value of cluster template. It's fixed
by removing the default value from Magnum API.

Loading…
Cancel
Save