fix: do not retire an image that another app uses as its source image

Image retirement removes images by id, so a queued image could be deleted even though another app had since started using it as its git:from-image source image. Skip such images at retire time and drop them from the retire list.

The git_4 test images are also given a per-app label so they no longer share a cached image id, which let a retire entry left by one test delete the next test's source image.
This commit is contained in:
Jose Diaz-Gonzalez
2026-10-14 10:00:51 -04:00
parent 02f0466cac
commit e71dffb1a7
3 changed files with 71 additions and 1 deletions

View File

@@ -187,6 +187,15 @@ fn-scheduler-docker-local-retire-images() {
return
fi
local -A SOURCE_IMAGE_APPS=()
local source_app source_image source_image_id
for source_app in $(dokku_apps "false" 2>/dev/null); do
source_image="$(plugn trigger git-get-property "$source_app" "source-image" 2>/dev/null || true)"
[[ -z "$source_image" ]] && continue
source_image_id="$("$DOCKER_BIN" image inspect --format '{{ .Id }}' "$source_image" 2>/dev/null | cut -d: -f2 || true)"
[[ -n "$source_image_id" ]] && SOURCE_IMAGE_APPS["$source_image_id"]="$source_app"
done
DEAD_IMAGES=()
while read line; do
[[ -z "$line" ]] && continue
@@ -209,6 +218,12 @@ fn-scheduler-docker-local-retire-images() {
continue
fi
if [[ -n "${SOURCE_IMAGE_APPS[$IMAGE_ID]}" ]]; then
dokku_log_warn "Image ${IMAGE_ID} is the source image for ${SOURCE_IMAGE_APPS[$IMAGE_ID]}, removing from retire list"
DEAD_IMAGES+=("$IMAGE_ID")
continue
fi
dokku_log_verbose_quiet "Attempting to retire $RETIRE_APP image $IMAGE_ID"
if RM_OUTPUT="$("$DOCKER_BIN" image remove "$IMAGE_ID" 2>&1)"; then
DEAD_IMAGES+=("$IMAGE_ID")