image is creating with option size= a negative number

Bug #1260738 reported by anju Tiwari
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
David Koo

Bug Description

I just try to create an image by giving size =-1
and the image is creating succesfully.

 glance image-create --name cirros --is-public true --container-format bare --disk-format qcow2 --location https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk --size -1

+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | bare |
| created_at | 2013-12-13T13:48:07 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | 2da4e4f9-5f1a-4c8d-a67c-272588e2efbc |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 6a2db75adb964c5b84010fa22b464715 |
| protected | False |
| size | -1 |
| status | active |
| updated_at | 2013-12-13T13:48:38 |
+------------------+--------------------------------------+

Changed in glance:
assignee: nobody → anju Tiwari (anjutiwari5)
Feilong Wang (flwang)
Changed in glance:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
David Koo (kpublicmail) wrote :

Hi Anju,

What's the status of this but - are you still working on this?

Revision history for this message
David Koo (kpublicmail) wrote :
Download full text (7.2 KiB)

A few more notes: It seems this "bug" occurs only when the image specified by "--location" doesn't exist. If the location exists and I try to create an image with negative size:

glance --os-image-api-version 1 --os-auth-token $(cat ~/user-token) --os-image-url http://127.0.0.1:9292 image-create --is-public true --name negSize --container-format bare --disk-format qcow2 --location http://127.0.0.1:8000/testImg.qcow2 --size -1

Request returned failure status.
409 Conflict
Provided image size must match the stored image size. (provided size: -1, stored size: 16777216)
    (HTTP 409)

But if the image does NOT exist:

glance --os-image-api-version 1 --os-auth-token $(cat ~/user-token) --os-image-url http://127.0.0.1:9292 image-create --is-public true --name negSize --container-format bare --disk-format qcow2 --location http://127.0.0.1:8000/notexists.qcow2 --size -1

+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | bare |
| created_at | 2013-12-24T03:20:21 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | 710a13eb-d791-472a-8531-948b99aaa2e6 |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | negSize |
| owner | 0ab96bc02dd34b319d0e6c2f36b83cfe |
| protected | False |
| size | -1 |
| status | active |
| updated_at | 2013-12-24T03:20:22 |
+------------------+--------------------------------------+

Incidentally, if I now try to download the image I get a 500 error:

glance --os-auth-token $(cat ~/user-token) --os-image-url http://127.0.0.1:9292 image-download --file /dev/null 710a13eb-d791-472a-8531-948b99aaa2e6

Request returned failure status.
HTTPInternalServerError (HTTP 500)

The server logs show an error:

 DEBUG [glance.registry.client.v1.client:117] Registry request GET /images/710a13eb-d791-472a-8531-948b99aaa2e6 HTTP 200 request id req-ad09b5d2-4c39-444e-b9e3-80ef523b0278
 DEBUG [glance.store.http:168] HTTP URL returned a 404 status code.
  INFO [glance.wsgi.server:493] Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 389, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/home/koo/stack/glance/glance/common/wsgi.py", line 367, ...

Read more...

Revision history for this message
David Koo (kpublicmail) wrote :

Forgot to mention: the crash happens only if the image specified by --location doesn't exist AND the size is negative.

David Koo (kpublicmail)
Changed in glance:
assignee: anju Tiwari (anjutiwari5) → David Koo (kpublicmail)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

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

commit f924943f250b52522a9285410d076d3567199c0f
Author: David Koo <email address hidden>
Date: Thu Dec 26 10:37:07 2013 +0800

    Disallow negative image sizes

    Currently Glance v1 allows creation of images with negative sizes when
    the source URL provided by the --location parmeter does not exist at
    the time of creation.

    There is already a check to verify whether or not an image size can be
    converted to an int but the check doesn't verify whether or not the
    resulting value is >= 0. This commit supplements that check to
    disallow negative values for the size parameter.

    Change-Id: I47511f3e34cf5adfdf944747d94285ecbbda4249
    Closes-Bug: #1260738

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
milestone: none → icehouse-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: icehouse-2 → 2014.1
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.