Comment 0 for bug 1323660

Revision history for this message
Bart Wensley (bartwensley) wrote : Glance image properties not copied to cinder volume with glance V2 API

When a cinder volume is created from a glance image, the "properties" attached to the glance image are not copied to the cinder volume (in the volume_image_metadata) if the glance V2 API is used. If the glance V1 API is used, the properties are copied correctly.

To illustrate, here is a glance image with a hw_vif_model property defined:

[root@controller-0 log(keystone_admin)]# glance image-show wrl5-avp
+-------------------------+--------------------------------------+
| Property | Value |
+-------------------------+--------------------------------------+
| Property 'hw_vif_model' | avp |
| checksum | 2386997c1a85709759c3d26ba0f11192 |
| container_format | bare |
| created_at | 2014-05-23T15:25:01.804247 |
| deleted | False |
| disk_format | raw |
| id | 78e935d4-3b8e-4cc4-ab9f-c24959492c22 |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | wrl5-avp |
| owner | 376000978ffb43159aa3ec554d62b7df |
| protected | False |
| size | 507510784 |
| status | active |
| updated_at | 2014-05-23T15:25:03.852936 |
+-------------------------+--------------------------------------+

When a volume is created (using glance V1 API) from this image (with "cinder create --image-id 2386997c1a85709759c3d26ba0f11192 --display-name=wrl5-avp-from-volume 1"), the volume_image_metadata for the resulting volume is:
{u'container_format': u'bare', u'min_ram': u'0', u'hw_vif_model': u'avp', u'disk_format': u'qcow2', u'image_name': u'wrl5-avp', u'image_id': u'8f1b7941-cbac-484e-8ef4-5714e01f5c66', u'checksum': u'2386997c1a85709759c3d26ba0f11192', u'min_disk': u'0', u'size': u'507510784'}

When a volume is created using the glance V2 API, the volume_image_metadata is missing the hw_vif_model:
{u'container_format': u'bare', u'min_ram': u'0', u'disk_format': u'qcow2', u'image_name': u'wrl5-avp', u'image_id': u'8f1b7941-cbac-484e-8ef4-5714e01f5c66', u'checksum': u'2386997c1a85709759c3d26ba0f11192', u'min_disk': u'0', u'size': u'507510784'}

With debug logs turned on, the results of the image get from glance are different. For the glance V1 API:

May 25 12:49:48 localhost 2014-05-25 12:49:48.221 1773 DEBUG glanceclient.common.http [-] HTTP/1.1 200 OK content-length: 0 x-image-meta-status: active x-image-meta-owner: 621793db5e664ca390af686640b24543 x-image-meta-name: wrl5-avp x-image-meta-container_format: bare x-image-meta-created_at: 2014-05-22T17:59:05.446468 etag: 2386997c1a85709759c3d26ba0f11192 location: http://192.168.204.2:9292/v1/images/8f1b7941-cbac-484e-8ef4-5714e01f5c66 x-image-meta-min_ram: 0 x-image-meta-updated_at: 2014-05-22T17:59:11.446979 x-image-meta-id: 8f1b7941-cbac-484e-8ef4-5714e01f5c66 date: Sun, 25 May 2014 12:49:48 GMT x-openstack-request-id: req-884ad959-fe85-4653-81e9-97a9205db3b8 x-image-meta-deleted: False x-image-meta-checksum: 2386997c1a85709759c3d26ba0f11192 x-image-meta-property-hw_vif_model: avp x-image-meta-protected: False x-image-meta-min_disk: 0 x-image-meta-size: 507510784 x-image-meta-is_public: True content-type: text/html; charset=UTF-8 x-image-meta-disk_format: qcow2 log_http_response /usr/lib64/python2.7/site-packages/glanceclient/common/http.py:152

With the glance V2 API:

May 25 12:07:15 localhost 2014-05-25 12:07:15.589 12689 DEBUG glanceclient.common.http [-] HTTP/1.1 200 OK date: Sun, 25 May 2014 12:07:15 GMT content-length: 543 content-type: application/json; charset=UTF-8 x-openstack-request-id: req-5c8b6f6c-0880-4054-ba03-4fc89326f64e {"status": "active", "name": "wrl5-avp", "tags": [], "container_format": "bare", "created_at": "2014-05-22T17:59:05Z", "hw_vif_model": "avp", "disk_format": "qcow2", "updated_at": "2014-05-22T17:59:11Z", "visibility": "public", "self": "/v2/images/8f1b7941-cbac-484e-8ef4-5714e01f5c66", "protected": false, "id": "8f1b7941-cbac-484e-8ef4-5714e01f5c66", "file": "/v2/images/8f1b7941-cbac-484e-8ef4-5714e01f5c66/file", "checksum": "2386997c1a85709759c3d26ba0f11192", "min_disk": 0, "size": 507510784, "min_ram": 0, "schema": "/v2/schemas/image"} log_http_response /usr/lib64/python2.7/site-packages/glanceclient/common/http.py:152

The difference (other than the switch to the json encoding) is that the hw_vif_model is returned as a property in the V1 case and returned as a regular field in the V2 case. From a look at the cinder code, I suspect that the problem happens because the _extract_attributes function (in cinder/image/glance.py) is using a whitelist to copy certain attributes and then copying the "properties" from the image transparently. In the case of the glance V2 API, the hw_vif_model isn't a "property", so it isn't getting copied. Here is the code (from Havana):

def _extract_attributes(image):
    IMAGE_ATTRIBUTES = ['size', 'disk_format', 'owner',
                        'container_format', 'checksum', 'id',
                        'name', 'created_at', 'updated_at',
                        'deleted_at', 'deleted', 'status',
                        'min_disk', 'min_ram', 'is_public']
    output = {}
    for attr in IMAGE_ATTRIBUTES:
        output[attr] = getattr(image, attr, None)

    output['properties'] = getattr(image, 'properties', {})

    return output

I don't know why the glance V2 API is returning the properties as regular attributes, but I expect that is what is causing the problem.

I am testing this in Havana, using the Ceph backend, but I don't expect the backend matters here.