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
This commit is contained in:
Vijendar Komalla 2017-02-15 11:06:27 -06:00
parent e71dbd3492
commit ee509ae323
3 changed files with 23 additions and 3 deletions

View File

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

View File

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

View File

@ -412,6 +412,26 @@ class TestPatch(api_base.FunctionalTest):
self.assertEqual(400, response.status_int)
self.assertTrue(response.json['errors'])
def test_update_cluster_with_rollback_enabled(self):
response = self.patch_json(
'/clusters/%s/?rollback=True' % self.cluster_obj.uuid,
[{'path': '/node_count', 'value': 4,
'op': 'replace'}],
headers={'OpenStack-API-Version': 'container-infra 1.3'})
self.mock_cluster_update.assert_called_once_with(mock.ANY, True)
self.assertEqual(202, response.status_code)
def test_update_cluster_with_rollback_disabled(self):
response = self.patch_json(
'/clusters/%s/?rollback=False' % self.cluster_obj.uuid,
[{'path': '/node_count', 'value': 4,
'op': 'replace'}],
headers={'OpenStack-API-Version': 'container-infra 1.3'})
self.mock_cluster_update.assert_called_once_with(mock.ANY, False)
self.assertEqual(202, response.status_code)
def test_remove_ok(self):
response = self.get_json('/clusters/%s' % self.cluster_obj.uuid)
self.assertIsNotNone(response['name'])