DELETE existing image fails if location attribute is None

Bug #747799 reported by Tushar Patil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Jay Pipes

Bug Description

Tested on revision No 100.

I was trying to add machine type image using glance-upload and for some reasons I terminated the command while uploading the image.
$./glance-upload --type=machine /home/tpatil/ipv6-images/ipv6-disk-image ipv6-image-test --ramdisk=2 --kernel=1

$./glance index
list the registered images as:-
root@ubuntu-openstack-glance-server:/home/tpatil/glance/bin# ./glance index
Found 4 public images...
ID Name Disk Format Container Format Size
---------------- ------------------------------ -------------------- -------------------- --------------
1 ipv6-kernel None None 3522336
2 ipv6-ramdisk None None 8679404
3 ipv6-image None None 1049624576
4 ipv6-image-test None None 0

Note: Id 4, size of the image is 0 bytes.

Now if I try to delete the image of Id 4, it gives me following error:-
root@ubuntu-openstack-glance-server:/home/tpatil/glance/bin# ./glance delete 4
Traceback (most recent call last):
  File "./glance", line 566, in <module>
    result = command(options, args)
  File "./glance", line 318, in image_delete
    c.delete_image(image_id)
  File "/home/tpatil/glance/glance/client.py", line 289, in delete_image
    self.do_request("DELETE", "/images/%s" % image_id)
  File "/home/tpatil/glance/glance/client.py", line 161, in do_request
    raise Exception("Internal Server error: %s" % res.read())
Exception: Internal Server error: Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/home/tpatil/glance/glance/common/wsgi.py", line 228, in __call__
    result = method(**arg_dict)
  File "/home/tpatil/glance/glance/server.py", line 453, in delete
    delete_from_backend(image['location'])
  File "/home/tpatil/glance/glance/store/__init__.py", line 88, in delete_from_backend
    parsed_uri = urlparse.urlparse(uri)
  File "/usr/lib/python2.6/urlparse.py", line 129, in urlparse
    tuple = urlsplit(url, scheme, allow_fragments)
  File "/usr/lib/python2.6/urlparse.py", line 168, in urlsplit
    i = url.find(':')
AttributeError: 'NoneType' object has no attribute 'find'

Related branches

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

This has to do with the location attribute of the image not being set, not the size being 0. Changing bug description accordingly.

Changed in glance:
assignee: nobody → Jay Pipes (jaypipes)
milestone: none → cactus-2011-04-07
importance: Undecided → Medium
status: New → Triaged
summary: - Delete image of size 0 gives AttributeError
+ DELETE existing image fails if location attribute is None
Revision history for this message
Jay Pipes (jaypipes) wrote :
Download full text (3.4 KiB)

Adding this test to /tests/unit/test_api.py:

    def test_delete_queued_image(self):
        """
        Here, we try to delete an image that is in the queued state.
        Bug #747799 demonstrated that trying to DELETE an image
        that had had its save process killed manually results in failure
        because the location attribute is None.
        """
        # Add an image the way that glance-upload adds an image...
        # by reserving a place in the database for an image without
        # really any attributes or information on the image and then
        # later doing an update with the image body and other attributes.
        # We will stop the process after the reservation stage, then
        # try to delete the image.
        fixture_headers = {'x-image-meta-store': 'file',
                           'x-image-meta-name': 'fake image #3'}

        req = webob.Request.blank("/images")
        req.method = 'POST'
        for k, v in fixture_headers.iteritems():
            req.headers[k] = v
        res = req.get_response(self.api)
        self.assertEquals(res.status_int, httplib.CREATED)

        res_body = json.loads(res.body)['image']
        self.assertEquals('queued', res_body['status'])

        # Now try to delete the image...
        req = webob.Request.blank("/images/3")
        req.method = 'DELETE'
        res = req.get_response(self.api)
        self.assertEquals(res.status_int, 200)

Re-produces the cause of the error:

======================================================================
ERROR: test_delete_queued_image (tests.unit.test_api.TestGlanceAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jpipes/repos/glance/bug747799/tests/unit/test_api.py", line 615, in test_delete_queued_image
    res = req.get_response(self.api)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/request.py", line 1008, in get_response
    application, catch_exc_info=False)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/request.py", line 977, in call_application
    app_iter = application(self.environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/home/jpipes/repos/glance/bug747799/glance/common/wsgi.py", line 228, in __call__
    result = method(**arg_dict)
  File "...

Read more...

Changed in glance:
status: Triaged → In Progress
Revision history for this message
Jay Pipes (jaypipes) wrote :

Adding this line:

            values['location'] = values.get('location')

to the stubbed DB calls reproduces the error identically:

RROR: test_delete_queued_image (tests.unit.test_api.TestGlanceAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jpipes/repos/glance/bug747799/tests/unit/test_api.py", line 615, in test_delete_queued_image
    res = req.get_response(self.api)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/request.py", line 1008, in get_response
    application, catch_exc_info=False)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/request.py", line 977, in call_application
    app_iter = application(self.environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/home/jpipes/repos/glance/bug747799/.glance-venv/lib/python2.6/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/home/jpipes/repos/glance/bug747799/glance/common/wsgi.py", line 228, in __call__
    result = method(**arg_dict)
  File "/home/jpipes/repos/glance/bug747799/glance/server.py", line 453, in delete
    delete_from_backend(image['location'])
  File "/home/jpipes/repos/glance/bug747799/glance/store/__init__.py", line 88, in delete_from_backend
    parsed_uri = urlparse.urlparse(uri)
  File "/usr/lib/python2.6/urlparse.py", line 129, in urlparse
    tuple = urlsplit(url, scheme, allow_fragments)
  File "/usr/lib/python2.6/urlparse.py", line 168, in urlsplit
    i = url.find(':')
AttributeError: 'NoneType' object has no attribute 'find'

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
milestone: cactus-2011-04-07 → 2011.2
status: Fix Committed → Fix Released
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.