launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28011
[Merge] ~cjwatson/launchpad:better-swift-size-error into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:better-swift-size-error into launchpad:master.
Commit message:
Expand error message if a Swift object has an unexpected size
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/414505
Including the observed/expected sizes in the error messages gives us a better chance of knowing what to look for when debugging.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:better-swift-size-error into launchpad:master.
diff --git a/lib/lp/services/librarianserver/swift.py b/lib/lp/services/librarianserver/swift.py
index ddb3125..bd22a1e 100644
--- a/lib/lp/services/librarianserver/swift.py
+++ b/lib/lp/services/librarianserver/swift.py
@@ -181,11 +181,13 @@ def _to_swift_file(log, swift_connection, lfc_id, fs_path):
log.debug(
"{} already exists in Swift({}, {})".format(
lfc_id, container, obj_name))
- if ('X-Object-Manifest' not in headers and
- int(headers['content-length'])
- != os.path.getsize(fs_path)):
+ got_size = int(headers['content-length'])
+ expected_size = os.path.getsize(fs_path)
+ if 'X-Object-Manifest' not in headers and got_size != expected_size:
raise AssertionError(
- '{} has incorrect size in Swift'.format(lfc_id))
+ '{} has incorrect size in Swift '
+ '(got {} bytes, expected {} bytes)'.format(
+ lfc_id, got_size, expected_size))
except swiftclient.ClientException as x:
if x.http_status != 404:
raise