radosgw tempurl: Error: path must be full path to an object e.g. /v1/a/c/o

Bug #1704497 reported by Alexander J. Maidak
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Ironic
Triaged
Medium
Unassigned

Bug Description

I'm running ironic bb3da02fbdd9bf8b2aa9707260a716f0469b1748

I'm trying to use RADOSGW in place of Swift. I've followed the docs and believe I've set everything up correctly however every time I attempt to create a baremetal instance I get the following error:

2017-07-14 15:18:20.074 11760 ERROR nova.compute.manager [instance: 3c106de5-a9e8-45e6-b586-557f1e26858c] InstanceDeployFailure: Failed to provision instance 3c106de5-a9e8-45e6-b586-557f1e26858c: Failed to prepare to deploy. Error: path must be full path to an object e.g. /v1/a/c/o

Looking at the code (https://github.com/openstack/ironic/blob/bb3da02fbdd9bf8b2aa9707260a716f0469b1748/ironic/common/glance_service/v2/image_service.py#L92-L93):

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

The issue is that swift_utils is imported from swiftclient and swift client requires a /v1/account/container/object path while radosgw only has a /v1/container/object path. So this code throws an error when it encounters the radosgw case of /v1/container/object...

Revision history for this message
Alexander J. Maidak (ajmaidak) wrote :

I'm not sure helpful this is but I did a little testing with swift client cli

This works good:
$ swift tempurl GET 300 http://192.168.29.184:8080/swift/v1/glance_images/ec198f37-0fac-4a4c-aab0-a01e3d6c7049 6c4cc823457aacac09a49e98
http://192.168.29.184:8080/swift/v1/glance_images/ec198f37-0fac-4a4c-aab0-a01e3d6c7049?temp_url_sig=1065cfc67c2586124e8685233b08bd0ff309a71e&temp_url_expires=1500069811

This does not:
$ swift tempurl GET 300 /v1/glance_images/ec198f37-0fac-4a4c-aab0-a01e3d6c7049 6c4cc823457aacac09a49e98
path must be full path to an object e.g. /v1/a/c/o

Revision history for this message
Dmitry Tantsur (divius) wrote :

I haven't used RadosGW myself, we'll need someone with a working reproducer to take a look.

Changed in ironic:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Travis Vaske (tvaske) wrote :

I have an environment that has the same issue, if you need someone to reproduce this so you can take a look around my environment is throw away. Let me know if you would like to schedule a meeting to troubleshoot.

Thanks!

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

Revision history for this message
Gnanasekar Velu (gnanasekarkas) wrote :

I am facing the similar error when I put /swift like

 *** template = '/swift/{api_version}/{container}/{object_id}' ****,

Request is going to rgw but failing with an error "Failed to prepare to deploy. Error: Validation of image href secreturl failed, reason: Got HTTP code 405 instead of 200 in response to HEAD request."

on rgw logs:

swift/swift/v1/glance_images_region1/6e77c740-4eeb-4a0d-b6a4-7093ddddd0e HTTP/1.1" 405 0 - python-requests/2.18.2

Revision history for this message
yan97ao (yan97ao) wrote :

This is due to this patch https://review.openstack.org/#/c/367377/
Remove the check in python-swiftclient works for me(but not in an elegant way).

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.