Missing container format error not properly reported by image-create command

Bug #1029272 reported by Mark McLoughlin
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Glance Client
Invalid
Medium
Unassigned

Bug Description

I tried:

  $> glance image-create --name f17netinst --disk-format iso < ../Fedora-17-i386-netinst.iso

and simply got:

  Bad request (HTTP 400)

Looking at the response on the wire, the error is more obvious:

  Failed to update image metadata. Got error: Invalid container format 'None' for image.

Brian Waldon (bcwaldon)
Changed in python-glanceclient:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Iccha Sethi (iccha-sethi) wrote :

right now the glance image-create does not give a bad request when disk_format or container_format is not specified, but the curl request gives a bad request if they are not specified.

In both cases the image is created.

Revision history for this message
Iccha Sethi (iccha-sethi) wrote :

curl request:

curl -i -X POST -H 'User-Agent: python-glanceclient' -H 'x-image-meta-is_public: False' -H 'Content-Type: application/octet-stream' -H 'X-Auth-Token: 3bd38d82e9774ae3857781a20a71b26d' -H 'x-image-meta-name: test_image1' -d 'None' http://184.106.106.164:9292/v1/images
HTTP/1.1 400 Bad Request
Content-Length: 163
Content-Type: text/html; charset=UTF-8
X-Openstack-Request-Id: req-7a18beb5-0fbf-4b38-8472-cfc5b7002bd5
Date: Sun, 28 Oct 2012 18:23:18 GMT

<html>
 <head>
  <title>400 Bad Request</title>
 </head>
 <body>
  <h1>400 Bad Request</h1>
  Invalid disk format 'None' for image.<br /><br />

 </body>
</html>

------------------
Glance client:

 glance --debug image-create --name test_image1
curl -i -X POST -H 'User-Agent: python-glanceclient' -H 'x-image-meta-is_public: False' -H 'Content-Type: application/octet-stream' -H 'X-Auth-Token: 3bd38d82e9774ae3857781a20a71b26d' -H 'x-image-meta-name: test_image1' -d 'None' http://184.106.106.164:9292/v1/images

HTTP/1.1 201 Created
date: Sun, 28 Oct 2012 17:50:50 GMT
content-length: 420
content-type: application/json
location: http://184.106.106.164:9292/v1/images/6d860ecd-d2bb-4179-b762-2789a605740c
x-openstack-request-id: req-75ef9e5d-9d67-4643-ab2c-0c5dba2aec91

{"image": {"status": "queued", "name": "test_image1", "deleted": false, "container_format": null, "created_at": "2012-10-28T17:50:50", "disk_for
mat": null, "updated_at": "2012-10-28T17:50:50", "properties": {}, "min_disk": 0, "protected": false, "id": "6d860ecd-d2bb-4179-b762-2789a605740
c", "checksum": null, "owner": "11f68f66abd04e8d9fd268d2056bd9c6", "is_public": false, "deleted_at": null, "min_ram": 0, "size": 0}}

+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | None |
| created_at | 2012-10-28T17:50:50 |
| deleted | False |
| deleted_at | None |
| disk_format | None |
| id | 6d860ecd-d2bb-4179-b762-2789a605740c |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | test_image1 |
| owner | 11f68f66abd04e8d9fd268d2056bd9c6 |
| protected | False |
| size | 0 |
| status | queued |
| updated_at | 2012-10-28T17:50:50 |
+------------------+--------------------------------------+

Revision history for this message
Iccha Sethi (iccha-sethi) wrote :

glance image-create --name f17netinst --disk-format iso
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | None |
| created_at | 2012-10-28T17:55:24 |
| deleted | False |
| deleted_at | None |
| disk_format | iso |
| id | f33c7b99-a3fb-4123-a356-b97967143154 |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | f17netinst |
| owner | 11f68f66abd04e8d9fd268d2056bd9c6 |
| protected | False |
| size | 0 |
| status | queued |
| updated_at | 2012-10-28T17:55:24 |
+------------------+--------------------------------------+

Revision history for this message
Iccha Sethi (iccha-sethi) wrote :

Do we want we the curl req and client to be same? or is the difference intended?
PS: This represents the case where no data is given, unlike the command for which the bug is filed.

Revision history for this message
Patrick Cheung (cheungpat) wrote :

I have a similar problem.

$ glance --debug --verbose -k image-create --name "boo" --container-format bare --disk-format raw < boo
curl -i -X POST -H 'x-image-meta-container_format: bare' -H 'User-Agent: python-glanceclient' -H 'x-image-meta-size: 110103' -H 'x-image-meta-is_public: False' -H 'X-Auth-Token: 00000000000000000000000000000000' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-disk_format: raw' -H 'x-image-meta-name: boo' -k -d '<open file '<stdin>', mode 'r' at 0x7f5971a7c0c0>' https://image.example.com:9292/v1/images

The result is a 400 Bad Request with error "Invalid disk format 'None' for image."

Notice that the curl command has underscore instead of hyphen in a few headers name (x-image-meta-container_format, x-image-meta-is_public, x-image-meta-disk_format). If I change them back to underscores, the command succeeds:

$ curl -i -X POST -H 'x-image-meta-container-format: bare' -H 'User-Agent: python-glanceclient' -H 'x-image-meta-size: 110103' -H 'x-image-meta-is-public: False' -H 'X-Auth-Token: 00000000000000000000000000000000' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-disk-format: raw' -H 'x-image-meta-name: boo' -k -d @boo https://boo.example.com:9292/v1/images

The returned JSON string is:

{"image": {"status": "active", "name": "boo", "deleted": false, "container_format": "bare", "created_at": "2012-11-07T06:48:11", "disk_format": "raw", "updated_at": "2012-11-07T06:48:12", "properties": {}, "min_disk": 0, "protected": false, "id": "08df5d5c-9399-4324-ae19-c8142649ff49", "checksum": "f8413ccc0d1fe47f50be369cb1930c28", "owner": "00000000000000000000000000000000", "is_public": false, "deleted_at": null, "min_ram": 0, "size": 107628}}

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Patrick - I believe that's a bit of a red herring. The headers are intended to be of the format 'x-image-meta-XXX' where the XXX can be replaced with anything (almost).

Iccha - I would expect the command to give me a reasonable failure message.

With that said, I don't think there's an easy way to parse out that error message. I think we first need to produce a parseable error format from Glance, then we can think about presenting it properly.

Revision history for this message
Jon Bernard (jbernard) wrote :
yatin (yatinkarel)
Changed in python-glanceclient:
assignee: nobody → yatin (yatinkarel)
yatin (yatinkarel)
Changed in python-glanceclient:
assignee: yatin (yatinkarel) → nobody
Revision history for this message
Darja Shakhray (dshakhray) wrote :
Revision history for this message
Darja Shakhray (dshakhray) wrote :

Example:
glance image-create --name f17netinst --disk-format iso < file
error: Must provide --container-format when using stdin.

Changed in python-glanceclient:
status: Triaged → Fix Committed
Revision history for this message
Kairat Kushaev (kkushaev) wrote :

Not valid anymore for both V1 and V2.
V1:
1) glance --debug image-create --name test_image1
curl -g -i -X POST -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'X-Auth-Token: {SHA1}5bf44242df58c2b1ccf2427a86fecb753e4a6652' -H 'Connection: keep-alive' -H 'x-image-meta-is_public: None' -H 'User-Agent: python-glanceclient' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-name: test_image1' http://192.168.122.191:9292/v1/images

result - HTTP/1.1 201 Created

2) curl -g -i -X POST -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'X-Auth-Token: e58f516402b94859919d306c52bf2336' -H 'Connection: keep-alive' -H 'x-image-meta-is_public: None' -H 'User-Agent: python-glanceclient' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-name: test_image1' http://192.168.122.191:9292/v1/images

result - HTTP/1.1 201 Created

I am marking this as Invalid.

Changed in python-glanceclient:
status: Fix Committed → Invalid
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.