I was able to pin down the image upload problem today: The Store.add file input read loop using chunkreadable throws an error on the very last read. Apparently the mod_wsgi.Input behaves differently than its eventlet counterpart in that it throws an error if the requested data length is greater than what is avalible. When I replaced the chunkreadable for loop with a while loop that modified the size of the last data read request, it works. Does anyone know if this is a code bug or rather a WSGI configuration setting that I missed?
Regards, Mark ------- I made the following chages to file /usr/lib/python2.7/dist-packages/glance/store/filesystem.py: def add(self, image_id, image_file, image_size): """ Stores an image file with supplied identifier to the backend storage system and returns a tuple containing information about the stored image. :param image_id: The opaque image identifier :param image_file: The image data to write, as a file-like object :param image_size: The size of the image data to write, in bytes :retval tuple of URL in backing store, bytes written, and checksum :raises `glance.common.exception.Duplicate` if the image already existed :note By default, the backend writes the image data to a file `/<DATADIR>/<ID>`, where <DATADIR> is the value of the filesystem_store_datadir configuration option and <ID> is the supplied image ID. """ filepath = os.path.join(self.datadir, str(image_id)) if os.path.exists(filepath): raise exception.Duplicate(_("Image file %s already exists!") % filepath) checksum = hashlib.md5() bytes_written = 0 bytes_to_read = ChunkedFile.CHUNKSIZE try: with open(filepath, 'wb') as f: while bytes_written < image_size: if (image_size - bytes_written) < ChunkedFile.CHUNKSIZE: bytes_to_read = image_size - bytes_written buf = image_file.read(bytes_to_read) bytes_written += len(buf) checksum.update(buf) f.write(buf) """ for buf in utils.chunkreadable(image_file, ChunkedFile.CHUNKSIZE): bytes_written += len(buf) checksum.update(buf) f.write(buf) """ except IOError as e: if e.errno != errno.EACCES: self._delete_partial(filepath, image_id) exceptions = {errno.EFBIG: exception.StorageFull(), errno.ENOSPC: exception.StorageFull(), errno.EACCES: exception.StorageWriteDenied()} raise exceptions.get(e.errno, e) From: Miller, Mark M (EB SW Cloud - R&D - Corvallis) Sent: Tuesday, December 17, 2013 12:32 AM To: OpenStack Development Mailing List (not for usage questions) Subject: [openstack-dev] Glance mod_wsgi.input Question Hello, I am trying to get the Grizzly Glance service working with Apache2 through the WSGI interface. I am having problems with the "_upload" method of file "glance/api/v1/images.py" It appears that the req.body_file pointer is invalid as I get the following error: (9, 'Bad file descriptor'). I have tried adding inline test code attempting to read the image_data object but have been unsuccessful. The req.content_length = None. Has anyone come across this issue? Below are a few variable values as well as the req.environ: scheme = file image size = 8 image data = <mod_wsgi.Input object at 0x7f5fb08931f0> ------------- key=HTTP_X_TENANT_NAME, value=u'AdminProject' key=routes.route, value=<routes.route.Route object at 0x7f5fb181fc90> key=webob.is_body_readable, value=True key=mod_wsgi.listener_port, value='9292' key=HTTP_X_PROJECT_NAME, value=u'AdminProject' key=SERVER_SOFTWARE, value='Apache' key=content-length, value=8 key=SCRIPT_NAME, value='/v1/v1' key=HTTP_TRANSFER_ENCODING, value='chunked' key=mod_wsgi.handler_script, value='' key=SERVER_SIGNATURE, value='<address>Apache Server at 10.1.184.1 Port 9292</address>\n' key=REQUEST_METHOD, value='POST' key=PATH_INFO, value='/images' key=SERVER_PROTOCOL, value='HTTP/1.1' key=QUERY_STRING, value='' key=Content_Length, value=8 key=HTTP_X_USER_ID, value=u'0dd0361fe85a43deb456dd47ed55c2e2' key=HTTP_X_IMAGE_META_MIN_RAM, value='0' key=HTTP_X_AUTH_TOKEN, value='de169f1045f8d306a750d28e8e33172e' key=HTTP_USER_AGENT, value='python-glanceclient' key=HTTP_X_DOMAIN_NAME, value=None key=SERVER_NAME, value='10.1.184.1' key=REMOTE_ADDR, value='10.1.184.1' key=HTTP_X_ROLE, value=u'admin' key=mod_wsgi.request_handler, value='wsgi-script' key=HTTP_X_IDENTITY_STATUS, value='Confirmed' key=wsgi.url_scheme, value='https' key=SERVER_ADMIN, value='[no address given]' key=CONTENT_LENGTH, value=8 key=HTTP_X_DOMAIN_ID, value=None key=PATH_TRANSLATED, value='/etc/apache2/wsgi/glance/glance-api.py/v1/images' key=SERVER_PORT, value='9292' key=HTTP_X_PROJECT_DOMAIN_ID, value=None key=wsgiorg.routing_args, value=(<routes.util.URLGenerator object at 0x7f5fb1765a90>, {'action': u'create', 'controller': <glance.common.wsgi.Resource object at 0x7f5fb181fc10>}) key=HTTP_X_USER_DOMAIN_ID, value=None key=wsgi.multiprocess, value=True key=mod_wsgi.input_chunked, value='1' key=SERVER_ADDR, value='10.1.184.1' key=DOCUMENT_ROOT, value='/etc/apache2/htdocs' key=HTTP_X_IMAGE_META_SIZE, value='8' key=mod_wsgi.process_group, value='glance-api' key=HTTP_X_PROJECT_DOMAIN_NAME, value=None key=HTTP_X_SERVICE_CATALOG, value='[{"endpoints_links": [], "endpoints": [{"adminURL": "https://192.168.124.81:8774/v2/eba7179c427f4c8bb177e4b37e6b4fcf", "region": "Region1", "publicURL": "https://10.1.184.2:8774/v2/eba7179c427f4c8bb177e4b37e6b4fcf", "internalURL": "https://192.168.124.81:8774/v2/eba7179c427f4c8bb177e4b37e6b4fcf", "id": "7d60c1b83ee9434cac1a799ff912bd71"}], "type": "compute", "name": "nova"}, {"endpoints_links": [], "endpoints": [{"adminURL": "https://192.168.124.82:9696/", "region": "Region1", "publicURL": "https://10.1.184.1:9696/", "internalURL": "https://192.168.124.82:9696/", "id": "23e53efd167c49c683a4d97900f781e6"}, {"adminURL": "https://192.168.124.82:9696/", "region": "domain", "publicURL": "https://10.1.184.1:9696/", "internalURL": "https://192.168.124.82:9696/", "id": "82bbe0e5b6954ea1a599582188c0197d"}], "type": "network", "name": "quantum"}, {"endpoints_links": [], "endpoints": [{"adminURL": "http://192.168.124.82:21062/", "region": "domain", "publicURL": "http://10.1.184.1:21061/1", "internalURL": "http://192.168.124.82:21061/1", "id": "c302d392551649c187a0f58d2cc6b3f4"}], "type": "repository", "name": "focus"}, {"endpoints_links": [], "endpoints": [{"adminURL": "https://192.168.124.82:9292", "region": "Region1", "publicURL": "https://10.1.184.1:9292", "internalURL": "https://192.168.124.82:9292", "id": "33a17baeb73644af8f45ebe631ab9788"}, {"adminURL": "https://192.168.124.82:9292", "region": "domain", "publicURL": "https://10.1.184.1:9292", "internalURL": "https://192.168.124.82:9292", "id": "4b0827ac48824f60b508fdb1edb3a401"}], "type": "image", "name": "glance"}, {"endpoints_links": [], "endpoints": [{"adminURL": "https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf", "region": "Region1", "publicURL": "https://10.1.184.1:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf", "internalURL": "https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf", "id": "f4ab866d10ef4bc297dbe1c7c747557c"}, {"adminURL": "https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf", "region": "domain", "publicURL": "https://10.1.184.1:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf", "internalURL": "https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf", "id": "e813d4f2ab8d49119146ba313645a37e"}], "type": "volume", "name": "cinder"}, {"endpoints_links": [], "endpoints": [{"adminURL": "https://192.168.124.81:8773/services/Admin", "region": "Region1", "publicURL": "https://10.1.184.2:8773/services/Cloud", "internalURL": "https://192.168.124.81:8773/services/Clouds", "id": "c77f6aacaaa64c68af48cc9b073ea81f"}], "type": "ec2", "name": "ec2"}, {"endpoints_links": [], "endpoints": [{"adminURL": "http://192.168.124.82:21051/1", "region": "domain", "publicURL": "http://10.1.184.1:21051/1", "internalURL": "http://192.168.124.82:21051/1", "id": "d01820a022e44b0c9f8011a608d852dc"}], "type": "provisioner", "name": "eve"}, {"endpoints_links": [], "endpoints": [{"adminURL": "https://192.168.124.82:35357/v2.0", "region": "Region1", "publicURL": "https://10.1.184.1:5000/v2.0", "internalURL": "https://192.168.124.82:5000/v2.0", "id": "b9adc8ffaf224fc6b078273caa11376c"}, {"adminURL": "https://192.168.124.82:35357/v2.0", "region": "domain", "publicURL": "https://10.1.184.1:5000/v2.0", "internalURL": "https://192.168.124.82:5000/v2.0", "id": "41a4936c4d974f15b039fc53d8d5d0ae"}], "type": "identity", "name": "keystone"}, {"endpoints_links": [], "endpoints": [{"adminURL": "http://192.168.124.82:21072/", "region": "domain", "publicURL": "http://10.1.184.1:21071/1", "internalURL": "http://192.168.124.82:21071/1", "id": "1e18cbf52b0845ecb914877e30637ee6"}], "type": "registry", "name": "graffiti"}]' key=HTTP_X_TENANT, value=u'AdminProject' key=HTTP_X_USER, value=u'Admin' key=SCRIPT_FILENAME, value='/etc/apache2/wsgi/glance/glance-api.py' key=HTTP_X_IMAGE_META_PROTECTED, value='False' key=HTTP_X_IMAGE_META_DISK_FORMAT, value='qcow2' key=HTTP_X_IMAGE_META_IS_PUBLIC, value='True' key=wsgi.input, value=<mod_wsgi.Input object at 0x7f5fb08931f0> key=keystone.token_info, value={u'access': {u'token': {u'issued_at': u'2013-12-17T12:14:36.329480', u'expires': u'2013-12-18T12:11:28Z', u'id': u'de169f1045f8d306a750d28e8e33172e', u'tenant': {u'enabled': True, u'id': u'eba7179c427f4c8bb177e4b37e6b4fcf', u'name': u'AdminProject', u'description': u''}}, u'serviceCatalog': [{u'endpoints_links': [], u'endpoints': [{u'adminURL': u'https://192.168.124.81:8774/v2/eba7179c427f4c8bb177e4b37e6b4fcf', u'region': u'Region1', u'publicURL': u'https://10.1.184.2:8774/v2/eba7179c427f4c8bb177e4b37e6b4fcf', u'internalURL': u'https://192.168.124.81:8774/v2/eba7179c427f4c8bb177e4b37e6b4fcf', u'id': u'7d60c1b83ee9434cac1a799ff912bd71'}], u'type': u'compute', u'name': u'nova'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'https://192.168.124.82:9696/', u'region': u'Region1', u'publicURL': u'https://10.1.184.1:9696/', u'internalURL': u'https://192.168.124.82:9696/', u'id': u'23e53efd167c49c683a4d97900f781e6'}, {u'adminURL': u'https://192.168.124.82:9696/', u'region': u'domain', u'publicURL': u'https://10.1.184.1:9696/', u'internalURL': u'https://192.168.124.82:9696/', u'id': u'82bbe0e5b6954ea1a599582188c0197d'}], u'type': u'network', u'name': u'quantum'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'http://192.168.124.82:21062/', u'region': u'domain', u'publicURL': u'http://10.1.184.1:21061/1', u'internalURL': u'http://192.168.124.82:21061/1', u'id': u'c302d392551649c187a0f58d2cc6b3f4'}], u'type': u'repository', u'name': u'focus'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'https://192.168.124.82:9292', u'region': u'Region1', u'publicURL': u'https://10.1.184.1:9292', u'internalURL': u'https://192.168.124.82:9292', u'id': u'33a17baeb73644af8f45ebe631ab9788'}, {u'adminURL': u'https://192.168.124.82:9292', u'region': u'domain', u'publicURL': u'https://10.1.184.1:9292', u'internalURL': u'https://192.168.124.82:9292', u'id': u'4b0827ac48824f60b508fdb1edb3a401'}], u'type': u'image', u'name': u'glance'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf', u'region': u'Region1', u'publicURL': u'https://10.1.184.1:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf', u'internalURL': u'https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf', u'id': u'f4ab866d10ef4bc297dbe1c7c747557c'}, {u'adminURL': u'https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf', u'region': u'domain', u'publicURL': u'https://10.1.184.1:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf', u'internalURL': u'https://192.168.124.82:8776/v1/eba7179c427f4c8bb177e4b37e6b4fcf', u'id': u'e813d4f2ab8d49119146ba313645a37e'}], u'type': u'volume', u'name': u'cinder'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'https://192.168.124.81:8773/services/Admin', u'region': u'Region1', u'publicURL': u'https://10.1.184.2:8773/services/Cloud', u'internalURL': u'https://192.168.124.81:8773/services/Clouds', u'id': u'c77f6aacaaa64c68af48cc9b073ea81f'}], u'type': u'ec2', u'name': u'ec2'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'http://192.168.124.82:21051/1', u'region': u'domain', u'publicURL': u'http://10.1.184.1:21051/1', u'internalURL': u'http://192.168.124.82:21051/1', u'id': u'd01820a022e44b0c9f8011a608d852dc'}], u'type': u'provisioner', u'name': u'eve'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'https://192.168.124.82:35357/v2.0', u'region': u'Region1', u'publicURL': u'https://10.1.184.1:5000/v2.0', u'internalURL': u'https://192.168.124.82:5000/v2.0', u'id': u'b9adc8ffaf224fc6b078273caa11376c'}, {u'adminURL': u'https://192.168.124.82:35357/v2.0', u'region': u'domain', u'publicURL': u'https://10.1.184.1:5000/v2.0', u'internalURL': u'https://192.168.124.82:5000/v2.0', u'id': u'41a4936c4d974f15b039fc53d8d5d0ae'}], u'type': u'identity', u'name': u'keystone'}, {u'endpoints_links': [], u'endpoints': [{u'adminURL': u'http://192.168.124.82:21072/', u'region': u'domain', u'publicURL': u'http://10.1.184.1:21071/1', u'internalURL': u'http://192.168.124.82:21071/1', u'id': u'1e18cbf52b0845ecb914877e30637ee6'}], u'type': u'registry', u'name': u'graffiti'}], u'user': {u'username': u'Admin', u'roles_links': [], u'id': u'0dd0361fe85a43deb456dd47ed55c2e2', u'roles': [{u'id': u'fbd220a4f1f842cfa7ef5cd48bb78e2d', u'name': u'admin'}], u'name': u'Admin'}, u'metadata': {u'is_admin': 0, u'roles': [u'fbd220a4f1f842cfa7ef5cd48bb78e2d']}}} key=HTTP_HOST, value='10.1.184.1:9292' key=HTTP_X_ROLES, value=u'admin' key=HTTPS, value='1' key=wsgi.multithread, value=True key=mod_wsgi.callable_object, value='application' key=routes.url, value=<routes.util.URLGenerator object at 0x7f5fb1765a90> key=HTTP_X_IMAGE_META_MIN_DISK, value='0' key=REQUEST_URI, value='/v1/images' key=HTTP_X_TENANT_ID, value=u'eba7179c427f4c8bb177e4b37e6b4fcf' key=webob.adhoc_attrs, value={'response': <Response at 0x7f5fb1765cd0 200 OK>, 'context': <glance.context.RequestContext object at 0x7f5fb17658d0>} key=wsgi.file_wrapper, value=<built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f5fb1607378> key=wsgi.version, value=(1, 1) key=api.version, value=1 key=GATEWAY_INTERFACE, value='CGI/1.1' key=wsgi.run_once, value=False key=HTTPCONTENT_LENGTH, value=8 key=wsgi.errors, value=<mod_wsgi.Log object at 0x7f5fb087f6b0> key=REMOTE_PORT, value='14055' key=mod_wsgi.listener_host, value='' key=mod_wsgi.version, value=(3, 3) key=HTTP_X_IMAGE_META_CONTAINER_FORMAT, value='bare' key=HTTP_X_PROJECT_ID, value=u'eba7179c427f4c8bb177e4b37e6b4fcf' key=HTTP_X_USER_DOMAIN_NAME, value=None key=HTTP_X_USER_NAME, value=u'Admin' key=CONTENT_TYPE, value='application/octet-stream' key=mod_wsgi.application_group, value='d00-50-56-8e-75-82.cloudos.org:9292|' key=mod_wsgi.script_reloading, value='1' key=HTTP_X_IMAGE_META_NAME, value='CirrosTiny' key=HTTP_ACCEPT_ENCODING, value='identity'
_______________________________________________ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev