no size check when using http to create an image
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance |
Fix Released
|
Medium
|
Zhi Yan Liu | ||
Glance Client |
Invalid
|
Undecided
|
Unassigned |
Bug Description
if I create an image from file and use --size which is smaller than the image on file we would fail with the below error:
root@opens-XXXX ~(keystone_admin)]# glance image-create --name rhevm_image --disk-format qcow2 --container-format bare --file /tmp/39f89a6a-
Request returned failure status.
400 Bad Request
Supplied size (1) and size generated from uploaded image (1440612352) did not match. Setting image status to 'killed'.
(HTTP 400)
but if I create an image from http and use a smaller size the image is created:
[root@opens-XXX ~(keystone_admin)]# glance image-create --name human --disk-format qcow2 --container-format bare --location http://
+------
| Property | Value |
+------
| checksum | None |
| container_format | bare |
| created_at | 2013-09-04T14:18:05 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | 55d45384-
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | human |
| owner | ad326a6c11a742c
| protected | False |
| size | 1B |
| status | active |
| updated_at | 2013-09-04T14:18:05 |
+------
[root@opens-XXXX ~(keystone_admin)]# glance image-list
+------
| ID | Name | Disk Format | Container Format | Size | Status |
+------
| 55d45384-
|+-----
if size is too small we should not allow the create of the image from http as well
Changed in glance: | |
status: | New → Triaged |
importance: | Undecided → Medium |
Changed in glance: | |
assignee: | nobody → Zhi Yan Liu (lzy-dev) |
Changed in glance: | |
milestone: | none → havana-rc1 |
Changed in glance: | |
status: | Fix Committed → Fix Released |
Changed in glance: | |
milestone: | havana-rc1 → 2013.2 |
This is a bit tricky.
Using location means you're telling Glance where the image *already* is. In order to verify the size, it'd be necessary to get the size from the storage backend, however, in some cases it is possible that the storage itself doesn't know the size of the image.
For example, if it's an http location, it'd necessary to send a HEAD request to the remote location (assuming the server supports it) and get the Content-Length from the response's headers but, if the response does not contain that header, then there's no other way to know the image size unless we download it locally, which is not feasible.