fix: recover deployed image from registry on local miss
Adds an app-aware `fn-verify-app-image` helper that pulls the deployed image from the configured registry when it is missing locally, gated on push-on-release being enabled, honoring per-app `registry:login` credentials. Every in-tree `verify_image` caller migrates to the wrapper and the bare helper is marked deprecated. `config:set` now forwards the deployed image tag to `release-and-deploy` so the release path no longer pins recovery on the unrecoverable `:latest` tag.
This commit is contained in:
9 files changed
+167
-27
No files matched your search
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
global_setup
|
||||
create_app
|
||||
dokku checks:set $TEST_APP wait-to-retire 30
|
||||
}
|
||||
|
||||
teardown() {
|
||||
destroy_app
|
||||
global_teardown
|
||||
}
|
||||
|
||||
setup_push_on_release_app() {
|
||||
if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_TOKEN" ]]; then
|
||||
skip "skipping due to missing docker.io credentials DOCKERHUB_USERNAME:DOCKERHUB_TOKEN"
|
||||
fi
|
||||
|
||||
run /bin/bash -c "dokku builder:set $TEST_APP selected herokuish"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku proxy:set $TEST_APP nginx"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku registry:login $TEST_APP docker.io $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku registry:set $TEST_APP image-repo $DOCKERHUB_USERNAME/$TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku registry:set $TEST_APP push-on-release true"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "docker image rm $DOCKERHUB_USERNAME/$TEST_APP:1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "docker image inspect $DOCKERHUB_USERNAME/$TEST_APP:1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "(registry) [recover] ps:restart pulls missing image" {
|
||||
setup_push_on_release_app
|
||||
|
||||
run /bin/bash -c "dokku ps:restart $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "not found locally, pulling from registry"
|
||||
|
||||
run /bin/bash -c "docker image inspect $DOCKERHUB_USERNAME/$TEST_APP:1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(registry) [recover] dokku run pulls missing image" {
|
||||
setup_push_on_release_app
|
||||
|
||||
run /bin/bash -c "dokku run $TEST_APP echo recovery-ok"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "not found locally, pulling from registry"
|
||||
assert_output_contains "recovery-ok"
|
||||
}
|
||||
|
||||
@test "(registry) [recover] domains:add pulls missing image" {
|
||||
setup_push_on_release_app
|
||||
|
||||
run /bin/bash -c "dokku domains:add $TEST_APP recovery.${DOKKU_DOMAIN}"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "docker image inspect $DOCKERHUB_USERNAME/$TEST_APP:1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(registry) [recover] config:set forwards deployed tag to release-and-deploy" {
|
||||
setup_push_on_release_app
|
||||
|
||||
run /bin/bash -c "dokku config:set $TEST_APP RECOVERY_KEY=value"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
# triggerRestart forwards the deployed numeric tag (not "latest") to
|
||||
# release-and-deploy, so the wrapper attempts recovery against ":1" rather
|
||||
# than skipping recovery for ":latest" which is never pushed.
|
||||
assert_output_contains "dokku/$TEST_APP:1 not found locally, pulling from registry"
|
||||
}
|
||||
Reference in new issue
Block a user