fix: add proxy health checks from app.json readiness
The caddy, haproxy, openresty, and traefik docs stated that requests are only routed to containers passing healthchecks, but these proxies route to a new container as soon as it starts. The first `web` readiness healthcheck in `app.json` is now also turned into health checks and retries for caddy and openresty, as it already was for traefik, so requests are routed away from containers that are not yet ready, and the docs now describe how each proxy actually behaves.
This commit is contained in:
@@ -130,21 +130,20 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
||||
fi
|
||||
fi
|
||||
|
||||
local app_json hc_path hc_scheme hc_port hc_timeout hc_interval hc_filter
|
||||
app_json="$(plugn trigger app-json-get-content "$APP" 2>/dev/null || echo "{}")"
|
||||
hc_filter='.healthchecks.web // [] | map(select(.type == "readiness" and .path != null and .path != "")) | .[0]'
|
||||
hc_path=$(echo "$app_json" | jq -r "$hc_filter | .path // empty")
|
||||
if [[ -n "$hc_path" ]]; then
|
||||
hc_scheme=$(echo "$app_json" | jq -r "$hc_filter | .scheme // empty")
|
||||
hc_port=$(echo "$app_json" | jq -r "$hc_filter | .port // empty")
|
||||
hc_timeout=$(echo "$app_json" | jq -r "$hc_filter | .timeout // empty")
|
||||
hc_interval=$(echo "$app_json" | jq -r "$hc_filter | .wait // empty")
|
||||
local healthcheck hc_path hc_scheme hc_port hc_timeout hc_interval
|
||||
healthcheck="$(fn-proxy-get-readiness-healthcheck "$APP")"
|
||||
if [[ -n "$healthcheck" ]]; then
|
||||
hc_path=$(echo "$healthcheck" | jq -r ".path // empty")
|
||||
hc_scheme=$(echo "$healthcheck" | jq -r ".scheme // empty")
|
||||
hc_port=$(echo "$healthcheck" | jq -r ".port // empty")
|
||||
hc_timeout=$(echo "$healthcheck" | jq -r ".timeout // empty")
|
||||
hc_interval=$(echo "$healthcheck" | jq -r ".wait // empty")
|
||||
|
||||
if ! fn-traefik-healthcheck-path-is-valid "$hc_path"; then
|
||||
if ! fn-proxy-healthcheck-path-is-valid "$hc_path"; then
|
||||
dokku_log_fail "Invalid app.json healthcheck path for traefik: path must start with a / and must not contain whitespace, control characters, quotes, or backslashes"
|
||||
fi
|
||||
|
||||
if ! fn-traefik-healthcheck-scheme-is-valid "$hc_scheme"; then
|
||||
if ! fn-proxy-healthcheck-scheme-is-valid "$hc_scheme"; then
|
||||
dokku_log_fail "Invalid app.json healthcheck scheme for traefik: scheme must be one of http or https"
|
||||
fi
|
||||
|
||||
|
||||
@@ -243,20 +243,3 @@ fn-traefik-dns-provider-env-vars() {
|
||||
declare desc="returns all dns-provider-* environment variables"
|
||||
fn-plugin-property-get-all-by-prefix "traefik" "--global" "dns-provider-"
|
||||
}
|
||||
|
||||
fn-traefik-healthcheck-path-is-valid() {
|
||||
declare desc="checks that an app.json healthcheck path is absolute and free of whitespace, control, quote, and backslash characters"
|
||||
declare HC_PATH="$1"
|
||||
|
||||
[[ "$HC_PATH" == /* ]] || return 1
|
||||
[[ "$HC_PATH" =~ [[:space:][:cntrl:]\"\'\\] ]] && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
fn-traefik-healthcheck-scheme-is-valid() {
|
||||
declare desc="checks that an app.json healthcheck scheme is either http or https"
|
||||
declare HC_SCHEME="$1"
|
||||
|
||||
[[ -z "$HC_SCHEME" ]] && return 0
|
||||
[[ "${HC_SCHEME,,}" == "http" ]] || [[ "${HC_SCHEME,,}" == "https" ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user