Nova passing bad 'size' property value 'None' to Glance for images

Bug #1487742 reported by Mike Dorman
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Zhenyu Zheng
Liberty
Fix Released
High
Matt Riedemann

Bug Description

Glance does not accept 'None' as a valid value for the 'size' property [1]. However, in certain situations Nova is sending a 'size' property with a 'None' value. This results in a 400 response from Glance to Nova, and the following backtrace in Glance:

2015-08-21 14:54:17.916 10446 TRACE glance.api.v1.images Traceback (most recent call last):
2015-08-21 14:54:17.916 10446 TRACE glance.api.v1.images File "/usr/lib/python2.7/site-packages/glance/api/v1/images.py", line 1144, in _deserialize
2015-08-21 14:54:17.916 10446 TRACE glance.api.v1.images result['image_meta'] = utils.get_image_meta_from_headers(request)
2015-08-21 14:54:17.916 10446 TRACE glance.api.v1.images File "/usr/lib/python2.7/site-packages/glance/common/utils.py", line 322, in get_image_meta_from_headers
2015-08-21 14:54:17.916 10446 TRACE glance.api.v1.images extra_msg=extra)
2015-08-21 14:54:17.916 10446 TRACE glance.api.v1.images InvalidParameterValue: Invalid value 'None' for parameter 'size': Cannot convert image size 'None' to an integer.

I believe what's happening is Nova tries to enforce certain required properties when creating or updating an image, and in the process reconciling those with the properties that Glance already has (through the _translate_from_glance() [2] and _extract_attributes() [3] methods in nova/image/glance.py)

Nova is enforcing the 'size' property being in place [4], but if Glance does not already have a 'size' property on the image (like if the image has been queued but not uploaded yet), the value gets set to 'None' on the Nova side [5]. This gets sent to Glance in subsequent calls, and it fails because 'None' cannot be converted to an integer (see backtrace above.)

Steps to Reproduce:

Nova and Glance 2015.1.1

1. Queue a new image in Glance
2. Attempt to set a metadata attribute on that image (this will fail with 400 error from Glance)
3. Actually upload the image data sometime later

Potential Solution:

I've patched this locally to simply check that the 'size' property gets set to 0 instead of 'None' on the Nova side. I am not familiar enough with all the internals here to understand if that's the "right" solution, but I can confirm it's working for us and this bug is no longer triggered.

[1] https://github.com/openstack/glance/blob/2015.1.1/glance/common/utils.py#L305-L319
[2] https://github.com/openstack/nova/blob/2015.1.1/nova/image/glance.py#L482
[3] https://github.com/openstack/nova/blob/2015.1.1/nova/image/glance.py#L533
[4] https://github.com/openstack/nova/blob/2015.1.1/nova/image/glance.py#L539
[5] https://github.com/openstack/nova/blob/2015.1.1/nova/image/glance.py#L571

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/215947

Changed in nova:
assignee: nobody → Mike Dorman (mdorman-m)
status: New → In Progress
Mike Dorman (mdorman-m)
summary: - Nova passing bad 'size' property value 'None' to Glance for image
- metadata
+ Nova passing bad 'size' property value 'None' to Glance for images
Changed in nova:
assignee: Mike Dorman (mdorman-m) → Zhenyu Zheng (zhengzhenyu)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/215947
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=cc7f0bc038915c2a765bcdd17342ad12ac92e43c
Submitter: Jenkins
Branch: master

commit cc7f0bc038915c2a765bcdd17342ad12ac92e43c
Author: Mike Dorman <email address hidden>
Date: Sat Aug 22 10:00:16 2015 -0700

    Ensure Glance image 'size' attribute is 0, not 'None'

    Make sure that if the 'size' attribute for an image does not
    exist in Glance, that we set the value to 0 and not 'None'.
    Glance does not accept 'None' as a valid value for the 'size'
    attribute.

    Co-Authored-By:Kevin_Zheng<email address hidden>

    Change-Id: I8c6a8749d86a22eb2d2e1e84ce6a2b9a4a4992ee
    Closes-bug: 1487742

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/liberty)

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/272536

Matt Riedemann (mriedem)
Changed in nova:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/liberty)

Reviewed: https://review.openstack.org/272536
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=14440aabf49c7169366166dc347070e38a211c2d
Submitter: Jenkins
Branch: stable/liberty

commit 14440aabf49c7169366166dc347070e38a211c2d
Author: Mike Dorman <email address hidden>
Date: Sat Aug 22 10:00:16 2015 -0700

    Ensure Glance image 'size' attribute is 0, not 'None'

    Make sure that if the 'size' attribute for an image does not
    exist in Glance, that we set the value to 0 and not 'None'.
    Glance does not accept 'None' as a valid value for the 'size'
    attribute.

    Co-Authored-By:Kevin_Zheng<email address hidden>

    Change-Id: I8c6a8749d86a22eb2d2e1e84ce6a2b9a4a4992ee
    Closes-bug: 1487742
    (cherry picked from commit cc7f0bc038915c2a765bcdd17342ad12ac92e43c)

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.