glance cannot find store for scheme vmware_datastore

Bug #1357462 reported by Jaroslav Henner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
High
Flavio Percoco
Icehouse
Fix Released
High
Flavio Percoco

Bug Description

 I have python-glance-2014.1.2-1.el7ost.noarch

when configuring

default_store=vmware_datastore
known_stores = glance.store.vmware_datastore.Store
vmware_server_host = 10.34.69.76
vmware_server_username=root
vmware_server_password=qum5net
vmware_datacenter_path="New Datacenter"
vmware_datastore_name=shared

glance-api doesn't seem to come up at all.
glance image-list
Error communicating with http://172.16.40.9:9292 [Errno 111] Connection refused

there seems to be nothing interesing in the logs. After changing to the

  default_store=file

  glance image-create --disk-format vmdk --container-format bare --copy-from 'http://str-02.rhev/OpenStack/cirros-0.3.1-x86_64-disk.vmdk' --name cirros-0.3.1-x86_64-disk.vmdk --is-public true --property vmware_disktype="sparse" --property vmware_adaptertype="ide" --property vmware_ostype="ubuntu64Guest" --name prdel --store vmware_datastore

or

  glance image-create --disk-format vmdk --container-format bare --file 'cirros-0.3.1-x86_64-disk.vmdk' --name cirros-0.3.1-x86_64-disk.vmdk --is-public true --property vmware_disktype="sparse" --property vmware_adaptertype="ide" --property vmware_ostype="ubuntu64Guest" --name prdel --store vmware_datastore

the image remains in queued state

I can see log lines
2014-08-15 12:38:55.885 24732 DEBUG glance.store [-] Registering store <class 'glance.store.vmware_datastore.Store'> with schemes ('vsphere',) create_stores /usr/lib/python2.7/site-packages/glance/store/__init__.py:208
2014-08-15 12:39:54.119 24764 DEBUG glance.api.v1.images [-] Store for scheme vmware_datastore not found get_store_or_400 /usr/lib/python2.7/site-packages/glance/api/v1/images.py:1057
2014-08-15 12:43:31.408 24764 DEBUG glance.api.v1.images [eac2ff8d-d55a-4e2c-8006-95beef8a0d7b caffabe3f56e4e5cb5cbeb040224fe69 77e18ad8a31e4de2ab26f52fb15b3cc1 - - -] Store for scheme vmware_datastore not found get_store_or_400 /usr/lib/python2.7/site-packages/glance/api/v1/images.py:1057

so it looks like there is inconsistency on the scheme that should be used. After hardcoding

  STORE_SCHEME = 'vmware_datastore'

in the

  /usr/lib/python2.7/site-packages/glance/store/vmware_datastore.py

the behaviour changed, but did not improve very much:

  glance image-create --disk-format vmdk --container-format bare --file 'cirros-0.3.1-x86_64-disk.vmdk' --name cirros-0.3.1-x86_64-disk.vmdk --is-public true --property vmware_disktype="sparse" --property vmware_adaptertype="ide" --property vmware_ostype="ubuntu64Guest" --name prdel --store vmware_datastore
400 Bad Request
Store for image_id not found: 7edc22ae-f229-4f21-8f7d-fa19a03410be
    (HTTP 400)

Revision history for this message
Jaroslav Henner (jhenner) wrote :
Revision history for this message
Matthew Booth (mbooth-9) wrote :

I believe that should be:

default_store=vsphere

and the known_stores entry is unnecessary, as the store is hardcoded.

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

You are probably wrong in both:

2) https://bugzilla.redhat.com/show_bug.cgi?id=1041825#c11
1) see below:

$ glance --debug image-create --copy-from FOO_BAR --name BAR_BAZ --disk-format qcow2 --container-format bare --store vmware_datastore
curl -i -X POST -H 'X-Auth-Token: ***' -H 'x-image-meta-container_format: bare' -H 'x-image-meta-store: vmware_datastore' -H 'User-Agent: python-glanceclient' -H 'x-image-meta-is_public: False' -H 'x-glance-api-copy-from: http://download.fedoraproject.org/pub/fedora/linux/updates/20/Images/x86_64/Fedora-x86_64-20-20140407-sda.qcow2' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-disk_format: qcow2' -H 'x-image-meta-name: Fedora-x86_64-20-20140407-sda' http://172.16.40.15:9292/v1/images

HTTP/1.1 201 Created
...

whereas when using --store vsphere:

$glance --debug image-create --copy-from FOO_BAR --name BAR_BAZ --disk-format qcow2 --container-format bare --store vsphere
curl -i -X POST -H 'X-Auth-Token: ***' -H 'x-image-meta-container_format: bare' -H 'x-image-meta-store: vsphere' -H 'User-Agent: python-glanceclient' -H 'x-image-meta-is_public: False' -H 'x-glance-api-copy-from: http://download.fedoraproject.org/pub/fedora/linux/updates/20/Images/x86_64/Fedora-x86_64-20-20140407-sda.qcow2' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-disk_format: qcow2' -H 'x-image-meta-name: Fedora-x86_64-20-20140407-sda' http://172.16.40.15:9292/v1/images

HTTP/1.1 400 Bad Request
date: Mon, 18 Aug 2014 16:07:28 GMT
content-length: 55
content-type: text/plain; charset=UTF-8
x-openstack-request-id: req-219408d0-406d-468f-a54d-20e8a0da6332

400 Bad Request

Required store vsphere is invalid

Request returned failure status: 400
400 Bad Request
Required store vsphere is invalid
    (HTTP 400)

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

I forgot to mention that

 * when --store vmware_datastore is used, the image is created, but it's status is queued
 * when --store vsphere is used, the behavior is the same as with --store 'asdf!@!%#'

  Required store asdf!@!%# is invalid

Revision history for this message
Matthew Booth (mbooth-9) wrote :

I believe the root cause is confusion in glance core between scheme and store name. _upload() in glance/api/v1/images.py contains:

        scheme = req.headers.get('x-image-meta-store', CONF.default_store)
        store = self.get_store_or_400(req, scheme)

The x-image-meta-store header is set with the value passed in by --store. It is validated as being the name of a store in _reserve(), which is called by create(). Note that get_known_stores() returns the list of module names which were registered as stores, which for vmware is 'vmware_datastore'.

However, in the above code it is then validated by get_store_or_400() as the name of a scheme, which it isn't. The correct scheme is 'vsphere'.

So, 'vsphere' fails validation as the name of a store, and 'vmware_datastore' fails validation as the name of a scheme. There is actually no value which can be passed to --store which will be validated by both checks.

However, note that the above code has a default of CONF.default_store, *which actually contains a scheme*. If default_store is set to vsphere and --store is not given at all, the above will validate. Also, store will not be checked in _reserve() as it will not be set.

Summary:

The fix is to work out the confusion in glance core between schemes and store names.

The workaround is to specify default_store=vsphere, and not give a store on the command line.

Changed in glance:
assignee: nobody → Flavio Percoco (flaper87)
importance: Undecided → High
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/115613

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

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

commit 4502759243c0f363545f4236b41abaf8bcf9a37b
Author: Flavio Percoco <email address hidden>
Date: Wed Aug 20 13:49:37 2014 +0200

    Check on schemes not stores

    Since the `_upload` method loads the store based on the scheme, we need
    to check whether the scheme exists in the known schemes instead of
    checking in the list of known stores. Without this fix, stores with a
    scheme name different than the store itself will not be usable through
    the `x-image-meta-store` header.

    Change-Id: Ia33afc1629cb47a31982df7932ac0d9aeb201b4f
    Closes-bug: #1357462

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

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/115890

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (stable/icehouse)

Reviewed: https://review.openstack.org/115890
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=d0453ae453adeacf19d121f08f8f9691f11f435a
Submitter: Jenkins
Branch: stable/icehouse

commit d0453ae453adeacf19d121f08f8f9691f11f435a
Author: Flavio Percoco <email address hidden>
Date: Wed Aug 20 13:49:37 2014 +0200

    Check on schemes not stores

    Since the `_upload` method loads the store based on the scheme, we need
    to check whether the scheme exists in the known schemes instead of
    checking in the list of known stores. Without this fix, stores with a
    scheme name different than the store itself will not be usable through
    the `x-image-meta-store` header.

    Conflicts:
     glance/api/v1/images.py

    Closes-bug: #1357462
    (cherry picked from commit 4502759243c0f363545f4236b41abaf8bcf9a37b)
    Change-Id: Ia33afc1629cb47a31982df7932ac0d9aeb201b4f

tags: added: in-stable-icehouse
Thierry Carrez (ttx)
Changed in glance:
milestone: none → juno-3
status: Fix Committed → Fix Released
summary: - glance cannot find store for scheme mware_datastore
+ glance cannot find store for scheme vmware_datastore
Thierry Carrez (ttx)
Changed in glance:
milestone: juno-3 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.