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:
3 files changed
+71
-1
No files matched your search
@@ -26,7 +26,7 @@ build_python_image() {
|
||||
cp "$TMP_IMAGE_DIR/$PROCFILE" "$TMP_IMAGE_DIR/Procfile"
|
||||
fi
|
||||
|
||||
docker image build -t "dokku-test/$TEST_APP:$TAG" -f "$TMP_IMAGE_DIR/alt.Dockerfile" "$TMP_IMAGE_DIR" || exit_code="$?"
|
||||
docker image build --label "com.dokku.test-app=$TEST_APP" -t "dokku-test/$TEST_APP:$TAG" -f "$TMP_IMAGE_DIR/alt.Dockerfile" "$TMP_IMAGE_DIR" || exit_code="$?"
|
||||
rm -rf "$TMP_IMAGE_DIR"
|
||||
return "$exit_code"
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ setup() {
|
||||
|
||||
teardown() {
|
||||
global_teardown
|
||||
docker image rm "dokku-test/$TEST_APP:shared" &>/dev/null || true
|
||||
}
|
||||
|
||||
@test "(scheduler-docker-local:report) --global raw and computed keys" {
|
||||
@@ -484,6 +485,60 @@ teardown() {
|
||||
assert_output "running"
|
||||
}
|
||||
|
||||
@test "(scheduler-docker-local) ps:retire keeps an image that is another app's source image" {
|
||||
local SECOND_APP="$TEST_APP-2" TMP_IMAGE_DIR
|
||||
TMP_IMAGE_DIR="$(mktemp -d "/tmp/${DOKKU_DOMAIN}.XXXXX")"
|
||||
cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/python/." "$TMP_IMAGE_DIR"
|
||||
run /bin/bash -c "docker image build -t dokku-test/$TEST_APP:shared -f $TMP_IMAGE_DIR/alt.Dockerfile $TMP_IMAGE_DIR"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
rm -rf "$TMP_IMAGE_DIR"
|
||||
assert_success
|
||||
|
||||
run create_app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run create_app "$SECOND_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku checks:set $TEST_APP wait-to-retire 1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:from-image $TEST_APP dokku-test/$TEST_APP:shared"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku git:from-image $SECOND_APP dokku-test/$TEST_APP:shared"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run deploy_app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
sleep 3
|
||||
|
||||
run /bin/bash -c "dokku ps:retire"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "is the source image for $SECOND_APP"
|
||||
|
||||
run /bin/bash -c "docker image inspect dokku-test/$TEST_APP:shared --format '{{.Id}}'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(scheduler-docker-local) procfile quoted arguments on deploy" {
|
||||
run create_app
|
||||
echo "output: $output"
|
||||
|
||||
Reference in new issue
Block a user