Bug 1296354 - Use actual content hash to compare fiels if ETags are different. r=nthomas a=release DONTBUILD
MozReview-Commit-ID: vovlfndXrK
--- a/testing/mozharness/mozharness/base/script.py
+++ b/testing/mozharness/mozharness/base/script.py
@@ -2025,16 +2025,21 @@ class BaseScript(ScriptMixin, LogMixin,
hasher = hashlib.sha512()
with open(file_path, 'rb') as fh:
buf = fh.read(bs)
while len(buf) > 0:
hasher.update(buf)
buf = fh.read(bs)
return hasher.hexdigest()
+ def get_content_hash(self, content, hash_type="sha512"):
+ h = hashlib.new(hash_type)
+ h.update(content)
+ return h.hexdigest()
+
@property
def return_code(self):
return self._return_code
@return_code.setter
def return_code(self, code):
old_return_code, self._return_code = self._return_code, code
if old_return_code != code:
--- a/testing/mozharness/scripts/release/push-candidate-to-releases.py
+++ b/testing/mozharness/scripts/release/push-candidate-to-releases.py
@@ -166,19 +166,29 @@ class ReleasePusher(BaseScript, Virtuale
self.info("Copying {} to {}".format(source, destination))
bucket.copy_key(destination, self.config["bucket_name"],
source)
elif source_md5 == dest_md5:
self.warning(
"{} already exists with the same content ({}), skipping copy".format(
destination, dest_md5))
else:
- self.fatal(
- "{} already exists with the different content (src ETag: {}, dest ETag: {}), aborting".format(
+ self.warn(
+ "{} already exists with the different content (src ETag: {}, dest ETag: {}), comparing content...".format(
destination, source_key.etag, dest_key.etag))
+ source_hash = self.get_content_hash(source_key.get_contents_as_string())
+ dest_hash = self.get_content_hash(dest_key.get_contents_as_string())
+ if source_hash == dest_hash:
+ self.warning(
+ "{} already exists with the same content ({}), skipping copy".format(
+ destination, dest_hash))
+ else:
+ self.fatal(
+ "{} already exists with the different content (src ETag: {}, dest ETag: {}), aborting".format(
+ destination, source_key.etag, dest_key.etag))
return retry(copy_key, sleeptime=5, max_sleeptime=60,
retry_exceptions=(S3CopyError, S3ResponseError))
def find_release_files():
candidates_prefix = self._get_candidates_prefix()
release_prefix = self._get_releases_prefix()
self.info("Getting key names from candidates")