GET /v2/images/UUID can't handle metadata with extra properties

Bug #1039525 reported by Akira Yoshiyama
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Invalid
Undecided
Unassigned

Bug Description

Summary
=======

On cinder folsom-3, create-image-from-image doesn't work because of a python-glanceclient bug.

Error Message (cinder-volume)
=============================

[-] Exception during message handling
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/cinder-2012.2-py2.7.egg/cinder/openstack/common/rpc/amqp.py", line 275, in _process_data
    rval = self.proxy.dispatch(ctxt, version, method, **args)
  File "/usr/local/lib/python2.7/dist-packages/cinder-2012.2-py2.7.egg/cinder/openstack/common/rpc/dispatcher.py", line 145, in dispatch
    return getattr(proxyobj, method)(ctxt, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/cinder-2012.2-py2.7.egg/cinder/volume/manager.py", line 153, in create_volume
    volume_ref['id'], {'status': 'error'})
  File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/cinder-2012.2-py2.7.egg/cinder/volume/manager.py", line 137, in create_volume
    image_location = image_service.get_location(context, image_id)
  File "/usr/local/lib/python2.7/dist-packages/cinder-2012.2-py2.7.egg/cinder/image/glance.py", line 194, in get_location
    _reraise_translated_image_exception(image_id)
  File "/usr/local/lib/python2.7/dist-packages/cinder-2012.2-py2.7.egg/cinder/image/glance.py", line 192, in get_location
    image_meta = client.call(context, 2, 'get', image_id)
  File "/usr/local/lib/python2.7/dist-packages/cinder-2012.2-py2.7.egg/cinder/image/glance.py", line 122, in call
    return getattr(client.images, method)(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/python_glanceclient-0.4.2-py2.7.egg/glanceclient/v2/images.py", line 58, in get
    return self.model(**body)
  File "/usr/local/lib/python2.7/dist-packages/warlock-0.1.0-py2.7.egg/warlock/core.py", line 37, in __init__
    raise ValueError()
ValueError

tcpick log (port 9292)
======================

JSON schema
-----------

GET /v2/schemas/image HTTP/1.1
Host: 127.0.0.1:9292
Accept-Encoding: identity
X-Auth-Token: 5dbbea713c5a4e078ffb8b62834259d5
Content-Type: application/json
User-Agent: python-glanceclient

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 2156
X-Openstack-Request-Id: req-ae192109-7b0f-4fcb-a708-ebe167ee7fc3
Date: Tue, 21 Aug 2012 15:42:57 GMT

{"additionalProperties": {"type": "string"}, "name": "image", "links": [{"href": "{self}", "rel": "self"}, {"href": "{file}",
 "rel": "enclosure"}, {"href": "{schema}", "rel": "describedby"}], "properties": {"status": {"enum": ["queued", "saving", "ac
tive", "killed", "deleted", "pending_delete"], "type": "string", "description": "Status of the image"}, "format": {"required"
: true, "type": "string", "description": "The format code for the image", "enum": ["raw", "vhd", "vmdk", "vdi", "qcow2", "qed
"]}, "name": {"type": "string", "description": "Descriptive name for the image", "maxLength": 255}, "tags": {"items": {"type"
: "string", "maxLength": 255}, "type": "array", "description": "List of strings related to the image"}, "checksum": {"type":
"string", "description": "md5 hash of image contents.", "maxLength": 32}, "created_at": {"type": "string", "description": "Da
te and time of image registration"}, "size": {"type": "integer", "description": "Size of image file in bytes"}, "disk_format"
: {"enum": ["raw", "vhd", "vmdk", "vdi", "iso", "qcow2", "aki", "ari", "ami"], "type": "string", "description": ""}, "updated
_at": {"type": "string", "description": "Date and time of the last image modification"}, "visibility": {"enum": ["public", "p
rivate"], "type": "string", "description": "Scope of image accessibility"}, "id": {"type": "string", "description": "An ident
ifier for the image", "maxLength": 36}, "protected": {"type": "boolean", "description": "If true, image will not be deletable
."}, "min_ram": {"type": "integer", "description": "Amount of ram (in MB) required to boot image."}, "file": {"type": "string"}, "container_format": {"enum": ["bare", "ovf", "ami", "aki", "ari"], "type": "string", "description": ""}, "min_disk": {"type": "integer", "description": "Amount of disk space (in GB) required to boot image."}, "direct_url": {"type": "string", "description": "URL to access the image file kept in external store"}, "type": {"required": true, "type": "string", "description": "The type code for the image", "enum": ["kernel", "ramdisk", "filesystem", "iso9660", "disk"]}, "self": {"type": "string"}, "schema": {"type": "string"}}}

Image metadata
--------------

GET /v2/images/9cc4151b-9d0d-4976-9c7f-99273bd011e8 HTTP/1.1
Host: 127.0.0.1:9292
Accept-Encoding: identity
X-Auth-Token: 5dbbea713c5a4e078ffb8b62834259d5
Content-Type: application/json
User-Agent: python-glanceclient

HTTP/1.1 200 OK
Content-Length: 627
Content-Type: application/json; charset=UTF-8
X-Openstack-Request-Id: req-719a41be-1840-4b6b-9481-e7525e91db62
Date: Tue, 21 Aug 2012 15:42:57 GMT

{"status": "active", "name": "centos.5-3", "tags": [], "kernel_id": "f01fb9ab-8110-4cd1-a2f2-57b9a88e23e0", "container_format": "ami", "created_at": "2012-08-18T22:32:15Z", "ramdisk_id": "c6f2527e-b0e8-47ec-9765-f1d1141331c9", "disk_format": "ami", "updated_at": "2012-08-18T22:34:18Z", "visibility": "public", "id": "9cc4151b-9d0d-4976-9c7f-99273bd011e8", "protected": false, "min_ram": 0, "file": "/v2/images/9cc4151b-9d0d-4976-9c7f-99273bd011e8/file", "checksum": "79523e49084752f61b49398b19831b23", "min_disk": 0, "size": 1049624576, "self": "/v2/images/9cc4151b-9d0d-4976-9c7f-99273bd011e8", "schema": "/v2/schemas/image"}

---

The schema doesn't have definitions for "kernel_id" and "ramdisk_id", so that validation failed.

Related commit
==============

* Add 'explain' command to v2 that describes schemas
  7f48506781ea1a50ed7760c41a34474f91979f06
* Replace static v2 Image model with warlock model
  c398af18b0b8fb5fb075be22563812e179290b2a

Solution
========

I think there are solutions:

a) Add kernel_id, ramdisk_id and other extra properties to schema.
b) Add 'extra_properties' to schema and make them its sub-properties.
c) Remove extra properties from result of that GET request.

Revision history for this message
Akira Yoshiyama (yosshy) wrote :

Extra solution
=============

d) Add extra definitions to /etc/glance/schema-image.json.
I'm using this.

{
    "kernel_id": {
        "type": "string",
        "description": "An identifier for the linked kernel image",
        "maxLength": 36,
        "required": false
    },
    "ramdisk_id": {
        "type": "string",
        "description": "An identifier for the linked ramdisk image",
        "maxLength": 36,
        "required": false
    }
}

Revision history for this message
Akira Yoshiyama (yosshy) wrote :

I replaced /etc/glance/schema-image.json with default one and no problem occured.
Sorry, perhaps that one of glance folsom-2 remained and "type" definithion worked.

Changed in glance:
status: New → Invalid
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Two things:

1) the boolean allow_additional_image_properties conf option controls whether users can add arbitrary image properties to an image - in this case, kernel_id and ramdisk_id are considered 'arbitrary' as they are not part of Glance

2) You should be careful using the v2 API, as it is still experimental and we aren't making any guarantees yet.

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.