From 520a302f3ade4eb2f862707b7cb38e84d33b4f86 Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Tue, 16 Apr 2024 15:53:19 +0800 Subject: [PATCH] test:[skip e2e]fix get image tag (#32306) Signed-off-by: zhuwenxing --- tests/scripts/get_image_tag_by_short_name.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/scripts/get_image_tag_by_short_name.py b/tests/scripts/get_image_tag_by_short_name.py index f1563f8684..bc2b5d2f20 100644 --- a/tests/scripts/get_image_tag_by_short_name.py +++ b/tests/scripts/get_image_tag_by_short_name.py @@ -43,11 +43,14 @@ def get_image_tag_by_short_name(repository, tag, arch): res = [] # Iterate through all tags and find the ones with the same DIGEST for tag_info in data["results"]: - if "digest" in tag_info["images"][0] and tag_info["images"][0]["digest"] == digest: - # Extract the image name - image_name = tag_info["name"].split(":")[0] - if image_name != tag and arch in [x["architecture"] for x in tag_info["images"]]: - res.append(image_name) + try: + if "digest" in tag_info["images"][0] and tag_info["images"][0]["digest"] == digest: + # Extract the image name + image_name = tag_info["name"].split(":")[0] + if image_name != tag and arch in [x["architecture"] for x in tag_info["images"]]: + res.append(image_name) + except Exception as e: + continue # In case of no match, try to find the latest tag with the same arch # there is a case: push master-xxx-arm64 and master-latest, but master-latest-amd64 is not pushed, # then there will be no tag matched, so we need to find the latest tag with the same arch even it is not the latest tag