Cannot delete remote image

Bug #912897 reported by Jay Pipes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Eoghan Glynn

Bug Description

Trying to delete images from Glance that have the Location set during registration (remote images) fails:

jpipes@librebox:~/repos/tempest$ glance -A servicetoken delete 203ed357-388c-4beb-9289-e98473dda896
Delete image 203ed357-388c-4beb-9289-e98473dda896? [y/N] y
Traceback (most recent call last):
  File "/usr/local/bin/glance", line 7, in <module>
    execfile(__file__)
  File "/opt/stack/glance/bin/glance", line 947, in <module>
    result = command(options, args)
  File "/opt/stack/glance/bin/glance", line 394, in image_delete
    c.delete_image(image_id)
  File "/opt/stack/glance/glance/client.py", line 185, in delete_image
    self.do_request("DELETE", "/images/%s" % image_id)
  File "/opt/stack/glance/glance/common/client.py", line 46, in wrapped
    return func(self, *args, **kwargs)
  File "/opt/stack/glance/glance/common/client.py", line 328, in do_request
    headers=headers)
  File "/opt/stack/glance/glance/common/client.py", line 63, in wrapped
    return func(self, method, url, body, headers)
  File "/opt/stack/glance/glance/common/client.py", line 423, in _do_request
    raise Exception("Internal Server error: %s" % res.read())
Exception: Internal Server error: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 194, in __call__
    response = req.get_response(self.application)
  File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/opt/stack/keystone/keystone/middleware/auth_token.py", line 212, in __call__
    return self._forward_request(env, start_response, proxy_headers)
  File "/opt/stack/keystone/keystone/middleware/auth_token.py", line 344, in _forward_request
    return self.app(env, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 194, in __call__
    response = req.get_response(self.application)
  File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.7/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 392, in __call__
    request, **action_args)
  File "/opt/stack/glance/glance/common/wsgi.py", line 409, in dispatch
    return method(*args, **kwargs)
  File "/opt/stack/glance/glance/api/v1/images.py", line 583, in delete
    req.context, id)
  File "/opt/stack/glance/glance/store/__init__.py", line 181, in schedule_delete_from_backend
    return delete_from_backend(uri, **kwargs)
  File "/opt/stack/glance/glance/store/__init__.py", line 142, in delete_from_backend
    raise exception.StoreDeleteNotSupported
StoreDeleteNotSupported: Deleting images from this store is not supported.

We should not error out if the backend does not support deletion. We should simply log an informative message and return a successful result.

Eoghan Glynn (eglynn)
Changed in glance:
assignee: nobody → Eoghan Glynn (eglynn)
Revision history for this message
Eoghan Glynn (eglynn) wrote :

Just to clarify, is the intent to either:

a) Change the glance CLI so that an error return from a DELETE call is handled in a more graceful way, i.e. consume the 500 Internal Server Error status & traceback message and return a successful exit status to the shell.

or:

b) Change the semantics and implementation of the Glance REST API, so that a DELETE on an undeletable image returns a pseudo-successful status (i.e. 204 No Content).

Approach (b) would seem to discard information that would be potentially useful to some clients.

Revision history for this message
Jay Pipes (jaypipes) wrote :

Actually, neither :)

The intent is to merely cathc the StoreDeleteNotSupported in the glance.store.delete_from_backend() method but not re-raise it. Simply log an INFO message stating an image was deleted from the registry and the backend did not support deletion.

That way, the registry will properly mark the image deleted, even if the backend does not support deletion (like is the case with the HTTP backend for remote images)

Make sense?
-jay

Revision history for this message
Eoghan Glynn (eglynn) wrote :

Yep, makes perfect sense, thanks.

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

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

Changed in glance:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/3192
Committed: http://github.com/openstack/glance/commit/41b981c98d947ada3e8c83af8392e222ce1b00cd
Submitter: Jenkins
Branch: master

commit 41b981c98d947ada3e8c83af8392e222ce1b00cd
Author: Eoghan Glynn <email address hidden>
Date: Thu Jan 19 22:07:25 2012 +0000

    Swallow exception on unsupported image deletion.

    Fixes LP #912897

    When the remote store does not support deletion of images (e.g. HTTP)
    the StoreDeleteNotSupported exception is now swallowed and logged as
    opposed to it being propagated back to the glance CLI.

    Also after a failed delete, we avoid falling through to the delayed
    delete logic.

    Change-Id: I6cc529f029750fc66a4d32e2076f29198b3d2093

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
status: Fix Committed → Fix Released
Jay Pipes (jaypipes)
tags: added: diablo-backport-needed
Thierry Carrez (ttx)
Changed in glance:
milestone: essex-3 → 2012.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.