← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1487742] [NEW] Nova passing bad 'size' property value 'None' to Glance for image metadata

 

Public bug reported:

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

** Affects: nova
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1487742

Title:
  Nova passing bad 'size' property value 'None' to Glance for image
  metadata

Status in OpenStack Compute (nova):
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1487742/+subscriptions


Follow ups