feat(ingress.tjo.cloud): healthcheck implementation
Some checks failed
/ lint (push) Failing after 40s
Some checks failed
/ lint (push) Failing after 40s
This commit is contained in:
parent
3a28a3eae0
commit
1232e36d66
1 changed files with 20 additions and 5 deletions
|
@ -144,7 +144,15 @@ configure_many() {
|
||||||
healthcheck() {
|
healthcheck() {
|
||||||
local ip="$1"
|
local ip="$1"
|
||||||
|
|
||||||
curl -s -f -o /dev/null "http://$ip" || error "Healthcheck failed"
|
code=$(curl -s -o /dev/null -I -w '%{http_code}' "http://$ip:1337/healthz" || echo "")
|
||||||
|
|
||||||
|
if [[ "$code" != "200" ]]; then
|
||||||
|
warn "Healthcheck failed for $ip. Got $code"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Healthcheck passed for $ip"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true); do
|
while (true); do
|
||||||
|
@ -167,17 +175,24 @@ while (true); do
|
||||||
warn "IPv4 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
warn "IPv4 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
||||||
else
|
else
|
||||||
info "Found IPv4 address $ipv4"
|
info "Found IPv4 address $ipv4"
|
||||||
|
if healthcheck "$ipv4"; then
|
||||||
configure_single "$domain_records" "$CLOUD_REGION" "$ipv4" "A"
|
configure_single "$domain_records" "$CLOUD_REGION" "$ipv4" "A"
|
||||||
configure_many "$domain_records" "any" "$ipv4" "A"
|
configure_many "$domain_records" "any" "$ipv4" "A"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z $ipv6 ]]; then
|
if [[ -z $ipv6 ]]; then
|
||||||
warn "IPv6 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
warn "IPv6 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
||||||
else
|
else
|
||||||
info "Found IPv6 address $ipv6"
|
info "Found IPv6 address $ipv6"
|
||||||
|
if healthcheck "[$ipv6]"; then
|
||||||
configure_single "$domain_records" "$CLOUD_REGION" "$ipv6" "AAAA"
|
configure_single "$domain_records" "$CLOUD_REGION" "$ipv6" "AAAA"
|
||||||
configure_many "$domain_records" "any" "$ipv6" "AAAA"
|
configure_many "$domain_records" "any" "$ipv6" "AAAA"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Check other domain_records,
|
||||||
|
# and remove any records that are not healthy.
|
||||||
|
|
||||||
sleep "$sleep_interval"
|
sleep "$sleep_interval"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue