← Back to team overview

yahoo-eng-team team mailing list archive

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

 

Public bug reported:

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.

** Affects: nova
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1520937

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

Status in OpenStack Compute (nova):
  New

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1520937/+subscriptions


Follow ups