Comment 4 for bug 1704497

Revision history for this message
cleandesk (cleandesk) wrote :

I've run into this bug as well. As the comment of Alexander described, the swiftclient lib does know how to connect to radosgw, so the bug is in the Ironic part getting the tempurl. I spent some time searching and I came to the following dirty trick:

In the file common/glance_service/v2/image_service.py I've added 2 lines:

========================================================================
In the function swift_temp_url:
========================================================================
if CONF.deploy.object_store_endpoint_type == 'radosgw':
            chunks = urlparse.urlsplit(CONF.glance.swift_endpoint_url)
            if not chunks.path:
                endpoint_url = urlparse.urljoin(
                    endpoint_url, 'swift')
            elif chunks.path != '/swift':
                raise exc.InvalidParameterValue(
                    _('Swift endpoint URL should only contain scheme, '
                      'hostname, optional port and optional /swift path '
                      'without trailing slash; provided value is: %s')
                    % endpoint_url)
*** template = '/swift/{api_version}/{container}/{object_id}' ****
else:
            template = '/{api_version}/{account}/{container}/{object_id}'

========================================================================
And in the function _generate_temp_url
========================================================================
if CONF.glance.swift_temp_url_cache_enabled:
   self._remove_expired_items_from_cache()
   if image_id in self._cache:
        return self._cache[image_id].url

path = swift_utils.generate_temp_url(
    path=path, seconds=seconds, key=key, method=method)

***endpoint=CONF.glance.swift_endpoint_url ***

temp_url = '{endpoint_url}{url_path}'.format(
    endpoint_url=endpoint, url_path=path)

========================================================================

Before, it gets the endpoint variable from keystone, which is http://1.2.3.4:8080/swift/v1
the swift_temp_url strips this down to http://1.2.3.4:8080/swift and gives this to the _generate_temp_url function.

The url_path variable delivered by the swift_temp_url function (from glance), which is e.g. /v1/glance_images/21893723873. The swiftclient doesn't like this and needs the /swift in front like this: /swift/v1/glance_images/21893723873.
To achieve this I've changed the template var in the if statement detecting radosgw and changed the endpoint url var in the _generate_temp_url function to the swift_endpoint_url in de conf file, which you need to set anyway