From 9352276cc2d0ca778b8f15fa3a802ec4c6c09c0f Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Mon, 6 Jan 2020 13:35:42 -0800 Subject: [PATCH] Test swift upload logs without encoding type for gzip files When retrieving gzipped files out of swift with gzip encoding set some swift implementations return a decompressed version of the file if your client cannot accept gzip encoding. This causes problems when the file you want is actually compressed like a .tar.gz. Instead we avoid setting the encoding type of these files forcing swift to give them back as is. This change will be followed by a change that updates the production role. Change-Id: Ica27cf070d50fcafd879b6f8ccc3964afa9bf5e6 --- .../test-upload-logs-swift/library/zuul_swift_upload.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/test-upload-logs-swift/library/zuul_swift_upload.py b/roles/test-upload-logs-swift/library/zuul_swift_upload.py index e5f272a37..100d8e65a 100755 --- a/roles/test-upload-logs-swift/library/zuul_swift_upload.py +++ b/roles/test-upload-logs-swift/library/zuul_swift_upload.py @@ -789,7 +789,14 @@ class Uploader(): headers['content-encoding'] = 'gzip' data = GzipFilter(open(file_detail.full_path, 'rb')) else: - if file_detail.encoding: + if (not file_detail.filename.endswith(".gz") and + file_detail.encoding): + # Don't apply gzip encoding to files that we receive as + # already gzipped. The reason for this is swift will + # serve this back to users as an uncompressed file if they + # don't set an accept-encoding that includes gzip. This + # can cause problems when the desired file state is + # compressed as with .tar.gz tarballs. headers['content-encoding'] = file_detail.encoding data = open(file_detail.full_path, 'rb') else: