Browse Source

Fix for cluster-update rollback issue

Currently cluster-update is rolling back in case of update
failure irrespective of whether the rollback flag set to
True or False. This change fixes the issue by setting the
right parameter type in cluster patch method.

Change-Id: I6c28c583e7e3b98622634ac2381513b442eb57b6
Closes-Bug: #1664781
Vijendar Komalla 2 years ago
parent
commit
ee509ae323

+ 2
- 2
magnum/api/controllers/v1/bay.py View File

@@ -463,8 +463,8 @@ class BaysController(base.Controller):
463 463
 
464 464
     @base.Controller.api_version("1.3")   # noqa
465 465
     @wsme.validate(types.uuid, bool, [BayPatchType])
466
-    @expose.expose(BayID, types.uuid_or_name, bool, body=[BayPatchType],
467
-                   status_code=202)
466
+    @expose.expose(BayID, types.uuid_or_name, types.boolean,
467
+                   body=[BayPatchType], status_code=202)
468 468
     def patch(self, bay_ident, rollback=False, patch=None):
469 469
         """Update an existing bay.
470 470
 

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

@@ -435,7 +435,7 @@ class ClustersController(base.Controller):
435 435
 
436 436
     @base.Controller.api_version("1.3")  # noqa
437 437
     @wsme.validate(types.uuid, bool, [ClusterPatchType])
438
-    @expose.expose(ClusterID, types.uuid_or_name, bool,
438
+    @expose.expose(ClusterID, types.uuid_or_name, types.boolean,
439 439
                    body=[ClusterPatchType], status_code=202)
440 440
     def patch(self, cluster_ident, rollback=False, patch=None):
441 441
         """Update an existing Cluster.

+ 20
- 0
magnum/tests/unit/api/controllers/v1/test_cluster.py View File

@@ -412,6 +412,26 @@ class TestPatch(api_base.FunctionalTest):
412 412
         self.assertEqual(400, response.status_int)
413 413
         self.assertTrue(response.json['errors'])
414 414
 
415
+    def test_update_cluster_with_rollback_enabled(self):
416
+        response = self.patch_json(
417
+            '/clusters/%s/?rollback=True' % self.cluster_obj.uuid,
418
+            [{'path': '/node_count', 'value': 4,
419
+              'op': 'replace'}],
420
+            headers={'OpenStack-API-Version': 'container-infra 1.3'})
421
+
422
+        self.mock_cluster_update.assert_called_once_with(mock.ANY, True)
423
+        self.assertEqual(202, response.status_code)
424
+
425
+    def test_update_cluster_with_rollback_disabled(self):
426
+        response = self.patch_json(
427
+            '/clusters/%s/?rollback=False' % self.cluster_obj.uuid,
428
+            [{'path': '/node_count', 'value': 4,
429
+              'op': 'replace'}],
430
+            headers={'OpenStack-API-Version': 'container-infra 1.3'})
431
+
432
+        self.mock_cluster_update.assert_called_once_with(mock.ANY, False)
433
+        self.assertEqual(202, response.status_code)
434
+
415 435
     def test_remove_ok(self):
416 436
         response = self.get_json('/clusters/%s' % self.cluster_obj.uuid)
417 437
         self.assertIsNotNone(response['name'])

Loading…
Cancel
Save