mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
[skip e2e]Fix get image tag for 2.2.0 branch (#27674)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
parent
5b405ca28a
commit
6a2b16fd6c
@ -18,12 +18,17 @@ def get_image_tag_by_short_name(repository, tag, arch):
|
|||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
# Get the latest tag with the same arch and prefix
|
# Get the latest tag with the same arch and prefix
|
||||||
sorted_imgaes = sorted(data["results"], key=lambda x: x["last_updated"], reverse=True)
|
sorted_images = sorted(data["results"], key=lambda x: x["last_updated"], reverse=True)
|
||||||
candidate_tag = None
|
candidate_tag = None
|
||||||
for tag_info in sorted_imgaes:
|
for tag_info in sorted_images:
|
||||||
if tag_info["name"].endswith(arch):
|
# print(tag_info)
|
||||||
|
if arch in [x["architecture"] for x in tag_info["images"]]:
|
||||||
candidate_tag = tag_info["name"]
|
candidate_tag = tag_info["name"]
|
||||||
break
|
if candidate_tag == tag:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
# print(f"candidate_tag: {candidate_tag}")
|
||||||
|
break
|
||||||
# Get the DIGEST of the short tag
|
# Get the DIGEST of the short tag
|
||||||
url = f"https://hub.docker.com/v2/repositories/{repository}/tags/{tag}"
|
url = f"https://hub.docker.com/v2/repositories/{repository}/tags/{tag}"
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@ -35,7 +40,7 @@ def get_image_tag_by_short_name(repository, tag, arch):
|
|||||||
if "digest" in tag_info["images"][0] and tag_info["images"][0]["digest"] == digest:
|
if "digest" in tag_info["images"][0] and tag_info["images"][0]["digest"] == digest:
|
||||||
# Extract the image name
|
# Extract the image name
|
||||||
image_name = tag_info["name"].split(":")[0]
|
image_name = tag_info["name"].split(":")[0]
|
||||||
if image_name != tag and arch in image_name:
|
if image_name != tag and arch in [x["architecture"] for x in tag_info["images"]]:
|
||||||
res.append(image_name)
|
res.append(image_name)
|
||||||
# In case of no match, try to find the latest tag with the same arch
|
# 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,
|
# there is a case: push master-xxx-arm64 and master-latest, but master-latest-amd64 is not pushed,
|
||||||
@ -44,7 +49,10 @@ def get_image_tag_by_short_name(repository, tag, arch):
|
|||||||
image_name = tag_info["name"].split(":")[0]
|
image_name = tag_info["name"].split(":")[0]
|
||||||
if image_name != tag and arch in image_name:
|
if image_name != tag and arch in image_name:
|
||||||
res.append(image_name)
|
res.append(image_name)
|
||||||
|
# print(res)
|
||||||
if len(res) == 0 or candidate_tag > res[0]:
|
if len(res) == 0 or candidate_tag > res[0]:
|
||||||
|
if candidate_tag is None:
|
||||||
|
return tag
|
||||||
return candidate_tag
|
return candidate_tag
|
||||||
else:
|
else:
|
||||||
return res[0]
|
return res[0]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user