You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by yh...@apache.org on 2024/01/26 18:22:23 UTC
(beam) 01/01: Fix clean up stale container workflow
This is an automated email from the ASF dual-hosted git repository.
yhu pushed a commit to branch fixcleanupcontainer
in repository https://gitbox.apache.org/repos/asf/beam.git
commit 5759d41538e4fdd902f911fd85756fdea1c8d640
Author: Yi Hu <ya...@google.com>
AuthorDate: Fri Jan 26 13:21:45 2024 -0500
Fix clean up stale container workflow
---
.../tools/stale_dataflow_prebuilt_image_cleaner.sh | 49 +++++++++++++---------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/.test-infra/tools/stale_dataflow_prebuilt_image_cleaner.sh b/.test-infra/tools/stale_dataflow_prebuilt_image_cleaner.sh
index 2838d6245ce..12f70ae426f 100755
--- a/.test-infra/tools/stale_dataflow_prebuilt_image_cleaner.sh
+++ b/.test-infra/tools/stale_dataflow_prebuilt_image_cleaner.sh
@@ -25,7 +25,13 @@ set -euo pipefail
PUBLIC_REPOSITORIES=(beam-sdk beam_portability beamgrafana beammetricssyncjenkins beammetricssyncgithub)
PRIVATE_REPOSITORIES=(java-postcommit-it python-postcommit-it jenkins github-actions)
# set as the same as 6-week release period
-DELETE_BEFORE_DAY=$(date --iso-8601=s -d '6 weeks ago')
+if [[ $OSTYPE == "linux-gnu"* ]]; then
+ # skip if not a valid date
+ DELETE_BEFORE_DAY=$(date --iso-8601=s -d '6 weeks ago')
+elif [[ $OSTYPE == "darwin"* ]]; then
+ # date command usage depending on OS
+ DELETE_BEFORE_DAY=$(date -j -v-6w '+%Y-%m-%dT%H:%M:%S')
+fi
REPOSITORIES=("${PUBLIC_REPOSITORIES[@]/#/gcr.io/apache-beam-testing/}" "${PRIVATE_REPOSITORIES[@]/#/us.gcr.io/apache-beam-testing/}")
@@ -70,24 +76,29 @@ for image_name in ${IMAGE_NAMES[@]}; do
# do not delete the one with latest label and the newest image without latest label
# this make sure we leave at least one container under each image name, either labelled "latest" or not
if [ "$LATEST_IN_TIME" != "$current" ]; then
- # Check to see if this image is built on top of earlier images. This is the case for multiarch images,
- # they will have a virtual size of 0 and a created date at the start of the epoch, but their manifests will
- # point to active images. These images should only be deleted when all of their dependencies can be safely
- # deleted.
- MANIFEST=$(docker manifest inspect ${image_name}@"${current}")
- SHOULD_DELETE=0
- DIGEST=$(echo $MANIFEST | jq -r '.manifests[0].digest')
- if [ "$DIGEST" != "null" ]
- then
- SHOULD_DELETE=1
- for i in ${STALE_IMAGES_CURRENT[@]}
- do
- echo "$i"
- if [ "$i" = "$DIGEST" ]
- then
- SHOULD_DELETE=0
- fi
- done
+ if [[ $image_name =~ 'beamgrafana' || $image_name =~ 'beammetricssyncjenkins' || $image_name =~ 'beammetricssyncgithub' ]]; then
+ # Skip docker manifest inspect for known single arch images, workaround permission issue & saving API call
+ SHOULD_DELETE=0
+ else
+ # Check to see if this image is built on top of earlier images. This is the case for multiarch images,
+ # they will have a virtual size of 0 and a created date at the start of the epoch, but their manifests will
+ # point to active images. These images should only be deleted when all of their dependencies can be safely
+ # deleted.
+ MANIFEST=$(docker manifest inspect ${image_name}@"${current}")
+ SHOULD_DELETE=0
+ DIGEST=$(echo $MANIFEST | jq -r '.manifests[0].digest')
+ if [ "$DIGEST" != "null" ]
+ then
+ SHOULD_DELETE=1
+ for i in ${STALE_IMAGES_CURRENT[@]}
+ do
+ echo "$i"
+ if [ "$i" = "$DIGEST" ]
+ then
+ SHOULD_DELETE=0
+ fi
+ done
+ fi
fi
if [ $SHOULD_DELETE = 0 ]