Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 923395

Summary: member-delete incorrect status codes on delete already deleted entry
Product: Red Hat OpenStack Reporter: Attila Fazekas <afazekas>
Component: openstack-glanceAssignee: Eoghan Glynn <eglynn>
Status: CLOSED ERRATA QA Contact: Attila Fazekas <afazekas>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 2.0 (Folsom)CC: eglynn
Target Milestone: snapshot5Keywords: Triaged
Target Release: 2.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openstack-glance-2012.2.3-8.el6ost Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 917059 Environment:
Last Closed: 2013-04-04 20:24:04 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:
Bug Depends On: 917059    
Bug Blocks:    

Description Attila Fazekas 2013-03-19 18:16:22 UTC
+++ This bug was initially created as a clone of Bug #917059 +++

Package versions:
python-glance-2012.2.3-3.el6ost.noarch
openstack-glance-2012.2.3-3.el6ost.noarch


Prepare an image and a tenant:


$ keystone tenant-create  --name test --description foo --enable true
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |               foo                |
|   enabled   |               True               |
|      id     | 8c2d8b205f334084b06105f3301b7e27 |
|     name    |               test               |
+-------------+----------------------------------+

$ glance --debug image-create --name image --container-format bare --disk-format  raw --is-public False --file /etc/passwd
curl -i -X POST -H 'x-image-meta-container_format: bare' -H 'User-Agent: python-glanceclient' -H 'x-image-meta-size: 1961' -H 'x-image-meta-is_public: False' -H 'X-Auth-Token: ab2643534a2d45deab2a74623b3907e2' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-disk_format: raw' -H 'x-image-meta-name: image' -d '<open file '/etc/passwd', mode 'r' at 0x23c8540>' http://10.34.63.217:9292/v1/images

HTTP/1.1 201 Created
content-length: 420
etag: bbb75599cd7acee6c7e118a0a0cc4ce8
location: http://10.34.63.217:9292/v1/images/930e76ab-c971-4463-8005-631ccc3aa4ae
date: Fri, 01 Mar 2013 14:18:20 GMT
content-type: application/json
x-openstack-request-id: req-d1be8f08-083b-447d-a706-d361fd7ec3c1

{"image": {"status": "active", "name": "image", "deleted": false, "container_format": "bare", "created_at": "2013-03-01T14:18:20", "disk_format": "raw", "updated_at": "2013-03-01T14:18:20", "properties": {}, "min_disk": 0, "protected": false, "id": "930e76ab-c971-4463-8005-631ccc3aa4ae", "checksum": "bbb75599cd7acee6c7e118a0a0cc4ce8", "owner": null, "is_public": false, "deleted_at": null, "min_ram": 0, "size": 1961}}

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | bbb75599cd7acee6c7e118a0a0cc4ce8     |
| container_format | bare                                 |
| created_at       | 2013-03-01T14:18:20                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | raw                                  |
| id               | 930e76ab-c971-4463-8005-631ccc3aa4ae |
| is_public        | False                                |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | image                                |
| owner            | None                                 |
| protected        | False                                |
| size             | 1961                                 |
| status           | active                               |
| updated_at       | 2013-03-01T14:18:20                  |
+------------------+--------------------------------------+

Delete the member two times:

$ glance --debug member-create 930e76ab-c971-4463-8005-631ccc3aa4ae 8c2d8b205f334084b06105f3301b7e27
curl -i -X PUT -H 'X-Auth-Token: 676b05a0fd254c0a92c3554071fa25fb' -H 'Content-Type: application/json' -H 'User-Agent: python-glanceclient' -d '{"member": {"can_share": false}}' http://10.34.63.217:9292/v1/images/930e76ab-c971-4463-8005-631ccc3aa4ae/members/8c2d8b205f334084b06105f3301b7e27

HTTP/1.1 204 No Content
date: Fri, 01 Mar 2013 14:19:48 GMT
content-length: 0
content-type: text/html; charset=UTF-8
x-openstack-request-id: req-e5845b76-3a74-4361-b09d-399c09f4ee64


Until now everything looks normal.
---------------------------------------------------------------------
$ glance --debug member-delete 930e76ab-c971-4463-8005-631ccc3aa4ae 8c2d8b205f334084b06105f3301b7e27
curl -i -X DELETE -H 'X-Auth-Token: 217e98ae51c64cc09b32d29295872b1f' -H 'Content-Type: application/octet-stream' -H 'User-Agent: python-glanceclient' http://10.34.63.217:9292/v1/images/930e76ab-c971-4463-8005-631ccc3aa4ae/members/8c2d8b205f334084b06105f3301b7e27

HTTP/1.1 204 No Content
date: Fri, 01 Mar 2013 14:19:59 GMT
content-length: 0
content-type: text/html; charset=UTF-8
x-openstack-request-id: req-d8d87e8d-3809-438f-a612-6544ba0d4e92

++++++++++++++++++++++++++++++++++
+Expected response 404 not found.+
++++++++++++++++++++++++++++++++++

According to the listing commands the listing commands, the member successfully deleted.

$ glance --debug member-list  --tenant-id 8c2d8b205f334084b06105f3301b7e27
curl -i -X GET -H 'X-Auth-Token: 2bc031236dd346cb9542b6e6764eaba1' -H 'Content-Type: application/json' -H 'User-Agent: python-glanceclient' http://10.34.63.217:9292/v1/shared-images/8c2d8b205f334084b06105f3301b7e27

HTTP/1.1 200 OK
date: Fri, 01 Mar 2013 14:20:33 GMT
content-length: 21
content-type: application/json; charset=UTF-8
x-openstack-request-id: req-ae3f11dc-465f-4ba5-9089-fb4ab904ca5d

{"shared_images": []}


$ glance --debug member-list  --image-id 930e76ab-c971-4463-8005-631ccc3aa4ae
curl -i -X GET -H 'X-Auth-Token: 06d3d635db824902bd6c7584050b9315' -H 'Content-Type: application/json' -H 'User-Agent: python-glanceclient' http://10.34.63.217:9292/v1/images/930e76ab-c971-4463-8005-631ccc3aa4ae/members

HTTP/1.1 200 OK
date: Fri, 01 Mar 2013 14:21:00 GMT
content-length: 15
content-type: application/json; charset=UTF-8
x-openstack-request-id: req-cc263d3a-d40e-45f2-af36-6f677d7f5b73

{"members": []}
--------------------------------------------------------

Delete a member from a not existing image: 
---------------------------------------------------
$glance --debug member-delete 930e76ab-c971-4463-8005-631ccc3aa4ab 8c2d8b205f334084b06105f3301b7e27
curl -i -X DELETE -H 'X-Auth-Token: 529d973daf2246c2868eaddece1a671c' -H 'Content-Type: application/octet-stream' -H 'User-Agent: python-glanceclient' http://10.34.63.217:9292/v1/images/930e76ab-c971-4463-8005-631ccc3aa4ab/members/8c2d8b205f334084b06105f3301b7e27

HTTP/1.1 404 Not Found
date: Fri, 01 Mar 2013 14:31:31 GMT
content-length: 104
content-type: text/plain; charset=UTF-8
x-openstack-request-id: req-34cecfe0-c82a-4b47-b244-dfb1ad598de5

404 Not Found

The resource could not be found.

 404 Not Found  The resource could not be found.       

Request returned failure status.
HTTPNotFound (HTTP 404)
-------------------------------

It is working correctly regardless to the tenant_id.

Note:
I have a workaround for #890798.


--- Additional comment from Eoghan Glynn on 2013-03-11 16:59:14 EDT ---

The problem is that the image member is referred to without checking if it actually exists:

  https://github.com/openstack/glance/blob/stable/folsom/glance/registry/api/v1/members.py#L284

leading to an IndexError on the list dereference in the non-existing case.

The fix is obvious and highly self-contained, hence very low-risk.

--- Additional comment from Eoghan Glynn on 2013-03-11 17:02:40 EDT ---

When forward-porting my initial fix to upstream master, I discovered that it has already been fixed there:

  https://review.openstack.org/14210

Hence the task just collapses down to a master->stable backport of an existing fix.

Abandoning my own patch, and backporting the original fix.

--- Additional comment from Eoghan Glynn on 2013-03-11 17:05:39 EDT ---

Original fix backported and proposed to stable/folsom upstream:

  https://review.openstack.org/24116

--- Additional comment from Eoghan Glynn on 2013-03-11 19:16:52 EDT ---

Proposed internally as:

  https://code.engineering.redhat.com/gerrit/#/c/3951/


--- Additional comment from Attila Fazekas on 2013-03-17 13:29:36 EDT ---

The 500 error response fixed.

But, deleting an already deleted member still succeeds. I got 204, but the expected 404.

Did you created a different issue for that ?

--- Additional comment from Eoghan Glynn on 2013-03-19 14:01:00 EDT ---

Attila,

I missed the second intertwined issue.

The 204 versus 404 should probably have been separate from the get-go

So can you clone off a separate issue for it, and I'll take a look at later this evening?

(I suspect probably a simple issue around the lingering deleted=1 row in the DB, so should probably be quickly fixable ...)

Cheers,
Eoghan

Comment 4 Eoghan Glynn 2013-03-19 21:52:10 UTC
Lon,

Which patch are you refering to?

I've just proposed a fix upstream on stable/folsom:

  https://review.openstack.org/24838

Note the issue does not exist on master, but the more limited fix is preferable IMO to a backport of more extensive refactoring.

Comment 12 errata-xmlrpc 2013-04-04 20:24:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0707.html