[Openstack] Glance API semantics when image sizes aren't known

Jay Pipes jaypipes at gmail.com
Tue Nov 15 21:36:27 UTC 2011


On Tue, Nov 15, 2011 at 4:28 PM, Ewan Mellor <Ewan.Mellor at eu.citrix.com> wrote:
>> -----Original Message-----
>> From: Jay Pipes [mailto:jaypipes at gmail.com]
>> Sent: Tuesday, November 15, 2011 12:45 PM
>> To: Ewan Mellor
>> Cc: openstack at lists.launchpad.net
>> Subject: Re: [Openstack] Glance API semantics when image sizes aren't
>> known
>>
>> On Tue, Nov 15, 2011 at 3:37 PM, Ewan Mellor
>> <Ewan.Mellor at eu.citrix.com> wrote:
>> >> From: Jay Pipes [mailto:jaypipes at gmail.com]
>> >>
>> >> The else: block is ONLY met when you are not using the Python glance
>> >> client, the glance CLI tool, and are not setting either the
>> >> Content-Length or X-Image-Meta-Size header. If you use the Python
>> >> glance client or CLI tool, the image you are feeding to the client
>> >> automatically does a seek/tell to determine the size of the image
>> you
>> >> are uploading.
>> >
>> > Or if you're using something that can't seek/tell, like a stream.  In
>> > that case, you get neither a Content-Length nor an X-Image-Meta-Size.
>> > Hence my question.
>>
>> And hence my answer ;)
>
> I don't think you answered the question.  My question was, what is the intended behavior when given a request that doesn't have either X-Image-Meta-Size or Content-Length set?

It depends. If you are just reserving/registering image metadata,
Glance will happily store 0, Content-Length or X-Image-Meta-Size.

On upload, once an image file is successfully uploaded to the backend
store, Glance will set the image's size to the number of bytes that
the backend store reported that it wrote.

On uploading an image when Swift is the backing store, Glance does its
best to upload the image file if no Content-Length or
X-Image-Meta-Size is specified, but on the event of a failed Swift
upload, the image size does not get set.

> Because the docs imply that the size will be inferred from the body of the upload request, but that's not what is happening in the Swift backend.

Would it be possible to paste the code you are using to do the upload?

Cheers,
-jay




More information about the Openstack mailing list