mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-12 20:42:57 +00:00
Handle attempts to push tag several times inside python
This commit is contained in:
6
.github/workflows/docker-tag-push.yml
vendored
6
.github/workflows/docker-tag-push.yml
vendored
@@ -18,7 +18,7 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
timeout-minutes:
|
timeout-minutes:
|
||||||
description: Timeout in minutes
|
description: Timeout in minutes
|
||||||
default: 10
|
default: 15
|
||||||
type: number
|
type: number
|
||||||
secrets:
|
secrets:
|
||||||
REGISTRY_USERNAME:
|
REGISTRY_USERNAME:
|
||||||
@@ -69,10 +69,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Merge tags for the images 🔀
|
- name: Merge tags for the images 🔀
|
||||||
run: |
|
run: |
|
||||||
python3 -m tagging.apps.merge_tags \
|
|
||||||
--image ${{ inputs.image }} \
|
|
||||||
--variant ${{ inputs.variant }} \
|
|
||||||
--tags-dir /tmp/jupyter/tags/ || \
|
|
||||||
python3 -m tagging.apps.merge_tags \
|
python3 -m tagging.apps.merge_tags \
|
||||||
--image ${{ inputs.image }} \
|
--image ${{ inputs.image }} \
|
||||||
--variant ${{ inputs.variant }} \
|
--variant ${{ inputs.variant }} \
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
# Distributed under the terms of the Modified BSD License.
|
# Distributed under the terms of the Modified BSD License.
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
import plumbum
|
import plumbum
|
||||||
|
|
||||||
@@ -63,6 +64,25 @@ def pull_missing_tags(merged_tag: str, all_local_tags: list[str]) -> list[str]:
|
|||||||
return existing_platform_tags
|
return existing_platform_tags
|
||||||
|
|
||||||
|
|
||||||
|
def push_manifest(merged_tag: str) -> None:
|
||||||
|
ATTEMPTS = 3
|
||||||
|
SLEEP_TIME = 5
|
||||||
|
|
||||||
|
LOGGER.info(f"Pushing manifest for tag: {merged_tag}")
|
||||||
|
# Retry pushing the manifest up to ATTEMPTS times in case of failure
|
||||||
|
for attempt in range(ATTEMPTS):
|
||||||
|
try:
|
||||||
|
docker["manifest", "push", merged_tag] & plumbum.FG
|
||||||
|
break
|
||||||
|
except plumbum.ProcessExecutionError as e:
|
||||||
|
LOGGER.warning(f"Attempt {attempt + 1} to push manifest failed: {e}")
|
||||||
|
if attempt + 1 == ATTEMPTS:
|
||||||
|
LOGGER.error(f"Failed to push manifest after {ATTEMPTS} attempts")
|
||||||
|
raise
|
||||||
|
time.sleep(SLEEP_TIME)
|
||||||
|
LOGGER.info(f"Successfully pushed manifest for tag: {merged_tag}")
|
||||||
|
|
||||||
|
|
||||||
def merge_tags(
|
def merge_tags(
|
||||||
merged_tag: str, all_local_tags: list[str], push_to_registry: bool
|
merged_tag: str, all_local_tags: list[str], push_to_registry: bool
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -84,9 +104,7 @@ def merge_tags(
|
|||||||
docker["manifest", "create", merged_tag][existing_platform_tags] & plumbum.FG
|
docker["manifest", "create", merged_tag][existing_platform_tags] & plumbum.FG
|
||||||
LOGGER.info(f"Successfully created manifest for tag: {merged_tag}")
|
LOGGER.info(f"Successfully created manifest for tag: {merged_tag}")
|
||||||
|
|
||||||
LOGGER.info(f"Pushing manifest for tag: {merged_tag}")
|
push_manifest(merged_tag)
|
||||||
docker["manifest", "push", merged_tag] & plumbum.FG
|
|
||||||
LOGGER.info(f"Successfully merged and pushed tag: {merged_tag}")
|
|
||||||
else:
|
else:
|
||||||
LOGGER.info(f"Skipping push for tag: {merged_tag}")
|
LOGGER.info(f"Skipping push for tag: {merged_tag}")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user