Bug 917293

Summary: [RFE] RFC2616 section 9.7 status code vs. nova server delete
Product: Red Hat OpenStack Reporter: Attila Fazekas <afazekas>
Component: openstack-novaAssignee: RHOS Maint <rhos-maint>
Status: CLOSED WONTFIX QA Contact: Ami Jeain <ajeain>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 2.1CC: ndipanov, sgordon, yeylon
Target Milestone: ---Keywords: Automation, FutureFeature, MoveUpstream, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-04 06:31:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Attila Fazekas 2013-03-02 18:44:38 UTC
In REST client implementation is common good practice, when:
- request causes an synchronous and asynchronous effect , and
- the synchronous operation has any immediately visible effect ie. immediate subsequent request showing any change,
we should emphasize the synchronous behavior in the responses (Status code)  (Or responding in way which does not distinguish the two cases).

However if the HTTP method is DELETE, the rule is the opposite! if the resource on the request URL not deleted it MUST NOT response with 204.

"
   A successful response SHOULD be 200 (OK) if the response includes an
   entity describing the status, 202 (Accepted) if the action has not
   yet been enacted, or 204 (No Content) if the action has been enacted
   but the response does not include an entity.
" by RFC2616 section 9.7

It means if the DELETE responded with 204, I MUST get 404 in an immediate subsequent request, unless concurrent operation recreated the resource.


$ nova --debug delete ab0ebda6-2c21-4258-8934-1005b970fee5 ; nova --debug show ab0ebda6-2c21-4258-8934-1005b970fee5

Part of the output in the received order:
-----------------------------------------
REQ: curl -i http://10.34.69.149:8774/v2/89a38fe6d3194864995ab0872905a65e/servers/ab0ebda6-2c21-4258-8934-1005b970fee5 -X DELETE -H "X-Auth-Project-Id: admin" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: c35f5783528d4131bf100604b2fabd6c"

send: u'DELETE /v2/89a38fe6d3194864995ab0872905a65e/servers/ab0ebda6-2c21-4258-8934-1005b970fee5 HTTP/1.1\r\nHost: 10.34.69.149:8774\r\nx-auth-project-id: admin\r\nx-auth-token: c35f5783528d4131bf100604b2fabd6c\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 204 No Content\r\n'
header: Content-Length: 0
header: X-Compute-Request-Id: req-53e3503a-8d73-4ffc-ba43-4bd5659a9e22
header: Content-Type: application/json
header: Date: Sat, 02 Mar 2013 18:26:21 GMT
RESP:{'date': 'Sat, 02 Mar 2013 18:26:21 GMT', 'status': '204', 'content-length': '0', 'content-type': 'application/json', 'x-compute-request-id': 'req-53e3503a-8d73-4ffc-ba43-4bd5659a9e22'} 
-----------------------------------------------------
REQ: curl -i http://10.34.69.149:8774/v2/89a38fe6d3194864995ab0872905a65e/servers/ab0ebda6-2c21-4258-8934-1005b970fee5 -X GET -H "X-Auth-Project-Id: admin" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: f74d6c7226c14915a26a81b540d43f3b"

connect: (10.34.69.149, 8774)
send: u'GET /v2/89a38fe6d3194864995ab0872905a65e/servers/ab0ebda6-2c21-4258-8934-1005b970fee5 HTTP/1.1\r\nHost: 10.34.69.149:8774\r\nx-auth-project-id: admin\r\nx-auth-token: f74d6c7226c14915a26a81b540d43f3b\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: X-Compute-Request-Id: req-80c97c68-0b44-4650-b027-84a85ee04b86
header: Content-Type: application/json
header: Content-Length: 1502
header: Date: Sat, 02 Mar 2013 18:26:21 GMT
RESP:{'status': '200', 'content-length': '1502', 'content-location': u'http://10.34.69.149:8774/v2/89a38fe6d3194864995ab0872905a65e/servers/ab0ebda6-2c21-4258-8934-1005b970fee5', 'x-compute-request-id': 'req-80c97c68-0b44-4650-b027-84a85ee04b86', 'date': 'Sat, 02 Mar 2013 18:26:21 GMT', 'content-type': 'application/json'} {"server": {"status": "ACTIVE", "updated": "2013-03-02T18:26:21Z", "hostId": "31bdffcdffd5b869b87c9be3cdd700e29c4a08286d6d306622b4815a", "OS-EXT-SRV-ATTR:host": "new32.lithium.rhev.lab.eng.brq.redhat.com", "addresses": {"novanetwork": [{"version": 4, "addr": "192.168.32.2"}]}, "links": [{"href": "http://10.34.69.149:8774/v2/89a38fe6d3194864995ab0872905a65e/servers/ab0ebda6-2c21-4258-8934-1005b970fee5", "rel": "self"}, {"href": "http://10.34.69.149:8774/89a38fe6d3194864995ab0872905a65e/servers/ab0ebda6-2c21-4258-8934-1005b970fee5", "rel": "bookmark"}], "key_name": null, "image": {"id": "12e9c131-aaf4-4f73-9659-ed2da9759cd2", "links": [{"href": "http://10.34.69.149:8774/89a38fe6d3194864995ab0872905a65e/images/12e9c131-aaf4-4f73-9659-ed2da9759cd2", "rel": "bookmark"}]}, "OS-EXT-STS:task_state": "deleting", "OS-EXT-STS:vm_state": "active", "OS-EXT-SRV-ATTR:instance_name": "instance-00000003", "OS-EXT-SRV-ATTR:hypervisor_hostname": "new32.lithium.rhev.lab.eng.brq.redhat.com", "flavor": {"id": "1", "links": [{"href": "http://10.34.69.149:8774/89a38fe6d3194864995ab0872905a65e/flavors/1", "rel": "bookmark"}]}, "id": "ab0ebda6-2c21-4258-8934-1005b970fee5", "security_groups": [{"name": "default"}], "user_id": "1d2b871844434bbc99845ed11c3f897b", "name": "test", "created": "2013-03-02T17:19:44Z", "tenant_id": "89a38fe6d3194864995ab0872905a65e", "OS-DCF:diskConfig": "MANUAL", "accessIPv4": "", "accessIPv6": "", "progress": 0, "OS-EXT-STS:power_state": 1, "config_drive": "", "metadata": {}}}
---------------------------------------------------

Comment 2 Russell Bryant 2013-03-06 22:44:19 UTC
The OpenStack API Change Guidelines state that changing the response code on success is generally not acceptable.  This would have to be considered as a change in API version 3, which will not appear until the Havana release, at the earliest.

https://wiki.openstack.org/wiki/APIChangeGuidelines#Generally_Not_Acceptable