Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(llm-proxy): give SIGTERM enough grace for every request already admitted
Alfredo Lopez75a0a834a899
diff --git a/deploy/base/control-plane/codex-llm-proxy.yaml b/deploy/base/control-plane/codex-llm-proxy.yamlindex 481afda23..6f3b4ebb7 100644--- a/deploy/base/control-plane/codex-llm-proxy.yaml+++ b/deploy/base/control-plane/codex-llm-proxy.yaml@@ -55,10 +55,12 @@ spec:spec:serviceAccountName: codex-llm-proxyautomountServiceAccountToken: false- # On SIGTERM the proxy waits for its open streams (#739 D6): the stream- # cap (CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS / 1000) plus 60 s for- # redeem and finalize. The deploy-contract script derives this value.- terminationGracePeriodSeconds: 1860+ # On SIGTERM the proxy stops accepting connections and finishes every+ # request it already admitted (#739 D6, R18): queue wait 60 s + body read+ # 10 s + redeem 15 s + stream cap (CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS /+ # 1000) + finalize 15 s + 20 s margin. test/deployManifest.test.ts derives+ # this value from the proxy's own constants.+ terminationGracePeriodSeconds: 1920securityContext:runAsNonRoot: trueseccompProfile:diff --git a/deploy/base/control-plane/grok-llm-proxy.yaml b/deploy/base/control-plane/grok-llm-proxy.yamlindex f5d9b4547..6653e6f9c 100644--- a/deploy/base/control-plane/grok-llm-proxy.yaml+++ b/deploy/base/control-plane/grok-llm-proxy.yaml@@ -50,10 +50,12 @@ spec:spec:serviceAccountName: grok-llm-proxyautomountServiceAccountToken: false- # On SIGTERM the proxy waits for its open streams (#739 D6): the stream- # cap (GROK_LLM_PROXY_MAX_STREAM_DURATION_MS / 1000) plus 60 s for- # redeem and finalize. The deploy-contract script derives this value.- terminationGracePeriodSeconds: 1860+ # On SIGTERM the proxy stops accepting connections and finishes every+ # request it already admitted (#739 D6, R18): queue wait 60 s + body read+ # 10 s + redeem 15 s + stream cap (GROK_LLM_PROXY_MAX_STREAM_DURATION_MS /+ # 1000) + finalize 15 s + 20 s margin. test/deployManifest.test.ts derives+ # this value from the proxy's own constants.+ terminationGracePeriodSeconds: 1920securityContext:runAsNonRoot: trueseccompProfile:diff --git a/scripts/tests/test-codex-llm-proxy-deploy-contract.sh b/scripts/tests/test-codex-llm-proxy-deploy-contract.shindex 7599bf885..7e2f1973d 100755--- a/scripts/tests/test-codex-llm-proxy-deploy-contract.sh+++ b/scripts/tests/test-codex-llm-proxy-deploy-contract.sh@@ -129,11 +129,13 @@ if len(stream_ms) != 1 or len(grace) != 1:"terminationGracePeriodSeconds exactly once")else:- required_grace = -(-int(stream_ms[0]) // 1000) + 60+ # Queue wait 60 + body read 10 + redeem 15 + finalize 15 + margin 20.+ # The proxy's test/deployManifest.test.ts derives the same sum from code.+ required_grace = -(-int(stream_ms[0]) // 1000) + 120if int(grace[0]) != required_grace:errors.append(f"terminationGracePeriodSeconds must be {required_grace} "- f"(MAX_STREAM_DURATION_MS / 1000 + 60), found {grace[0]}"+ f"(MAX_STREAM_DURATION_MS / 1000 + 120), found {grace[0]}")if "codex-llm-proxy.yaml" not in active(kustomize):diff --git a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh b/scripts/tests/test-grok-llm-proxy-deploy-contract.shindex 4640a82a0..29b90fd0f 100755--- a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh+++ b/scripts/tests/test-grok-llm-proxy-deploy-contract.sh@@ -117,11 +117,13 @@ if len(stream_ms) != 1 or len(grace) != 1:"terminationGracePeriodSeconds exactly once")else:- required_grace = -(-int(stream_ms[0]) // 1000) + 60+ # Queue wait 60 + body read 10 + redeem 15 + finalize 15 + margin 20.+ # The proxy's test/deployManifest.test.ts derives the same sum from code.+ required_grace = -(-int(stream_ms[0]) // 1000) + 120if int(grace[0]) != required_grace:errors.append(f"terminationGracePeriodSeconds must be {required_grace} "- f"(MAX_STREAM_DURATION_MS / 1000 + 60), found {grace[0]}"+ f"(MAX_STREAM_DURATION_MS / 1000 + 120), found {grace[0]}")if "grok-llm-proxy.yaml" not in active(kustomize):