docker-archive / docker-registry

This is **DEPRECATED**! Please go to https://github.com/docker/distribution
Apache License 2.0
2.88k stars 879 forks source link

Cryptic Error message if glance URL is invalid #192

Open chilicat opened 10 years ago

chilicat commented 10 years ago

I started a docker-registry in for my openstack deployment.

docker run -d -p 5042:5000 \
  -e SETTINGS_FLAVOR=openstack \
  -e OS_USERNAME=${OS_USERNAME} \
  -e OS_PASSWORD=${OS_PASSWORD} \
  -e OS_TENANT_NAME=${OS_TENANT_NAME} \
  -e OS_GLANCE_URL=$glance \
  -e OS_AUTH_URL=${OS_AUTH_URL}  \

By mistake I handed over a invalid URL for glance (basically I just provided the IP address)

I got following error message:

AttributeError: 'NoneType' object has no attribute 'rfind'
    2014-01-13 14:20:42,546 ERROR: Exception on /v1/images/539c0211cd76cdeaedbecf9f023ef774612e331137ce7ebe4ae1b61088e7edbe/json [PUT]
    Traceback (most recent call last):
      [snip] ..... [snip]
      File "/docker-registry/lib/storage/glance.py", line 58, in dispatcher
        return attr(*args, **kwargs)
      File "/docker-registry/lib/storage/glance.py", line 213, in remove
        (image, propname) = self._init_path(path, False)
      File "/docker-registry/lib/storage/glance.py", line 113, in _init_path
        image = self._find_image_by_id(glance, image_id)
      File "/docker-registry/lib/storage/glance.py", line 146, in _find_image_by_id
        images = [i for i in glance.images.list(filters=filters)]
      File "/usr/local/lib/python2.7/dist-packages/glanceclient/v1/images.py", line 174, in paginate
        images = self._list(url, "images")
      File "/usr/local/lib/python2.7/dist-packages/glanceclient/common/base.py", line 53, in _list
        resp, body = self.api.json_request('GET', url)
      File "/usr/local/lib/python2.7/dist-packages/glanceclient/common/http.py", line 250, in json_request
        resp, body_iter = self._http_request(url, method, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/glanceclient/common/http.py", line 184, in _http_request
        conn = self.get_connection()
      File "/usr/local/lib/python2.7/dist-packages/glanceclient/common/http.py", line 113, in get_connection
        **self.connection_kwargs)
      File "/usr/lib/python2.7/httplib.py", line 693, in __init__
        self._set_hostport(host, port)
      File "/usr/lib/python2.7/httplib.py", line 712, in _set_hostport
        i = host.rfind(':')

The docker-registry (or container) should evaluate the given URL and fail with a user friendly message in case it is invalid.

shin- commented 10 years ago

Thanks for the report, we'll look into it!

chilicat commented 10 years ago

Just a minor thing, but everything which helps to find the user mistake faster.... :) I would prefer if the application can fail as early as possible, during startup, if possible. thanks