summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijendar Komalla <vijendar.komalla@RACKSPACE.COM>2017-02-15 11:06:27 -0600
committerVijendar Komalla <vijendar.komalla@RACKSPACE.COM>2017-02-15 13:44:12 -0600
commitee509ae323b2db469e663fcaef9647a3b111025d (patch)
tree66e255346f1888b38a7613ac64811cc5dcdeff3b
parente71dbd349248a4187be134e1118cff29fcd6121e (diff)
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
Notes
Notes (review): Code-Review+2: Adrian Otto <adrian.otto@rackspace.com> Code-Review+2: yatin <yatin.karel@nectechnologies.in> Workflow+1: yatin <yatin.karel@nectechnologies.in> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 16 Feb 2017 05:19:42 +0000 Reviewed-on: https://review.openstack.org/434403 Project: openstack/magnum Branch: refs/heads/master
-rw-r--r--magnum/api/controllers/v1/bay.py4
-rw-r--r--magnum/api/controllers/v1/cluster.py2
-rw-r--r--magnum/tests/unit/api/controllers/v1/test_cluster.py20
3 files changed, 23 insertions, 3 deletions
diff --git a/magnum/api/controllers/v1/bay.py b/magnum/api/controllers/v1/bay.py
index a8faecd..3466479 100644
--- a/magnum/api/controllers/v1/bay.py
+++ b/magnum/api/controllers/v1/bay.py
@@ -463,8 +463,8 @@ class BaysController(base.Controller):
463 463
464 @base.Controller.api_version("1.3") # noqa 464 @base.Controller.api_version("1.3") # noqa
465 @wsme.validate(types.uuid, bool, [BayPatchType]) 465 @wsme.validate(types.uuid, bool, [BayPatchType])
466 @expose.expose(BayID, types.uuid_or_name, bool, body=[BayPatchType], 466 @expose.expose(BayID, types.uuid_or_name, types.boolean,
467 status_code=202) 467 body=[BayPatchType], status_code=202)
468 def patch(self, bay_ident, rollback=False, patch=None): 468 def patch(self, bay_ident, rollback=False, patch=None):
469 """Update an existing bay. 469 """Update an existing bay.
470 470
diff --git a/magnum/api/controllers/v1/cluster.py b/magnum/api/controllers/v1/cluster.py
index e6ad47f..d36954c 100644
--- a/magnum/api/controllers/v1/cluster.py
+++ b/magnum/api/controllers/v1/cluster.py
@@ -435,7 +435,7 @@ class ClustersController(base.Controller):
435 435
436 @base.Controller.api_version("1.3") # noqa 436 @base.Controller.api_version("1.3") # noqa
437 @wsme.validate(types.uuid, bool, [ClusterPatchType]) 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 body=[ClusterPatchType], status_code=202) 439 body=[ClusterPatchType], status_code=202)
440 def patch(self, cluster_ident, rollback=False, patch=None): 440 def patch(self, cluster_ident, rollback=False, patch=None):
441 """Update an existing Cluster. 441 """Update an existing Cluster.
diff --git a/magnum/tests/unit/api/controllers/v1/test_cluster.py b/magnum/tests/unit/api/controllers/v1/test_cluster.py
index aab217d..a2cabac 100644
--- a/magnum/tests/unit/api/controllers/v1/test_cluster.py
+++ b/magnum/tests/unit/api/controllers/v1/test_cluster.py
@@ -412,6 +412,26 @@ class TestPatch(api_base.FunctionalTest):
412 self.assertEqual(400, response.status_int) 412 self.assertEqual(400, response.status_int)
413 self.assertTrue(response.json['errors']) 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 def test_remove_ok(self): 435 def test_remove_ok(self):
416 response = self.get_json('/clusters/%s' % self.cluster_obj.uuid) 436 response = self.get_json('/clusters/%s' % self.cluster_obj.uuid)
417 self.assertIsNotNone(response['name']) 437 self.assertIsNotNone(response['name'])