Port not parsed correctly in Swift URI

Bug #771849 reported by Jay Pipes
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Glance
Fix Released
High
Jay Pipes
glance (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Hi,

I use Glance bzr124 on a ubuntu 10.04 LTS with a backend Swift 1.2.0.
I can upload and list files on the object store but when I tried to delete one, I've got this error :

$ glance delete 1

Delete image 1? [y/N] y
Traceback (most recent call last):
  File "/usr/bin/glance", line 605, in <module>
    result = command(options, args)
  File "/usr/bin/glance", line 327, in image_delete
    c.delete_image(image_id)
  File "/usr/lib/pymodules/python2.6/glance/client.py", line 289, in delete_image
    self.do_request("DELETE", "/images/%s" % image_id)
  File "/usr/lib/pymodules/python2.6/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 "/usr/lib/pymodules/python2.6/glance/common/wsgi.py", line 228, in __call__
    result = method(**arg_dict)
  File "/usr/lib/pymodules/python2.6/glance/server.py", line 456, in delete
    delete_from_backend(image['location'])
  File "/usr/lib/pymodules/python2.6/glance/store/__init__.py", line 94, in delete_from_backend
    return backend_class.delete(parsed_uri, **kwargs)
  File "/usr/lib/pymodules/python2.6/glance/store/swift.py", line 180, in delete
    swift_conn.delete_object(container, obj)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 839, in delete_object
    return self._retry(None, delete_object, container, obj)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 734, in _retry
    self.url, self.token = self.get_auth()
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 722, in get_auth
    return get_auth(self.authurl, self.user, self.key, snet=self.snet)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 177, in get_auth
    parsed, conn = http_connection(url)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 153, in http_connection
    conn = HTTPSConnection(parsed.netloc)
  File "/usr/lib/python2.6/httplib.py", line 1101, in __init__
    HTTPConnection.__init__(self, host, port, strict, timeout)
  File "/usr/lib/python2.6/httplib.py", line 657, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.6/httplib.py", line 682, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
InvalidURL: nonnumeric port: ''

In the log file of glance (registery + API) :

2011-04-26 18:05:08 DEBUG [routes.middleware] Matched DELETE /images/1
2011-04-26 18:05:08 DEBUG [routes.middleware] Route path: '/images/:(id)', defaults: {'action': u'delete', 'controller': <glance.server.Controller object
at 0x1cd3310>}
2011-04-26 18:05:08 DEBUG [routes.middleware] Match dict: {'action': u'delete', 'controller': <glance.server.Controller object at 0x1cd3310>, 'id': u'1'}
2011-04-26 18:05:08 DEBUG [routes.middleware] Matched GET /images/1
2011-04-26 18:05:08 DEBUG [routes.middleware] Route path: '/images/:(id)', defaults: {'action': u'show', 'controller': <glance.registry.server.Controller
object at 0x220e510>}
2011-04-26 18:05:08 DEBUG [routes.middleware] Match dict: {'action': u'show', 'controller': <glance.registry.server.Controller object at 0x220e510>, 'id':
 u'1'}
2011-04-26 18:05:08 INFO [sqlalchemy.engine.base.Engine.0x...a2d0] SELECT images.created_at AS images_created_at, images.updated_at AS images_updated_at,
 images.deleted_at AS images_deleted_at, images.deleted AS images_deleted, images.id AS images_id, images.name AS images_name, images.disk_format AS images_d
isk_format, images.container_format AS images_container_format, images.size AS images_size, images.status AS images_status, images.is_public AS images_is_pub
lic, images.location AS images_location, images.checksum AS images_checksum, image_properties_1.created_at AS image_properties_1_created_at, image_properties
_1.updated_at AS image_properties_1_updated_at, image_properties_1.deleted_at AS image_properties_1_deleted_at, image_properties_1.deleted AS image_propertie
s_1_deleted, image_properties_1.id AS image_properties_1_id, image_properties_1.image_id AS image_properties_1_image_id, image_properties_1.name AS image_pro
perties_1_name, image_properties_1.value AS image_properties_1_value
FROM images LEFT OUTER JOIN image_properties AS image_properties_1 ON images.id = image_properties_1.image_id
WHERE images.deleted = %s AND images.id = %s
2011-04-26 18:05:08 INFO [sqlalchemy.engine.base.Engine.0x...a2d0] (False, '1')
2011-04-26 18:05:08 DEBUG [sqlalchemy.engine.base.Engine.0x...a2d0] Col ('images_created_at', 'images_updated_at', 'images_deleted_at', 'images_deleted',
'images_id', 'images_name', 'images_disk_format', 'images_container_format', 'images_size', 'images_status', 'images_is_public', 'images_location', 'images_c
hecksum', 'image_properties_1_created_at', 'image_properties_1_updated_at', 'image_properties_1_deleted_at', 'image_properties_1_deleted', 'image_properties_
1_id', 'image_properties_1_image_id', 'image_properties_1_name', 'image_properties_1_value')
2011-04-26 18:05:08 DEBUG [sqlalchemy.engine.base.Engine.0x...a2d0] Row (datetime.datetime(2011, 4, 26, 15, 59, 28), datetime.datetime(2011, 4, 26, 15, 59
, 29), None, 0, 1L, 'Test Swift', 'qcow2', 'bare', 6182L, 'active', 1, 'swift://glance:ethuleau:nah2eeBo@https://p-hs21-15-swift-proxy-1:11000/v1.0//glance/1
', 'f21ea10ef86385db52e39158d7052c58', None, None, None, None, None, None, None, None)
2011-04-26 18:05:08 DEBUG [eventlet.wsgi.server] 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 "/usr/lib/pymodules/python2.6/glance/common/wsgi.py", line 228, in __call__
    result = method(**arg_dict)
  File "/usr/lib/pymodules/python2.6/glance/server.py", line 456, in delete
    delete_from_backend(image['location'])
  File "/usr/lib/pymodules/python2.6/glance/store/__init__.py", line 94, in delete_from_backend
    return backend_class.delete(parsed_uri, **kwargs)
  File "/usr/lib/pymodules/python2.6/glance/store/swift.py", line 180, in delete
    swift_conn.delete_object(container, obj)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 839, in delete_object
    return self._retry(None, delete_object, container, obj)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 734, in _retry
    self.url, self.token = self.get_auth()
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 722, in get_auth
    return get_auth(self.authurl, self.user, self.key, snet=self.snet)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 177, in get_auth
    parsed, conn = http_connection(url)
  File "/usr/lib/pymodules/python2.6/swift/common/client.py", line 153, in http_connection
    conn = HTTPSConnection(parsed.netloc)
  File "/usr/lib/python2.6/httplib.py", line 1101, in __init__
    HTTPConnection.__init__(self, host, port, strict, timeout)
  File "/usr/lib/python2.6/httplib.py", line 657, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.6/httplib.py", line 682, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
InvalidURL: nonnumeric port: ''
2011-04-26 18:05:08 DEBUG [eventlet.wsgi.server] 127.0.0.1 - - [26/Apr/2011 18:05:08] "DELETE /images/1 HTTP/1.1" 500 2509 0.012554
2011-04-26 18:05:08 DEBUG [eventlet.wsgi.server] 127.0.0.1 - - [26/Apr/2011 18:05:08] "GET /images/1 HTTP/1.1" 200 543 0.017775

Is it a bug or I made a mistake in my platform ?

Regards,
Édouard.

Related branches

Jay Pipes (jaypipes)
Changed in glance:
importance: Undecided → High
assignee: nobody → Jay Pipes (jaypipes)
Jay Pipes (jaypipes)
Changed in glance:
status: New → Confirmed
milestone: none → diablo-1
Revision history for this message
Jay Pipes (jaypipes) wrote :

Rick is brilliant...

Use swift+http:// as the solution.

Changed in glance:
status: Confirmed → Triaged
Revision history for this message
Everett Toews (everett-toews) wrote :

And where exactly in /etc/glance/glance.conf do you use this solution?

At first I thought it was in swift_store_auth_address, e.g.

    default_store = swift
    swift_store_auth_address = swift+https://192.168.5.250:8080/auth/v1.0/

Then it occurred to me it made more sense in default_store, e.g.

    default_store = swift+https://
    swift_store_auth_address = 192.168.5.250:8080/auth/v1.0/

but neither worked for me. Could the s in https be throwing it off or is it something else?

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

Hehe, sorry Everett, I didn't mean it was the solution as a workaround. I meant it is the solution I have to write into the code base so that we can have proper parsing of "URIs within URIs". :)

Jay Pipes (jaypipes)
Changed in glance:
milestone: diablo-1 → diablo-2
Jay Pipes (jaypipes)
Changed in glance:
milestone: diablo-2 → diablo-3
Jay Pipes (jaypipes)
Changed in glance:
status: Triaged → In Progress
Changed in glance:
status: In Progress → Fix Committed
Jay Pipes (jaypipes)
Changed in glance (Ubuntu):
status: New → Invalid
Thierry Carrez (ttx)
Changed in glance:
milestone: diablo-3 → 2011.3
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

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.