Open sbjorn opened 9 years ago
Can one of the admins verify this patch?
The code looks good. As this is not tested in Tempest, could you provide a CURL command to GET a specific part of a Glance image ?
The API v2 of glance allow partial retrieval of images (eventhough it is broken). Here is a CURL command which targets the api v2 endpoint and retrieves the first 50 bytes of an image;
$ curl -i -H 'X-Auth-Token: mytoken' -H 'Content-Range: bytes 0-49/245' http://127.0.0.1:9292/v2/images/c0c2cf17-cfcb-45ef-a6a7-2d7502d36338/file
The implementation on the glance api side is flaky. Make sure you have disabled caching, otherwise the cache might serve this request (which completely ignores the Content-Range
header and returns the whole image).
A bigger problem is that the partial image retrieval implementation is broken; this currently does not work at all because the Content-Size
header is explicitly set to the size of the whole object. See https://github.com/openstack/glance/blob/master/glance/api/v2/image_data.py#L241
I guess https://github.com/openstack/glance could use a couple of bug reports in Launchpad then (if they're not in yet), and some patches in Gerrit (if time permits) :-)
The question we would have to ask is 'should we fix something we don't use and we've not been requested to add' ?
A bug report is nice in any case.
The bug regarding partial image retrieval is treated in https://bugs.launchpad.net/glance/+bug/1399851
As for the cache, I just filed a new bug; https://bugs.launchpad.net/glance/+bug/1459550
This adds support for the READ_RANDOM capability by leveraging HTTP range requests as outlined in #7. Due to limitations in sproxyd, explicit ranges must be calculated before a partial get request.
There are issues around how exceptions are handled in glance when requesting an object from the store. One of the paths calling the
store.get
is theshow
implementation in APIv1 https://github.com/openstack/glance/blob/master/glance/api/v1/images.py#L467. We can essentially only raiseRemoteServiceUnavailable
,NotFound
,StoreGetNotSupported
,StoreRandomGetNotSupported
orUnknownScheme
, none of which make much sense in case of an invalid request range, i.e. a 416 HTTP status code. A hackish way of doing this is to raise the webob exception immediately, which will fall through the glance exception logic in the_get_from_store
method.