From 5cbc2d024e33aa1bd2c01db42ef6039341a3fbd0 Mon Sep 17 00:00:00 2001 From: Keerthi Gowda Date: Thu, 6 Aug 2026 16:40:40 -0700 Subject: [PATCH] create_data_tar: warn and exit 0 on duplicate version instead of failing When multiple projects invoke this script and one has already been published to Artifactory, the previous behavior aborted with a fatal error. This treats an existing version as a non-fatal condition: log a warning with the matching Artifactory location(s) and exit 0, skipping tarball creation. Genuine Artifactory query/parse failures still exit 1. Signed-off-by: Keerthi Gowda --- create_data_tar.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/create_data_tar.py b/create_data_tar.py index 8255278..6b06c68 100755 --- a/create_data_tar.py +++ b/create_data_tar.py @@ -324,10 +324,12 @@ def fetch_artifactory_uris(query_name: str): return uris -def fail_if_version_exists_in_artifactory(tar_name: str, args) -> None: +def find_existing_version_in_artifactory(tar_name: str, args): """ - Query Artifactory and fail when the same package version is already present - for the same architecture. + Query Artifactory for tarballs matching the same package/version/arch + (same distro folder layout, when --distro is given). + Returns the list of matching Artifactory URIs (empty if none found). + Raises RuntimeError if Artifactory itself could not be queried/parsed. """ identity = parse_tar_identity(tar_name) if identity: @@ -361,15 +363,7 @@ def fail_if_version_exists_in_artifactory(tar_name: str, args) -> None: if base == tar_name: duplicates.append(uri) - if duplicates: - examples = "\n".join(f" - {u}" for u in duplicates[:10]) - extra = "" if len(duplicates) <= 10 else f"\n ... and {len(duplicates) - 10} more" - raise RuntimeError( - "Version already exists in Artifactory; refusing to create tarball.\n" - f" tar_name: {tar_name}\n" - f" matches: {len(duplicates)}\n" - f"{examples}{extra}" - ) + return duplicates def main(): @@ -395,13 +389,26 @@ def main(): if tar_name == base: tar_name = base + '.tar.gz' - # Remote duplicate guard: fail early if this version already exists. + # Remote duplicate guard: warn and exit cleanly if this version already + # exists, so a caller batching multiple projects doesn't treat an + # already-published version as a fatal failure for the whole batch. try: - fail_if_version_exists_in_artifactory(tar_name, args) + duplicates = find_existing_version_in_artifactory(tar_name, args) except Exception as e: logger.critical(str(e)) sys.exit(1) + if duplicates: + examples = "\n".join(f" - {u}" for u in duplicates[:10]) + extra = "" if len(duplicates) <= 10 else f"\n ... and {len(duplicates) - 10} more" + logger.warning( + "Version already exists in Artifactory; skipping tarball creation.\n" + f" tar_name: {tar_name}\n" + f" matches: {len(duplicates)}\n" + f"{examples}{extra}" + ) + sys.exit(0) + # Remove stale metadata files from previous runs. try: remove_stale_metadata_files(work_dir)