List servers having non-existent flavor returns 422 Unprocessable Entity instead of empty list

Bug #1102462 reported by Jay Pipes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Davanum Srinivas (DIMS)

Bug Description

Discovered running Tempest:

07:17:00 ======================================================================
07:17:00 ERROR: test_list_servers_by_non_existing_flavor (tempest.tests.compute.servers.test_list_servers_negative.ListServersNegativeTest)
07:17:00 ----------------------------------------------------------------------
07:17:00 Traceback (most recent call last):
07:17:00 File "/opt/stack/new/tempest/tempest/tests/compute/servers/test_list_servers_negative.py", line 121, in test_list_servers_by_non_existing_flavor
07:17:00 resp, body = self.client.list_servers(dict(flavor=non_existing_flavor))
07:17:00 File "/opt/stack/new/tempest/tempest/services/compute/json/servers_client.py", line 129, in list_servers
07:17:00 resp, body = self.get(url)
07:17:00 File "/opt/stack/new/tempest/tempest/common/rest_client.py", line 179, in get
07:17:00 return self.request('GET', url, headers, wait=wait)
07:17:00 File "/opt/stack/new/tempest/tempest/common/rest_client.py", line 308, in request
07:17:00 raise exceptions.TempestException(str(resp.status))
07:17:00 TempestException: An unknown exception occurred
07:17:00 Details: An unknown exception occurred
07:17:00 Details: 422
07:17:00 -------------------- >> begin captured logging << --------------------
07:17:00 tempest.common.rest_client: ERROR: Request URL: http://127.0.0.1:8774/v2/6ddb2f83e4ad4a0da7bf9e7a7f1df6da/servers?flavor=1234
07:17:00 tempest.common.rest_client: ERROR: Request Body: None
07:17:00 tempest.common.rest_client: ERROR: Response Headers: {'date': 'Mon, 21 Jan 2013 07:07:54 GMT', 'status': '422', 'content-length': '71', 'content-type': 'application/json; charset=UTF-8', 'x-compute-request-id': 'req-69a003d4-8e42-48eb-be45-c0280952912b'}
07:17:00 tempest.common.rest_client: ERROR: Response Body: {u'computeFault': {u'message': u'Flavor could not be found', u'code': 422}}
07:17:00 --------------------- >> end captured logging << ---------------------

The source of the issue is plain:

https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/servers.py#L542

compute_api.get_all() is raising FlavorNotFound if search_opts includes a non-existing flavor ID.

Since this is list operation, shouldn't the result of GET /servers that finds no matches be an empty list?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/20198

Changed in nova:
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/20198
Committed: http://github.com/openstack/nova/commit/656052036374086f785f02bf288d23af14ab2ab5
Submitter: Jenkins
Branch: master

commit 656052036374086f785f02bf288d23af14ab2ab5
Author: Davanum Srinivas <email address hidden>
Date: Mon Jan 21 19:36:20 2013 -0500

    List servers having non-existent flavor should return empty list

    When we catch the exception just return an empty list.

    Fixes LP# 1102462

    Change-Id: I730bd505c40fa76cb0ba687575e3c3882fee6254

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → grizzly-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-3 → 2013.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.