From efa58933478b79bfaece4662ef26c720ef0f1322 Mon Sep 17 00:00:00 2001 From: "John \"codefu\" McDole" Date: Tue, 5 Aug 2025 13:53:34 -0700 Subject: [PATCH] fix: content_aware_hash tag for fuchsia merge / upload (#173253) Also tag after the upload, similar to #173140 fixes: #173137 --- .../fuchsia/merge_and_upload_debug_symbols.py | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/tools/fuchsia/merge_and_upload_debug_symbols.py b/engine/src/flutter/tools/fuchsia/merge_and_upload_debug_symbols.py index 35becf02148..f1c5dba6c00 100755 --- a/engine/src/flutter/tools/fuchsia/merge_and_upload_debug_symbols.py +++ b/engine/src/flutter/tools/fuchsia/merge_and_upload_debug_symbols.py @@ -87,15 +87,7 @@ def ProcessCIPDPackage(upload, cipd_yaml, engine_version, content_hash, out_dir, if already_exists: print('CIPD package %s tag %s already exists!' % (package_name, git_tag)) - content_tag = '' - if content_hash: - content_tag = 'content_aware_hash:%s' % content_hash - content_already_exists = CheckCIPDPackageExists(package_name, content_tag) - if content_already_exists: - print('CIPD package %s tag %s already exists!' % (package_name, content_tag)) - content_tag = '' - # do not return; content hash can match multiple PRs (reverts, framework only) - + tag_content_hash = False if upload and IsLinux() and not already_exists: command = [ 'cipd', @@ -109,21 +101,49 @@ def ProcessCIPDPackage(upload, cipd_yaml, engine_version, content_hash, out_dir, '-verification-timeout', '10m0s', ] - if content_tag: - command.extend(['-tag', content_tag]) + tag_content_hash = True else: command = [ 'cipd', 'pkg-build', '-pkg-def', cipd_yaml, '-out', os.path.join(_packaging_dir, 'fuchsia-debug-symbols-%s.cipd' % target_arch) ] + RunCIPDCommandWithRetries(command, _packaging_dir) + + if tag_content_hash: + TagBuildWithContentHash(package_name, content_hash, git_tag, _packaging_dir) + + +def TagBuildWithContentHash(package_name, content_hash, git_tag, _packaging_dir): + content_tag = 'content_aware_hash:%s' % content_hash + already_exists = CheckCIPDPackageExists(package_name, content_tag) + if already_exists: + print('CIPD package %s tag %s already exists!' % (package_name, content_tag)) + # content hash can match multiple PRs and we cannot tag multiple times. + return + + # Tag the new content hash for the git_revision. This is done separately due + # to a race condition: https://github.com/flutter/flutter/issues/173137 + command = [ + 'cipd', + 'set-tag', + package_name, + '-tag', + content_tag, + '-version', + git_tag, + ] + RunCIPDCommandWithRetries(command, _packaging_dir) + + +def RunCIPDCommandWithRetries(command, working_dir): # Retry up to three times. We've seen CIPD fail on verification in some # instances. Normally verification takes slightly more than 1 minute when # it succeeds. num_tries = 3 for tries in range(num_tries): try: - subprocess.check_call(command, cwd=_packaging_dir) + subprocess.check_call(command, cwd=working_dir) break except subprocess.CalledProcessError as error: print('Failed %s times.\nError was: %s' % (tries + 1, error))