Fix az parameter handling which blocks the integration test

1.What is the problem:
If availability zone (az in short) does not exit in the volume creation
request, 400 bad request was given in current handling, this handling is
incorrect and will block the following integration test cases:
ostestr --regex tempest.api.volume.test_volumes_list
ostestr --regex tempest.api.volume.test_volumes_get

Refer to https://review.openstack.org/#/c/329300/

2.What's need to be fixed:
To fix the issue, volume creation should allow no az parameter in
the request, and select one default bottom pod to continue the volume
creation.

3.What is the purpose of this patch set:
To make the integration test being the gate test of each patch set after
The Tricircle integration test Jenkins job is configured in
https://review.openstack.org/#/c/329740/

Change-Id: I8ee1cd5741605fbb105e2f24258459516aa7c5c0
This commit is contained in:
XiongQiu 2016-06-01 16:34:12 +08:00
parent 59ad16c78b
commit f0f9a20dbe
3 changed files with 20 additions and 10 deletions

View File

@ -52,13 +52,10 @@ class VolumeController(rest.RestController):
pecan.abort(400, _('Volume not found in request body'))
return
if 'availability_zone' not in kw['volume']:
pecan.abort(400, _('Availability zone not set in request'))
return
az = kw['volume'].get('availability_zone', '')
pod, pod_az = az_ag.get_pod_by_az_tenant(
context,
az_name=kw['volume']['availability_zone'],
az_name=az,
tenant_id=self.tenant_id)
if not pod:
pecan.abort(500, _('Pod not configured or scheduling failure'))

View File

@ -120,14 +120,27 @@ def get_pod_by_az_tenant(context, az_name, tenant_id):
pod = core.get_resource(context,
models.Pod,
pod_b['pod_id'])
if pod['az_name'] == az_name:
if az_name and pod['az_name'] == az_name:
return pod, pod['pod_az_name']
elif az_name == '' and pod['az_name'] != '':
# if the az_name is not specified, a defult bottom
# pod will be selected
return pod, pod['pod_az_name']
else:
pass
# TODO(joehuang): schedule one dynamically in the future
filters = [{'key': 'az_name', 'comparator': 'eq', 'value': az_name}]
if az_name != '':
filters = [{'key': 'az_name', 'comparator': 'eq', 'value': az_name}]
else:
filters = None
# if az_name is valid, select a pod under this az_name
# if az_name is '', select the first valid bottom pod.
# change to dynamic schedluing in the future
pods = db_api.list_pods(context, filters=filters)
for pod in pods:
if pod['pod_name'] != '':
if pod['pod_name'] != '' and pod['az_name'] != '':
try:
with context.session.begin():
core.create_resource(

View File

@ -255,7 +255,7 @@ class TestVolumeController(CinderVolumeFunctionalTest):
"project_id": 'my_tenant_id',
"metadata": {}
},
"expected_error": 400
"expected_error": 202
},
# incorrect AZ parameter
@ -575,7 +575,7 @@ class TestVolumeController(CinderVolumeFunctionalTest):
elif test_vol.get('volume_xxx'):
response = self.app.post_json(
'/v2/' + tenant_id + '/volumes',
dict(volume=test_vol['volume_xxx']),
dict(volume_xxx=test_vol['volume_xxx']),
expect_errors=True)
else:
return