glance --location images handling is hiding HTTP errors and uses incorrect HTTP codes...

Bug #1316137 reported by Jaroslav Henner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Rajesh Tailor
glance_store
Fix Released
Medium
Rajesh Tailor

Bug Description

1) Glance is hiding error messages when used with --location. If the URL returns HTTP 404, glance is just ignoring it.

2) Reply to GET request to http://CENSORED:9292/v1/images/2e34a168-62ca-412d-84bb-852fcaf2a391 contains header:

   location: http://CENSORED:9292/v1/images/2e34a168-62ca-412d-84bb-852fcaf2a391

which is referring the same URL. This feels weird.

3) It also replies with HTTP 200 in the case above, so why does the reply contain the "location" header?
    How can it reply 200 when it couldn't have succeed to download the image?

[root@cloudimg ~(keystone_admin)]# glance image-create --location http://www.google.com/glance_handles_404_and_other_errors_incorrectly.html --is-public False --container-format bare --disk-format qcow2 --name 404.html; echo "exit code: $?"
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | bare |
| created_at | 2014-05-05T12:42:17 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | 2e34a168-62ca-412d-84bb-852fcaf2a391 |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | 404.html |
| owner | 56be9abf0ca24193908472465157112f |
| protected | False |
| size | 0 |
| status | active |
| updated_at | 2014-05-05T12:42:17 |
+------------------+--------------------------------------+
exit code: 0

[root@cloudimg ~(keystone_admin)]# glance --debug image-download --file 404.html 404.html; echo "exit code: $?"
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
curl -i -X GET -H 'X-Auth-Token: MIIO3wYJKoZIhvcNAQcCoIIO0DC...EcKIsfbUbm5A74Gg==' -H 'Content-Type: application/json' -H 'User-Agent: python-glanceclient' http://CENSORED:9292/v1/images/detail?limit=20&name=404.html

HTTP/1.1 200 OK
date: Mon, 05 May 2014 12:44:06 GMT
content-length: 425
content-type: application/json; charset=UTF-8
x-openstack-request-id: req-d1bb2f3a-31ea-4da8-b1a5-e8a021f6e122

{"images": [{"status": "active", "name": "404.html", "deleted": false, "container_format": "bare", "created_at": "2014-05-05T12:42:17", "disk_format": "qcow2", "updated_at": "2014-05-05T12:42:17", "min_disk": 0, "protected": false, "id": "2e34a168-62ca-412d-84bb-852fcaf2a391", "min_ram": 0, "checksum": null, "owner": "56be9abf0ca24193908472465157112f", "is_public": false, "deleted_at": null, "properties": {}, "size": 0}]}

curl -i -X GET -H 'X-Auth-Token: MIIO3wYJKoZIhvcNAQcCo...EcKIsfbUbm5A74Gg==' -H 'Content-Type: application/octet-stream' -H 'User-Agent: python-glanceclient' http://CENSORED:9292/v1/images/2e34a168-62ca-412d-84bb-852fcaf2a391

HTTP/1.1 200 OK
content-length: 0
x-image-meta-id: 2e34a168-62ca-412d-84bb-852fcaf2a391
date: Mon, 05 May 2014 12:44:07 GMT
x-image-meta-deleted: False
x-image-meta-container_format: bare
x-image-meta-protected: False
x-image-meta-min_disk: 0
x-image-meta-created_at: 2014-05-05T12:42:17
x-image-meta-size: 0
x-image-meta-status: active
location: http://CENSORED:9292/v1/images/2e34a168-62ca-412d-84bb-852fcaf2a391
x-image-meta-is_public: False
x-image-meta-min_ram: 0
x-image-meta-owner: 56be9abf0ca24193908472465157112f
x-image-meta-updated_at: 2014-05-05T12:42:17
content-type: application/octet-stream
x-openstack-request-id: req-7796b7dc-476a-477d-a480-6025c874ab0e
x-image-meta-disk_format: qcow2
x-image-meta-name: 404.html

exit code: 0

[root@cloudimg ~(keystone_admin)]# hexdump 404.html -C
[root@cloudimg ~(keystone_admin)]#
[root@cloudimg ~(keystone_admin)]# du 404.html
0 404.html

Note there is no ERROR nor WARNING in the log. I am quite OK with that, but the end user should be notified with ERRORs when the glance image-download fails.

Revision history for this message
Jaroslav Henner (jhenner) wrote :

rpm -q openstack-glance
openstack-glance-2013.2.3-1.el6ost.noarch

Revision history for this message
Jaroslav Henner (jhenner) wrote :

Note there is quite related 956469

description: updated
description: updated
Changed in glance:
assignee: nobody → Rajesh Tailor (rajesh-tailor)
Changed in glance-store:
assignee: nobody → Rajesh Tailor (rajesh-tailor)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance_store (master)

Fix proposed to branch: master
Review: https://review.openstack.org/137514

Changed in glance:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

Fix proposed to branch: master
Review: https://review.openstack.org/137515

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance_store (master)

Reviewed: https://review.openstack.org/137514
Committed: https://git.openstack.org/cgit/openstack/glance_store/commit/?id=53cb5c345faa88d76b79d73e3ac4bd15da9ff8a9
Submitter: Jenkins
Branch: master

commit 53cb5c345faa88d76b79d73e3ac4bd15da9ff8a9
Author: Rajesh Tailor <email address hidden>
Date: Mon Oct 6 04:20:42 2014 -0700

    Catch NotFound exception in http.Store get_size

    Glance store doesn't catch NotFound exception in case image is not
    found and it simply returns image size as 0.

    Caught NotFound exception while getting the image_size if image
    doesn't exist in store.

    Change-Id: Ieb3dcb79ed9ba4368d0b3ca69b30095c1fd800b9
    Partial-Bug: 1316137

Changed in glance-store:
status: New → Fix Committed
Changed in glance:
milestone: none → kilo-2
Ian Cordasco (icordasc)
Changed in glance:
importance: Undecided → Medium
Thierry Carrez (ttx)
Changed in glance:
milestone: kilo-2 → kilo-3
Changed in glance-store:
importance: Undecided → Medium
milestone: none → v0.1.12
milestone: v0.1.12 → none
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/137515
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=cfa55973d9089f030585f304121f1425a8e1f356
Submitter: Jenkins
Branch: master

commit cfa55973d9089f030585f304121f1425a8e1f356
Author: Rajesh Tailor <email address hidden>
Date: Wed Oct 8 04:12:35 2014 -0700

    Raise exception if store location URL not found

    Glance doesn't catch NotFound exception when --location parameter
    is used with non-exist http store URL.

    If the URL returns HTTP 404, glance is just ignoring it and returns
    image-size as zero.

    While getting the image-size caught NotFound exception as well
    if location parameter is specified.

    Depends-On: Ieb3dcb79ed9ba4368d0b3ca69b30095c1fd800b9
    Change-Id: I9ffad7666c6e64c007c9938684903aed44e60151
    Closes-Bug: 1316137

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: kilo-3 → 2015.1.0
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.