From 7f32181ebe33b031a0cd5b81be194aeb150578ea Mon Sep 17 00:00:00 2001 From: Falkan Date: Thu, 26 Mar 2026 22:29:47 -0400 Subject: [PATCH] feat: readiness sentinel for Kubernetes entrypoint.sh creates /home/agent/vol/.openclaw-initializing at startup and removes it just before launching the gateway. Pod is not marked ready until init (volume copy + config baking) is fully complete. deployment.yaml adds readinessProbe: exec test ! -f sentinel, with initialDelaySeconds=5, periodSeconds=5, failureThreshold=60 (5 minute window for slow storage on first deploy). --- deployment.yaml | 7 +++++++ entrypoint.sh | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/deployment.yaml b/deployment.yaml index e5e671c..7aea18e 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -64,6 +64,13 @@ spec: - name: vol mountPath: /home/agent/vol + readinessProbe: + exec: + command: ["test", "!", "-f", "/home/agent/vol/.openclaw-initializing"] + initialDelaySeconds: 5 + periodSeconds: 5 + failureThreshold: 60 + env: # ── Required ──────────────────────────────────────────── diff --git a/entrypoint.sh b/entrypoint.sh index aa4cd20..3dcf9a7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -61,6 +61,14 @@ export OPENCLAW_GATEWAY_PORT="${OPENCLAW_GATEWAY_PORT:-18800}" log() { echo "[entrypoint] $*"; } warn() { echo "[entrypoint] WARNING: $*" >&2; } +# ── Readiness sentinel ──────────────────────────────────────────── +# Present during init; deleted just before gateway starts. +# Kubernetes readiness probe: test ! -f /home/agent/vol/.openclaw-initializing +SENTINEL="${VOL}/.openclaw-initializing" +mkdir -p "${VOL}" +touch "${SENTINEL}" +log "Readiness sentinel created at ${SENTINEL}" + # ── Warn on missing required vars ──────────────────────────────── for var in OPENCLAW_GATEWAY_TOKEN OPENCLAW_DEFAULT_MODEL OPENCLAW_AGENT_NAME \ ANTHROPIC_API_KEY ANTHROPIC_MODEL ANTHROPIC_SMALL_FAST_MODEL PAI_AGENT_NAME; do @@ -522,6 +530,8 @@ fi # Run gateway in background. OpenClaw manages its own internal restarts. # The sleep loop keeps the container alive if the gateway process exits. log "Starting OpenClaw gateway on port ${OPENCLAW_GATEWAY_PORT}..." +rm -f "${SENTINEL}" +log "Readiness sentinel removed — pod is ready." /home/agent/.npm-global/bin/openclaw gateway & while true; do