fix(ci): classify private proxy socket HTTP readiness before OIDC startup
This commit is contained in:
1 parent
53b258d571
commit
670e225db4
1 file changed
+54
-14
+54
-14
@@ -79,23 +79,63 @@ proxy_id="$(dc ps -q proxy)"
|
||||
test -n "$proxy_id"
|
||||
bootstrap_volume="${project}_zitadel-bootstrap"
|
||||
|
||||
# Distinguish an unhealthy private proxy/Host route from a broken forwarder.
|
||||
# The probing container shares ONLY the disposable proxy network namespace;
|
||||
# no host-published port, credentials, response body or user HTTP query.
|
||||
# Classify the direct private proxy socket/HTTP route separately from the
|
||||
# forwarder BEFORE any ephemeral OIDC client/user or credential is created.
|
||||
# This probe shares ONLY the run-owned proxy network namespace. No published
|
||||
# host port, raw exception/log, URL, HTTP body, cookie or secret is printed.
|
||||
docker run --rm --network "container:$proxy_id" python:3.12-alpine \
|
||||
python -c '
|
||||
import http.client, sys
|
||||
try:
|
||||
import errno
|
||||
import http.client
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
|
||||
transient = {"CONNECTION_REFUSED", "TIMEOUT", "CONNECTION_RESET"}
|
||||
for attempt in range(1, 4):
|
||||
conn = http.client.HTTPConnection("127.0.0.1", 80, timeout=9)
|
||||
conn.request("GET", "/debug/ready", headers={"Host": "localhost:8080"})
|
||||
response = conn.getresponse()
|
||||
if response.status != 200:
|
||||
print("OIDC_CI_PRIVATE_PROXY_HOST_ROUTE_HTTP_STATUS=" + str(response.status), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except (OSError, http.client.HTTPException):
|
||||
print("OIDC_CI_PRIVATE_PROXY_SOCKET_OR_HTTP_BLOCKED", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print("ZITPLANE_OIDC_PRIVATE_PROXY_HOST_ROUTE_PASS")
|
||||
try:
|
||||
conn.request("GET", "/debug/ready", headers={"Host": "localhost:8080"})
|
||||
response = conn.getresponse()
|
||||
if response.status != 200:
|
||||
print("OIDC_CI_PRIVATE_PROXY_HOST_ROUTE_HTTP_STATUS=" + str(response.status),
|
||||
file=sys.stderr, flush=True)
|
||||
sys.exit(1)
|
||||
print("ZITPLANE_OIDC_PRIVATE_PROXY_HOST_ROUTE_PASS", flush=True)
|
||||
sys.exit(0)
|
||||
except (TimeoutError, socket.timeout):
|
||||
reason = "TIMEOUT"
|
||||
except ConnectionRefusedError:
|
||||
reason = "CONNECTION_REFUSED"
|
||||
except ConnectionResetError:
|
||||
reason = "CONNECTION_RESET"
|
||||
except http.client.HTTPException:
|
||||
reason = "HTTP_PROTOCOL_ERROR"
|
||||
except OSError as exc:
|
||||
reasons = {
|
||||
errno.ECONNREFUSED: "CONNECTION_REFUSED",
|
||||
errno.ETIMEDOUT: "TIMEOUT",
|
||||
errno.ECONNRESET: "CONNECTION_RESET",
|
||||
errno.ENETUNREACH: "NETWORK_UNREACHABLE",
|
||||
errno.EHOSTUNREACH: "NETWORK_UNREACHABLE",
|
||||
errno.EACCES: "PERMISSION_DENIED",
|
||||
errno.EPERM: "PERMISSION_DENIED",
|
||||
}
|
||||
reason = reasons.get(exc.errno, "SOCKET_OTHER")
|
||||
finally:
|
||||
try:
|
||||
conn.close()
|
||||
except OSError:
|
||||
pass
|
||||
print("OIDC_CI_PRIVATE_PROXY_PROBE_ATTEMPT=" + str(attempt) +
|
||||
" CLASS=" + reason, file=sys.stderr, flush=True)
|
||||
# Retry only known transient socket errors, never HTTP/protocol/policy.
|
||||
if reason not in transient or attempt == 3:
|
||||
break
|
||||
time.sleep(2)
|
||||
print("OIDC_CI_PRIVATE_PROXY_READINESS_BLOCKED_CLASS=" + reason,
|
||||
file=sys.stderr, flush=True)
|
||||
sys.exit(1)
|
||||
'
|
||||
|
||||
# P05-OIDC-04: inspect the run-owned proxy socket and PID namespace BEFORE
|
||||
|
||||
Reference in new issue
Block a user