Fix the failure to scale-down k8s cluster

Fix the failure to scale-down k8s cluster. We were getting this
failure because as part of scaling, Bay needs to be retrieved for
the respective k8s obj. But if the object passed is a Bay itself
we need not retrieve the Bay. At present even for Bay object the
code proceeds ahead to retrieve bay and cannot find bay_uuid
attribute. This patch fixes this problem.

We might need to backport this fix to stable/liberty as well.

Change-Id: I7ed03af8bdbb8647851751bb550d9529d96b5cb4
Closes-Bug: #1509439
This commit is contained in:
Vilobh Meshram
2015-10-23 11:34:16 -07:00
parent 7cadd64d23
commit f231a60942
2 changed files with 11 additions and 3 deletions

View File

@@ -82,8 +82,11 @@ class TestK8sAPI(base.TestCase):
context = 'context'
obj = getattr(objects, cls)({})
self.assertFalse(hasattr(obj, 'bay_uuid'))
obj.bay_uuid = 'bay-uuid'
if cls is not 'Bay':
self.assertFalse(hasattr(obj, 'bay_uuid'))
obj.bay_uuid = 'bay-uuid'
else:
obj = bay_obj
with patch(
'magnum.conductor.k8s_api.K8sAPI._create_temp_file_with_content',