From 5e8ab1cd857eb5cedfd367251f3d6fa34fb6c861 Mon Sep 17 00:00:00 2001 From: Marc Koderer Date: Wed, 19 Jun 2013 16:07:44 +0200 Subject: [PATCH] Content-length missing in put_object 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cinder/backup/services/swift.py b/cinder/backup/services/swift.py index 4b3ed22a1..ed6df06e4 100644 --- a/cinder/backup/services/swift.py +++ b/cinder/backup/services/swift.py @@ -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') % -- 2.45.2