Fix experimental=True for view in microversion 2.5
A previous patch added experimental=True to hide task_state field for any API call that would return share fields, such as "create" and "get" calls if different than microversion "2.5" with experimental=True. Turns out the field task_state should be returned always if microversion is "2.5" or above because it relates to a change in DB, not only to the usage of Share Migration feature. This patch fixes it by removing experimental=True dependency to show task_state field. Closes-bug: #1497352 Change-Id: Ic07d63ebcfe25c1cfa3fac1e75e2e186fbcec25b
This commit is contained in:
parent
415e3f7322
commit
3085534f46
@ -100,7 +100,7 @@ class ViewBuilder(common.ViewBuilder):
|
||||
share_dict['source_cgsnapshot_member_id'] = share.get(
|
||||
'source_cgsnapshot_member_id')
|
||||
|
||||
@common.ViewBuilder.versioned_method("2.5", None, True)
|
||||
@common.ViewBuilder.versioned_method("2.5")
|
||||
def add_task_state_field(self, share_dict, share):
|
||||
share_dict['task_state'] = share.get('task_state')
|
||||
|
||||
|
@ -164,6 +164,9 @@ class ShareApiTest(test.TestCase):
|
||||
expected = self._get_expected_share_detailed_response(self.share)
|
||||
expected['share']['consistency_group_id'] = None
|
||||
expected['share']['source_cgsnapshot_member_id'] = None
|
||||
if (api_version.APIVersionRequest(microversion) >=
|
||||
api_version.APIVersionRequest('2.5')):
|
||||
expected['share']['task_state'] = None
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_share_create_with_valid_default_share_type(self):
|
||||
@ -457,6 +460,7 @@ class ShareApiTest(test.TestCase):
|
||||
expected['share']['consistency_group_id'] = None
|
||||
expected['share']['source_cgsnapshot_member_id'] = None
|
||||
expected['share']['share_type_name'] = None
|
||||
expected['share']['task_state'] = None
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_share_show_admin(self):
|
||||
@ -783,7 +787,7 @@ class ShareApiTest(test.TestCase):
|
||||
def test_share_list_detail_with_task_state(self):
|
||||
env = {'QUERY_STRING': 'name=Share+Test+Name'}
|
||||
req = fakes.HTTPRequest.blank('/shares/detail', environ=env,
|
||||
version="2.5", experimental=True)
|
||||
version="2.5")
|
||||
expected = self._list_detail_common_expected()
|
||||
expected['shares'][0]['consistency_group_id'] = None
|
||||
expected['shares'][0]['source_cgsnapshot_member_id'] = None
|
||||
|
@ -220,15 +220,8 @@ class SharesV2Client(shares_client.SharesClient):
|
||||
"""Get detailed list of shares w/o filters."""
|
||||
return self.list_shares(detailed=True, params=params, version=version)
|
||||
|
||||
def get_share(self, share_id, version=LATEST_MICROVERSION,
|
||||
experimental=False):
|
||||
headers = None
|
||||
extra_headers = False
|
||||
if experimental:
|
||||
headers = EXPERIMENTAL
|
||||
extra_headers = True
|
||||
resp, body = self.get("shares/%s" % share_id, version=version,
|
||||
headers=headers, extra_headers=extra_headers)
|
||||
def get_share(self, share_id, version=LATEST_MICROVERSION):
|
||||
resp, body = self.get("shares/%s" % share_id, version=version)
|
||||
self.expected_success(200, resp.status)
|
||||
return self._parse_resp(body)
|
||||
|
||||
@ -498,14 +491,15 @@ class SharesV2Client(shares_client.SharesClient):
|
||||
headers=EXPERIMENTAL, extra_headers=True,
|
||||
version=version)
|
||||
|
||||
def wait_for_migration_completed(self, share_id, dest_host):
|
||||
def wait_for_migration_completed(self, share_id, dest_host,
|
||||
version=LATEST_MICROVERSION):
|
||||
"""Waits for a share to migrate to a certain host."""
|
||||
share = self.get_share(share_id, "2.5", True)
|
||||
share = self.get_share(share_id, version=version)
|
||||
migration_timeout = CONF.share.migration_timeout
|
||||
start = int(time.time())
|
||||
while share['task_state'] != 'migration_success':
|
||||
time.sleep(self.build_interval)
|
||||
share = self.get_share(share_id, "2.5", True)
|
||||
share = self.get_share(share_id, version=version)
|
||||
if share['task_state'] == 'migration_success':
|
||||
return share
|
||||
elif share['task_state'] == 'migration_error':
|
||||
|
Loading…
Reference in New Issue
Block a user