Return code for rebuild with non-existent image changed

Bug #963248 reported by David Kranz on 2012-03-23
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Eoghan Glynn

Bug Description

The tempest test

ERROR: Negative test: The server rebuild for a non existing server should not

recently broke because nova started returning 400 and it recently was returning 400.
Was this intentional?

Either the code or the test needs to be changed.

ERROR: Negative test: The server rebuild for a non existing server should not
Traceback (most recent call last):
  File "/cygdrive/c/source/tempest/tempest/tests/", line 158, in test_rebuild_nonexistant_server
  File "/cygdrive/c/source/tempest/tempest/services/nova/json/", line 217, in rebuild
  File "/cygdrive/c/source/tempest/tempest/common/", line 100, in post
    return self.request('POST', url, headers, body)
  File "/cygdrive/c/source/tempest/tempest/common/", line 136, in request
    raise exceptions.BadRequest(resp_body['badRequest']['message'])
BadRequest: Bad request
Details: Bad request
Details: Invalid imageRef provided.
-------------------- >> begin captured logging << --------------------
tempest.common.rest_client: ERROR: Request URL:
tempest.common.rest_client: ERROR: Request Body: {"rebuild": {"personality": [{"path": "/etc/rebuild.txt", "contents": "VGVzdCBzZXJ2ZXIgcmVidWlsZC4="}], "metadata": {"rebuild": "server"}, "name": "server36933620389", "imageRef": "346f4039-a81e-44e0-9223-4a3d13c907", "adminPass": "rebuild"}}
tempest.common.rest_client: ERROR: Response Headers: {'date': 'Fri, 23 Mar 2012 16:14:11 GMT', 'status': '400', 'content-length': '70', 'content-type': 'application/json; charset=UTF-8', 'x-compute-request-id': 'req-a582eee4-ec5c-483b-b97d-e1dd7deb70b7'}
tempest.common.rest_client: ERROR: Response Body: {u'badRequest': {u'message': u'Invalid imageRef provided.', u'code': 400}}
--------------------- >> end captured logging << ---------------------

Jay Pipes (jaypipes) wrote :

David, you wrote "recently broke because nova started returning 400 and it recently was returning 400." I think you meant to say that until recently Nova was returning something different than 400. What return code was Nova returning?

David Kranz (david-kranz) wrote :

Sorry about that. The test is expecting NotFound (404).

David Kranz (david-kranz) wrote :

If this bug is not fixed in essex real soon now it should be closed as invalid, effectively accepting the API change. The Tempest test, currently being skipped pending resolution, needs to be updated either way.

Eoghan Glynn (eglynn) on 2012-06-07
Changed in nova:
status: New → In Progress
Eoghan Glynn (eglynn) wrote :

I traced through the nova codepath mapping 404 to 400 on invalid image and this is clearly deliberate, see bug:

specifically the patch:

containing the change:

    +++ b/nova/api/openstack/compute/
  @@ -1081,6 +1081,9 @@ class Controller(wsgi.Controller):
           except exception.InstanceNotFound:
               msg = _("Instance could not be found")
               raise exc.HTTPNotFound(explanation=msg)
  + except exception.ImageNotFound as error:
  + msg = _("Cannot find image for rebuild")
  + raise exc.HTTPBadRequest(explanation=msg)

Given the obvious deliberateness here, I'm going the mark this bug as 'Won't Fix' ... instead the tempest test should be modified to reflect the *actual* semantics of the nova API.

Changed in nova:
assignee: nobody → Eoghan Glynn (eglynn)
status: In Progress → Invalid
David Kranz (david-kranz) wrote :

I am a bit confused here. Joe Gordon submitted a change that unskiped the tempest test and changed it to expect 400 instead of 404. But the test failed because nova is returning 404 now! Eoghan, was this change somehow reverted?

Eoghan Glynn (eglynn) wrote :

Bug #963248 refers to the response code when the image is not found ... this is still 400 (I just checked it).

Whereas tests the case where the server (as opposed to the image) is non-existent. In that case, 404 is returned (I don't think there was any change there).

So the confusion simply relates to the "wrong" entity being non-existent.

David Kranz (david-kranz) wrote :

There must have been a regression that was fixed in the interim.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers