glance image-create with invalid store fails but still creates image

Bug #1260314 reported by John Lenihan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Yanis Guenane

Bug Description

glance checks whether or not a specified store is valid, but if it is invalid the image has already been created.

I pulled the latest devstack code and then ran these commands after sourcing openrc:

ubuntu@devstack-glance:/mnt/devstack$ glance index
ID Name Disk Format Container Format Size
------------------------------------ ------------------------------ -------------------- -------------------- --------------
6792e9a7-f4f8-48cb-b407-80e360b8a773 cirros-0.3.1-x86_64-uec ami ami 25165824
7808c034-3fdd-4975-af26-e7d5a15d2113 cirros-0.3.1-x86_64-uec-ramdis ari ari 3714968
4efcddb2-9f20-413f-86a3-3bf69455e09b cirros-0.3.1-x86_64-uec-kernel aki aki 4955792
ubuntu@devstack-glance:/mnt/devstack$
ubuntu@devstack-glance:/mnt/devstack$ glance -d image-create --store s3e --disk-format raw --container-format bare --name complete_gibberish </etc/hosts
curl -i -X POST -H 'x-image-meta-container_format: bare' -H 'Transfer-Encoding: chunked' -H 'x-image-meta-store: s3e' -H 'User-Agent: python-glanceclient' -H 'x-image-meta-size: 221' -H 'x-image-meta-is_public: False' -H 'X-Auth-Token: <redacted_token>' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-disk_format: raw' -H 'x-image-meta-name: complete_gibberish' -d '<open file '<stdin>', mode 'r' at 0x7f16181b6150>' http://10.4.36.1:9292/v1/images

HTTP/1.1 400 Bad Request
date: Thu, 12 Dec 2013 12:47:37 GMT
content-length: 52
content-type: text/plain; charset=UTF-8
x-openstack-request-id: req-c9bad6ee-d79c-41f3-bd96-d3929afd742c

400 Bad Request

Store for scheme s3e not found

Request returned failure status.
400 Bad Request
Store for scheme s3e not found
    (HTTP 400)
ubuntu@devstack-glance:/mnt/devstack$ glance index
ID Name Disk Format Container Format Size
------------------------------------ ------------------------------ -------------------- -------------------- --------------
b26c03e4-7cdf-44fe-9187-7de315c9b38b complete_gibberish raw bare 221
6792e9a7-f4f8-48cb-b407-80e360b8a773 cirros-0.3.1-x86_64-uec ami ami 25165824
7808c034-3fdd-4975-af26-e7d5a15d2113 cirros-0.3.1-x86_64-uec-ramdis ari ari 3714968
4efcddb2-9f20-413f-86a3-3bf69455e09b cirros-0.3.1-x86_64-uec-kernel aki aki 4955792

This problem occurs using the v1 API. If using the V2 API the '--store' option does not seem to be present.

Changed in glance:
assignee: nobody → Yanis Guenane (yanis-guenane)
status: New → Confirmed
Revision history for this message
Yanis Guenane (yanis-guenane) wrote :

This happens because the validity of the --store parameter is never checked, only the scheme's value in the location (ie. s3://toto -> s3)

Revision history for this message
Yanis Guenane (yanis-guenane) wrote :

I was wrong it is checked but after _reserve have been done thus the creation of the image.

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/61848

Changed in glance:
status: Confirmed → In Progress
Zhi Yan Liu (lzy-dev)
Changed in glance:
importance: Undecided → Medium
Changed in glance:
milestone: none → icehouse-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

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

commit a7e977bfd46ffc932f32f7e4e5a60ea3db4ed574
Author: Yanis Guenane <email address hidden>
Date: Thu Dec 12 19:12:14 2013 +0000

    Check --store parameter validity before _reserve

    Currently the value of the --store parameter is checked after the call
    to _reserve is made. Thus the image is actually created on the
    database even though the store is invalid, and then returns a E400.

    Change-Id: Ic27ed30e605794342161530e8a8eacd6e6deb5d9
    Closes-bug: #1260314

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: icehouse-3 → 2014.1
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.