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
changes/93/680893/1
Feilong Wang 1 week ago
parent
commit
e59e3e070f

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

@@ -180,7 +180,7 @@ class Cluster(base.APIBase):
180 180
     fixed_subnet = wtypes.StringType(min_length=1, max_length=255)
181 181
     """The fixed subnet name to attach to the Cluster"""
182 182
 
183
-    floating_ip_enabled = wsme.wsattr(types.boolean, default=True)
183
+    floating_ip_enabled = wsme.wsattr(types.boolean)
184 184
     """Indicates whether created clusters should have a floating ip or not."""
185 185
 
186 186
     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):
510 510
 def add_fip_env_file(env_files, cluster_template, cluster):
511 511
     lb_fip_enabled = cluster.labels.get(
512 512
         "master_lb_floating_ip_enabled",
513
-        cluster_template.floating_ip_enabled
513
+        cluster.floating_ip_enabled
514 514
     )
515 515
     master_lb_fip_enabled = strutils.bool_from_string(lb_fip_enabled)
516 516
 

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

@@ -203,7 +203,7 @@ class TemplateDefinitionTestCase(base.TestCase):
203 203
         mock_cluster_template = mock.MagicMock(floating_ip_enabled=True,
204 204
                                                master_lb_enabled=True,
205 205
                                                labels={})
206
-        mock_cluster = mock.MagicMock(labels={})
206
+        mock_cluster = mock.MagicMock(floating_ip_enabled=True, labels={})
207 207
         env_files = []
208 208
         cmn_tdef.add_fip_env_file(env_files, mock_cluster_template,
209 209
                                   mock_cluster)
@@ -289,6 +289,28 @@ class TemplateDefinitionTestCase(base.TestCase):
289 289
             env_files
290 290
         )
291 291
 
292
+    def test_add_fip_env_lb_enable_lbfip_template_disable_cluster_enable(self):
293
+        mock_cluster_template = mock.MagicMock(
294
+            floating_ip_enabled=False,
295
+            master_lb_enabled=True,
296
+            labels={}
297
+        )
298
+        mock_cluster = mock.MagicMock(
299
+            floating_ip_enabled=True,
300
+            labels={})
301
+        env_files = []
302
+
303
+        cmn_tdef.add_fip_env_file(env_files, mock_cluster_template,
304
+                                  mock_cluster)
305
+
306
+        self.assertEqual(
307
+            [
308
+                cmn_tdef.COMMON_ENV_PATH + 'enable_floating_ip.yaml',
309
+                cmn_tdef.COMMON_ENV_PATH + 'enable_lb_floating_ip.yaml'
310
+            ],
311
+            env_files
312
+        )
313
+
292 314
     @mock.patch('magnum.drivers.common.driver.Driver.get_driver')
293 315
     def test_base_get_scale_params(self, mock_driver):
294 316
         mock_context = mock.MagicMock()

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

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

Loading…
Cancel
Save