From 99c6342b1a256efa273ba8ea82cb505c274adcba Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 4 Feb 2020 10:06:07 +0000 Subject: [PATCH] Bug 1603988 - Part 1: Avoid to fail system-symbols-mac-upload-symbols when no symbols to upload r=marco,gsvelto Currently, when task system-symbols-mac doesn't produce artifacts because of no data, then the task system-symbols-mac-upload-symbols is failing too. So this patch aims to not fail the task in such a case. Differential Revision: https://phabricator.services.mozilla.com/D59848 --HG-- extra : moz-landing-system : lando --- taskcluster/ci/system-symbols-upload/kind.yml | 2 +- toolkit/crashreporter/tools/upload_symbols.py | 28 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/taskcluster/ci/system-symbols-upload/kind.yml b/taskcluster/ci/system-symbols-upload/kind.yml index 7c0d8e3372db..e6df92f0e348 100644 --- a/taskcluster/ci/system-symbols-upload/kind.yml +++ b/taskcluster/ci/system-symbols-upload/kind.yml @@ -23,7 +23,7 @@ job-template: SYMBOL_SECRET: "project/releng/gecko/build/level-{level}/gecko-symbol-upload" run: using: mach - mach: {artifact-reference: "python toolkit/crashreporter/tools/upload_symbols.py "} + mach: {artifact-reference: "python toolkit/crashreporter/tools/upload_symbols.py --ignore-missing"} sparse-profile: upload-symbols scopes: - secrets:get:project/releng/gecko/build/level-{level}/gecko-symbol-upload diff --git a/toolkit/crashreporter/tools/upload_symbols.py b/toolkit/crashreporter/tools/upload_symbols.py index 906acd39eda0..bf1d325204d6 100644 --- a/toolkit/crashreporter/tools/upload_symbols.py +++ b/toolkit/crashreporter/tools/upload_symbols.py @@ -68,11 +68,33 @@ def main(): description='Upload symbols in ZIP using token from Taskcluster secrets service.') parser.add_argument('zip', help='Symbols zip file - URL or path to local file') + parser.add_argument('--ignore-missing', + help='No error on missing files', + action='store_true') args = parser.parse_args() - if not args.zip.startswith('http') and not os.path.isfile(args.zip): - log.error('Error: zip file "{0}" does not exist!'.format(args.zip)) - return 1 + def check_file_exists(url): + for i, _ in enumerate(redo.retrier(attempts=MAX_RETRIES), start=1): + try: + resp = requests.head(url, allow_redirects=True) + return resp.status_code == requests.codes.ok + except requests.exceptions.RequestException as e: + log.error('Error: {0}'.format(e)) + log.info('Retrying...') + return False + + if args.zip.startswith('http'): + is_existing = check_file_exists(args.zip) + else: + is_existing = os.path.isfile(args.zip) + + if not is_existing: + if args.ignore_missing: + log.info('Zip file "{0}" does not exist!'.format(args.zip)) + return 0 + else: + log.error('Error: zip file "{0}" does not exist!'.format(args.zip)) + return 1 secret_name = os.environ.get('SYMBOL_SECRET') if secret_name is not None: