Skip to content

Commit

Permalink
Merge pull request containers#370 from cevich/increase_image_rm_rate
Browse files Browse the repository at this point in the history
[CI:TOOLING] Increase obsolete image flagging and pruning
  • Loading branch information
cevich authored Jul 8, 2024
2 parents dd546e9 + f67769a commit e166288
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion IMG_SFX
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20240702t180702z-f40f39d13
20240708t135624z-f40f39d13
9 changes: 5 additions & 4 deletions imgobsolete/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gcloud_init

# Set this to 1 for testing
DRY_RUN="${DRY_RUN:-0}"
OBSOLETE_LIMIT=10
OBSOLETE_LIMIT=50
THEFUTURE=$(date --date='+1 hour' +%s)
TOO_OLD_DAYS='30'
TOO_OLD_DESC="$TOO_OLD_DAYS days ago"
Expand Down Expand Up @@ -201,14 +201,15 @@ for (( i=nr_amis ; i ; i-- )); do
done

COUNT=$(<"$IMGCOUNT")
CANDIDATES=$(wc -l <$TOOBSOLETE)
msg "########################################################################"
msg "Obsoleting $OBSOLETE_LIMIT random images of $COUNT examined:"
msg "Obsoleting $OBSOLETE_LIMIT random image candidates ($CANDIDATES/$COUNT total):"

# Require a minimum number of images to exist. Also if there is some
# horrible scripting accident, this limits the blast-radius.
if [[ "$COUNT" -lt $OBSOLETE_LIMIT ]]
if [[ "$CANDIDATES" -lt $OBSOLETE_LIMIT ]]
then
die 0 "Safety-net Insufficient images ($COUNT) to process ($OBSOLETE_LIMIT required)"
die 0 "Safety-net Insufficient images ($CANDIDATES) to process ($OBSOLETE_LIMIT required)"
fi

# Don't let one bad apple ruin the whole bunch
Expand Down
9 changes: 5 additions & 4 deletions imgprune/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gcloud_init
# Set this to 1 for testing
DRY_RUN="${DRY_RUN:-0}"
# For safety's sake limit nr deletions
DELETE_LIMIT=10
DELETE_LIMIT=50
ABOUTNOW=$(date --iso-8601=date) # precision is not needed for this use
# Format Ref: https://cloud.google.com/sdk/gcloud/reference/topic/formats
# Field list from `gcloud compute images list --limit=1 --format=text`
Expand Down Expand Up @@ -106,13 +106,14 @@ for (( i=nr_amis ; i ; i-- )); do
done

COUNT=$(<"$IMGCOUNT")
CANDIDATES=$(wc -l <$TODELETE)
msg "########################################################################"
msg "Deleting up to $DELETE_LIMIT random images of $COUNT examined:"
msg "Deleting up to $DELETE_LIMIT random image candidates ($CANDIDATES/$COUNT total)::"

# Require a minimum number of images to exist
if [[ "$COUNT" -lt $DELETE_LIMIT ]]
if [[ "$CANDIDATES" -lt $DELETE_LIMIT ]]
then
die 0 "Safety-net Insufficient images ($COUNT) to process deletions ($DELETE_LIMIT required)"
die 0 "Safety-net Insufficient images ($CANDIDATES) to process deletions ($DELETE_LIMIT required)"
fi

sort --random-sort $TODELETE | tail -$DELETE_LIMIT | \
Expand Down
2 changes: 1 addition & 1 deletion imgts/lib_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ aws_init() {
then
TMPF="$1"
else
TMPF=$(mktemp -p '' .$(uuidgen)_XXXX.ini)
TMPF=$(mktemp -p '' .XXXXXXXX)
fi
# shellcheck disable=SC2154
echo "$AWSINI" > $TMPF
Expand Down

0 comments on commit e166288

Please sign in to comment.