fix: map caddy healthcheck headers and apply tls-internal
Caddy healthchecks now honor the `attempts` and `httpHeaders` properties of the `app.json` readiness healthcheck, matching openresty. The `tls-internal` property was also never applied to app containers, and now takes effect for apps served over https.
This commit is contained in:
6 files changed
+205
-43
No files matched your search
@@ -582,6 +582,47 @@ teardown() {
|
||||
assert_output_contains "Invalid app.json healthcheck path for caddy" -1
|
||||
}
|
||||
|
||||
@test "(caddy) healthcheck headers from app.json" {
|
||||
run /bin/bash -c "dokku proxy:set $TEST_APP caddy"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP setup_caddy_readiness_healthcheck_headers
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"caddy.reverse_proxy.health_headers.X-Check\" }}'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output '"dokku check"'
|
||||
|
||||
run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"caddy.reverse_proxy.health_fails\" }}'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "2"
|
||||
|
||||
sleep 5
|
||||
|
||||
run /bin/bash -c "docker exec caddy-caddy-1 cat /config/caddy/Caddyfile.autosave"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains 'X-Check "dokku check"'
|
||||
assert_output_contains "health_fails 2"
|
||||
|
||||
run /bin/bash -c "docker logs caddy-caddy-1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Failed to convert caddyfile" 0
|
||||
|
||||
assert_http_localhost_response "http" "$TEST_APP.dokku.me" "80" "" "python/http.server"
|
||||
}
|
||||
|
||||
setup_caddy_readiness_healthcheck() {
|
||||
local APP="$1"
|
||||
local APP_REPO_DIR="$2"
|
||||
@@ -591,3 +632,13 @@ setup_caddy_readiness_healthcheck() {
|
||||
convert_to_dockerfile "$APP" "$APP_REPO_DIR"
|
||||
mv "$APP_REPO_DIR/app-readiness.json" "$APP_REPO_DIR/app.json"
|
||||
}
|
||||
|
||||
setup_caddy_readiness_healthcheck_headers() {
|
||||
local APP="$1"
|
||||
local APP_REPO_DIR="$2"
|
||||
[[ -z "$APP" ]] && local APP="$TEST_APP"
|
||||
APP_REPO_DIR="$(realpath "$APP_REPO_DIR")"
|
||||
|
||||
convert_to_dockerfile "$APP" "$APP_REPO_DIR"
|
||||
jq '.healthchecks.web[0].attempts = 2 | .healthchecks.web[0].httpHeaders = [{"name": "X-Check", "value": "dokku check"}]' "$APP_REPO_DIR/app-readiness.json" >"$APP_REPO_DIR/app.json"
|
||||
}
|
||||
Reference in new issue
Block a user