]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Content-length missing in put_object
authorMarc Koderer <m.koderer@telekom.de>
Wed, 19 Jun 2013 14:07:44 +0000 (16:07 +0200)
committerMarc Koderer <m.koderer@telekom.de>
Wed, 26 Jun 2013 05:50:02 +0000 (07:50 +0200)
Radosgw returns a "411 Length Required" in case the content-length is not
specified. The parameter content_type is not set which leads to the problem
that content_length cannot be determined. Since the content length is already
computed in backup/services/swift it shouldn't be a problem to set this
parameter.

Conflicts:
cinder/backup/services/swift.py

Change-Id: I4c56823d70fcd1a801a75bfd14f474a2780dc1ac

cinder/backup/services/swift.py

index 4b3ed22a13911b696062324ed4b0030416d7db1d..ed6df06e4fec392769412b737d3fce282222b417 100644 (file)
@@ -201,7 +201,8 @@ class SwiftBackupService(base.Base):
         metadata['objects'] = object_list
         metadata_json = json.dumps(metadata, sort_keys=True, indent=2)
         reader = StringIO.StringIO(metadata_json)
-        etag = self.conn.put_object(container, filename, reader)
+        etag = self.conn.put_object(container, filename, reader,
+                                    content_length=reader.len)
         md5 = hashlib.md5(metadata_json).hexdigest()
         if etag != md5:
             err = _('error writing metadata file to swift, MD5 of metadata'
@@ -288,7 +289,8 @@ class SwiftBackupService(base.Base):
         reader = StringIO.StringIO(data)
         LOG.debug(_('About to put_object'))
         try:
-            etag = self.conn.put_object(container, object_name, reader)
+            etag = self.conn.put_object(container, object_name, reader,
+                                        content_length=len(data))
         except socket.error as err:
             raise exception.SwiftConnectionFailed(reason=str(err))
         LOG.debug(_('swift MD5 for %(object_name)s: %(etag)s') %