Nova strips the path from glance servers specificed in [glance]/api_servers config

Bug #1520937 reported by Morgan Fainberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Sean Dague

Bug Description

Nova strips out the path from the URL for any glance server in the "api_servers" configuration option. This prevents the use of <host>/image as part of the location for glance to be specified.

the code in "nova.image.glance" for "get_api_servers" silently drops the path on the floor.

As you can see here:

def get_api_servers():
    """Shuffle a list of CONF.glance.api_servers and return an iterator
    that will cycle through the list, looping around to the beginning
    if necessary.
    """
    api_servers = []

    configured_servers = (['%s:%s' % (CONF.glance.host, CONF.glance.port)]
                          if CONF.glance.api_servers is None
                          else CONF.glance.api_servers)
    for api_server in configured_servers:
        if '//' not in api_server:
            api_server = 'http://' + api_server
        o = urlparse.urlparse(api_server)
        port = o.port or 80
        host = o.netloc.rsplit(':', 1)[0]
        if host[0] == '[' and host[-1] == ']':
            host = host[1:-1]
        use_ssl = (o.scheme == 'https')
        api_servers.append((host, port, use_ssl))
    random.shuffle(api_servers)
    return itertools.cycle(api_servers)

Urlparse.urlparse splits out as follows:

>>> urlparse.urlparse("http://test.com/images")
ParseResult(scheme='http', netloc='test.com', path='/images', params='', query='', fragment='')

This means that glance *must* be on the root of wherever it lives from nova's perspective. We should not prevent services from living outside of the "root" of the path / ignoring proper URL schemes.

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

It looks like glanceclient may make it exceedingly difficult to add in a path-prefix in the way nova is consuming it.

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

upon further digging it looks like glanceclient may just accept the URI path as long as it is constructed sanely. However, it is not an easy construction in the way it's being presented.

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

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

Changed in nova:
assignee: nobody → Morgan Fainberg (mdrnstm)
status: New → In Progress
no longer affects: python-glanceclient
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to nova (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/251926

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Morgan Fainberg (<email address hidden>) on branch: master
Review: https://review.openstack.org/251926

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Morgan Fainberg (<email address hidden>) on branch: master
Review: https://review.openstack.org/251138

Revision history for this message
Sean Dague (sdague) wrote :

This has been fixed in upstream Mitaka.

Changed in nova:
assignee: Morgan Fainberg (mdrnstm) → Sean Dague (sdague)
importance: Undecided → Medium
status: In Progress → 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.