+1 to the description, I'll make sure Waldon reviews the patches today
On Fri, Mar 8, 2013 at 9:11 AM, Stuart McLaren <email address hidden> wrote: > Thierry, > > Thanks. That looks good to me. > > -- > You received this bug notification because you are a member of Glance > Core, which is subscribed to the bug report. > https://bugs.launchpad.net/bugs/1135541 > > Title: > v1 api returns location as header for cached images > > Status in OpenStack Image Registry and Delivery Service (Glance): > Triaged > > Bug description: > > When an image which is not in cache is downloaded: > > rm /opt/stack/data/glance/cache/2e877e45-5c13-42e8-995a-ffb28f888df4 ; > glance --os-image-api-version 1 --os-username glance --os-password > XXX --os-tenant-name service --os-auth-url http://localhost:5000/v2.0 > image-download 2e877e45-5c13-42e8-995a-ffb28f888df4 > > The headers don't contain the backend 'location' field: > > T 10.6.51.191:9292 -> 10.6.51.191:52150 [AP] > HTTP/1.1 200 OK. > Content-Type: application/octet-stream. > X-Image-Meta-Id: 2e877e45-5c13-42e8-995a-ffb28f888df4. > X-Image-Meta-Deleted: False. > X-Image-Meta-Container_format: bare. > X-Image-Meta-Checksum: ccad32d005750c1005a80079b6fe8a9f. > X-Image-Meta-Protected: False. > X-Image-Meta-Min_disk: 0. > X-Image-Meta-Created_at: 2013-02-27T10:37:24. > X-Image-Meta-Size: 332. > X-Image-Meta-Status: active. > X-Image-Meta-Is_public: False. > X-Image-Meta-Min_ram: 0. > X-Image-Meta-Owner: 1bc9a6b4c0064336bc877f813244ffa1. > X-Image-Meta-Updated_at: 2013-02-27T10:37:25. > X-Image-Meta-Disk_format: qcow2. > X-Image-Meta-Name: Image1. > Location: http://10.6.51.191:9292/v1/images/2e877e45-5c13-42e8-995a-ffb28f888df4. > Etag: ccad32d005750c1005a80079b6fe8a9f. > X-Openstack-Request-Id: req-60ab20e6-4c3b-43a6-8203-c20d113fd7a4. > Date: Thu, 28 Feb 2013 10:23:06 GMT. > Transfer-Encoding: chunked. > . > 14c. > > > But if the image is cached: > > glance --os-image-api-version 1 --os-username glance --os-password > XXX --os-tenant-name service --os-auth-url http://localhost:5000/v2.0 > image-download 2e877e45-5c13-42e8-995a-ffb28f888df4 > > the backend location field (with credentials) is returned as a header: > > T 10.6.51.191:9292 -> 10.6.51.191:51954 [AP] > HTTP/1.1 200 OK. > Content-Length: 332. > Content-Type: application/octet-stream. > X-Image-Meta-Id: 2e877e45-5c13-42e8-995a-ffb28f888df4. > X-Image-Meta-Deleted: False. > X-Image-Meta-Container_format: bare. > X-Image-Meta-Location: swift+http://service%3Aglance:<redacted>@10.6.51.191:5000/v2.0/glance/2e877e45-5c13-42e8-995a-f fb28f888df4. > X-Image-Meta-Protected: False. > X-Image-Meta-Min_disk: 0. > X-Image-Meta-Created_at: 2013-02-27T10:37:24. > X-Image-Meta-Size: 332. > X-Image-Meta-Status: active. > X-Image-Meta-Is_public: False. > X-Image-Meta-Min_ram: 0. > X-Image-Meta-Owner: 1bc9a6b4c0064336bc877f813244ffa1. > X-Image-Meta-Updated_at: 2013-02-27T10:37:25. > X-Image-Meta-Checksum: ccad32d005750c1005a80079b6fe8a9f. > X-Image-Meta-Disk_format: qcow2. > X-Image-Meta-Name: Image1. > Location: http://10.6.51.191:9292/v1/images/2e877e45-5c13-42e8-995a-ffb28f888df4. > Etag: ccad32d005750c1005a80079b6fe8a9f. > X-Openstack-Request-Id: req-a854a036-5abb-477e-a6da-69012befe2ad. > Date: Thu, 28 Feb 2013 10:22:15 GMT. > . > > > A possible fix for this: > > $ git diff glance/api/v1/images.py > diff --git a/glance/api/v1/images.py b/glance/api/v1/images.py > index 4b62946..fadc888 100644 > --- a/glance/api/v1/images.py > +++ b/glance/api/v1/images.py > @@ -933,6 +933,9 @@ class ImageSerializer(wsgi.JSONResponseSerializer): > self.notifier = notifier.Notifier() > > def _inject_location_header(self, response, image_meta): > + # Remove original location for security reasons > + if 'location' in image_meta: > + del image_meta['location'] > location = self._get_image_location(image_meta) > response.headers['Location'] = location.encode('utf-8') > > To manage notifications about this bug go to: > https://bugs.launchpad.net/glance/+bug/1135541/+subscriptions
+1 to the description, I'll make sure Waldon reviews the patches today
On Fri, Mar 8, 2013 at 9:11 AM, Stuart McLaren /bugs.launchpad .net/bugs/ 1135541 data/glance/ cache/2e877e45- 5c13-42e8- 995a-ffb28f888d f4 ; api-version 1 --os-username glance --os-password localhost: 5000/v2. 0 5c13-42e8- 995a-ffb28f888d f4 octet-stream. 5c13-42e8- 995a-ffb28f888d f4. Meta-Deleted: False. Meta-Container_ format: bare. Meta-Checksum: ccad32d005750c1 005a80079b6fe8a 9f. Meta-Protected: False. Meta-Min_ disk: 0. Meta-Created_ at: 2013-02- 27T10:37: 24. Meta-Status: active. Meta-Is_ public: False. Meta-Min_ ram: 0. 6bc877f813244ff a1. Meta-Updated_ at: 2013-02- 27T10:37: 25. Meta-Disk_ format: qcow2. 10.6.51. 191:9292/ v1/images/ 2e877e45- 5c13-42e8- 995a-ffb28f888d f4. 005a80079b6fe8a 9f. Request- Id: req-60ab20e6- 4c3b-43a6- 8203-c20d113fd7 a4. api-version 1 --os-username glance --os-password localhost: 5000/v2. 0 5c13-42e8- 995a-ffb28f888d f4 octet-stream. 5c13-42e8- 995a-ffb28f888d f4. Meta-Deleted: False. Meta-Container_ format: bare. Meta-Location: swift+http:// service% 3Aglance:<redacted> @10.6.51. 191:5000/ v2.0/glance/ 2e877e45- 5c13-42e8- 995a-f fb28f888df4. Meta-Protected: False. Meta-Min_ disk: 0. Meta-Created_ at: 2013-02- 27T10:37: 24. Meta-Status: active. Meta-Is_ public: False. Meta-Min_ ram: 0. 6bc877f813244ff a1. Meta-Updated_ at: 2013-02- 27T10:37: 25. Meta-Checksum: ccad32d005750c1 005a80079b6fe8a 9f. Meta-Disk_ format: qcow2. 10.6.51. 191:9292/ v1/images/ 2e877e45- 5c13-42e8- 995a-ffb28f888d f4. 005a80079b6fe8a 9f. Request- Id: req-a854a036- 5abb-477e- a6da-69012befe2 ad. api/v1/ images. py api/v1/ images. py b/glance/ api/v1/ images. py api/v1/ images. py api/v1/ images. py (wsgi.JSONRespo nseSerializer) : location_ header( self, response, image_meta): 'location' ] image_location( image_meta) headers[ 'Location' ] = location. encode( 'utf-8' ) /bugs.launchpad .net/glance/ +bug/1135541/ +subscriptions
<email address hidden> wrote:
> Thierry,
>
> Thanks. That looks good to me.
>
> --
> You received this bug notification because you are a member of Glance
> Core, which is subscribed to the bug report.
> https:/
>
> Title:
> v1 api returns location as header for cached images
>
> Status in OpenStack Image Registry and Delivery Service (Glance):
> Triaged
>
> Bug description:
>
> When an image which is not in cache is downloaded:
>
> rm /opt/stack/
> glance --os-image-
> XXX --os-tenant-name service --os-auth-url http://
> image-download 2e877e45-
>
> The headers don't contain the backend 'location' field:
>
> T 10.6.51.191:9292 -> 10.6.51.191:52150 [AP]
> HTTP/1.1 200 OK.
> Content-Type: application/
> X-Image-Meta-Id: 2e877e45-
> X-Image-
> X-Image-
> X-Image-
> X-Image-
> X-Image-
> X-Image-
> X-Image-Meta-Size: 332.
> X-Image-
> X-Image-
> X-Image-
> X-Image-Meta-Owner: 1bc9a6b4c006433
> X-Image-
> X-Image-
> X-Image-Meta-Name: Image1.
> Location: http://
> Etag: ccad32d005750c1
> X-Openstack-
> Date: Thu, 28 Feb 2013 10:23:06 GMT.
> Transfer-Encoding: chunked.
> .
> 14c.
>
>
> But if the image is cached:
>
> glance --os-image-
> XXX --os-tenant-name service --os-auth-url http://
> image-download 2e877e45-
>
> the backend location field (with credentials) is returned as a header:
>
> T 10.6.51.191:9292 -> 10.6.51.191:51954 [AP]
> HTTP/1.1 200 OK.
> Content-Length: 332.
> Content-Type: application/
> X-Image-Meta-Id: 2e877e45-
> X-Image-
> X-Image-
> X-Image-
> X-Image-
> X-Image-
> X-Image-
> X-Image-Meta-Size: 332.
> X-Image-
> X-Image-
> X-Image-
> X-Image-Meta-Owner: 1bc9a6b4c006433
> X-Image-
> X-Image-
> X-Image-
> X-Image-Meta-Name: Image1.
> Location: http://
> Etag: ccad32d005750c1
> X-Openstack-
> Date: Thu, 28 Feb 2013 10:22:15 GMT.
> .
>
>
> A possible fix for this:
>
> $ git diff glance/
> diff --git a/glance/
> index 4b62946..fadc888 100644
> --- a/glance/
> +++ b/glance/
> @@ -933,6 +933,9 @@ class ImageSerializer
> self.notifier = notifier.Notifier()
>
> def _inject_
> + # Remove original location for security reasons
> + if 'location' in image_meta:
> + del image_meta[
> location = self._get_
> response.
>
> To manage notifications about this bug go to:
> https:/