fix: correct issue where attempts were done globally instead of per check
This commit is contained in:
1 parent
a3a37a1948
commit
00a175bef7
1 file changed
+21
-22
@@ -147,30 +147,10 @@ scheduler-docker-local-check-deploy() {
|
||||
fi
|
||||
done
|
||||
|
||||
local ATTEMPT=0
|
||||
|
||||
until [[ $SUCCESS == 1 || $ATTEMPT -ge $ATTEMPTS ]]; do
|
||||
local FAILEDCHECKS=0
|
||||
local ATTEMPT=$((ATTEMPT + 1))
|
||||
dokku_log_verbose "Attempt $ATTEMPT/$ATTEMPTS. Waiting for $WAIT seconds ..."
|
||||
sleep "$WAIT"
|
||||
|
||||
# -q Do not use .curlrc (must come first)
|
||||
# --compressed Test compression handled correctly
|
||||
# --fail Fail on server errors (4xx, 5xx)
|
||||
# --location Follow redirects
|
||||
# --noproxy Do not use http_proxy env variable
|
||||
local CURL_OPTIONS="-q --compressed --fail --location --noproxy $DOKKU_APP_LISTEN_IP --max-time $TIMEOUT"
|
||||
|
||||
# Set X-Forwarded-Proto header if TLS is enabled.
|
||||
local SSL="$DOKKU_ROOT/$APP/tls"
|
||||
if [[ -e "$SSL/server.crt" && -e "$SSL/server.key" ]]; then
|
||||
local CURL_OPTIONS+=" -H X-Forwarded-Proto:https"
|
||||
fi
|
||||
|
||||
exec <"$CHECKS_FILENAME"
|
||||
local CHECK_URL
|
||||
local EXPECTED
|
||||
local FAILEDCHECKS=0
|
||||
while read -r CHECK_URL EXPECTED; do
|
||||
# Ignore empty lines and lines starting with #
|
||||
# shellcheck disable=SC1001
|
||||
@@ -202,6 +182,19 @@ scheduler-docker-local-check-deploy() {
|
||||
local URL_PATHNAME=$CHECK_URL
|
||||
fi
|
||||
|
||||
# -q Do not use .curlrc (must come first)
|
||||
# --compressed Test compression handled correctly
|
||||
# --fail Fail on server errors (4xx, 5xx)
|
||||
# --location Follow redirects
|
||||
# --noproxy Do not use http_proxy env variable
|
||||
local CURL_OPTIONS="-q --compressed --fail --location --noproxy $DOKKU_APP_LISTEN_IP --max-time $TIMEOUT"
|
||||
|
||||
# Set X-Forwarded-Proto header if TLS is enabled.
|
||||
local SSL="$DOKKU_ROOT/$APP/tls"
|
||||
if [[ -e "$SSL/server.crt" && -e "$SSL/server.key" ]]; then
|
||||
local CURL_OPTIONS+=" -H X-Forwarded-Proto:https"
|
||||
fi
|
||||
|
||||
# This URL will show up in the messages
|
||||
local LOG_URL="$URL_PROTOCOL://$URL_HOSTNAME$URL_PATHNAME"
|
||||
# And how we formulate the CURL request
|
||||
@@ -211,6 +204,12 @@ scheduler-docker-local-check-deploy() {
|
||||
dokku_log_verbose "$LOG_URL => \"$EXPECTED\""
|
||||
[[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS"
|
||||
|
||||
local ATTEMPT=0
|
||||
until [[ $SUCCESS == 1 || $ATTEMPT -ge $ATTEMPTS ]]; do
|
||||
local ATTEMPT=$((ATTEMPT + 1))
|
||||
dokku_log_verbose "Attempt $ATTEMPT/$ATTEMPTS. Waiting for $WAIT seconds ..."
|
||||
sleep "$WAIT"
|
||||
|
||||
# Capture HTTP response or CURL error message
|
||||
# shellcheck disable=SC2086
|
||||
if OUTPUT=$(curl -# $CURL_ARGS 2>&1); then
|
||||
@@ -224,7 +223,6 @@ scheduler-docker-local-check-deploy() {
|
||||
dokku_log_warn "$OUTPUT"
|
||||
local FAILEDCHECKS=$((FAILEDCHECKS + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $FAILEDCHECKS -gt 0 ]]; then
|
||||
dokku_log_warn "Check attempt $ATTEMPT/$ATTEMPTS failed."
|
||||
@@ -233,6 +231,7 @@ scheduler-docker-local-check-deploy() {
|
||||
local SUCCESS=1
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [[ $FAILEDCHECKS -gt 0 ]]; then
|
||||
dokku_log_fail "Could not start due to $FAILEDCHECKS failed checks."
|
||||
|
||||
Reference in new issue
Block a user