← Back to team overview

openstack team mailing list archive

Re: [Glance]: which part of the source codes handle the receiving of the upload image data

 

On 02/17/2012 04:08 AM, benzwt benzwt wrote:
Hi Glance guys,

Hi Reynolds!

I'm not good in WSGI. I have a foolish question to ask.
Which part of the source codes handle the receiving of the uploading data.

The receiver of the uploaded data is the webob.Request object that is constructed on the Glance API server (within the eventlet that picks up the socket connection associated with a client HTTP request).

As far as I know, the uploading data is in body_file from webob. I
traced the webob
code but it made my head blowed.

Heh, yeah, it's a bit funky. :) More below...

--->  send chunked data ->    | (webob)  this mechanism is unclear to
me| --->  body_file

Would somebody kindly give a guide on this issue ?

Well, I would say my words of advice would be to avoid making any calls that end up calling the webob.Request.make_body_seekable() method (or setting the is_body_seekable attribute). Doing so will make webob.Request attempt to read the entire request body into memory (a StringIO object) in an attempt to determine the length of the request body if it is not known (as used to be the case with certain chunked transfer requests that the Glance client used to use -- it now always calculates the content length on the client side to avoid this possibility).

What Glance does is pass the webob.Request.body_file attribute off to the backend storage driver object, and that storage driver either uses the body_file attribute as-is (see /glance/store/filesystem.py) or wraps that body_file attribute in a custom reader object that allows the driver to read and track chunks of incoming request data without seeking to the end fo the body_file (see above for problems with doing that...) or writing chunks of the incoming request body to disk. See the Swift driver in /glance/store/swift.py for how that is done.

Best,
-jay


References