Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.
TypeScript
fix(deploy): a flapping health probe must not read as an outage (#276)
yetonef694fed49870
diff --git a/scripts/release-smoke.mjs b/scripts/release-smoke.mjsindex 498684c..3b4069e 100644--- a/scripts/release-smoke.mjs+++ b/scripts/release-smoke.mjs@@ -40,9 +40,38 @@ async function request(path, { authenticated = true } = {}) {return body}+/** /api/health is the readiness probe: `SELECT 1` raced against a 1s timer, so+ * a DB under load answers 503 on some fraction of calls while every real+ * request still completes. One such 503 must not read as "production is+ * down" — it failed the pre-deploy baseline on a healthy-but-busy fleet and+ * would roll a good candidate back on the post-deploy check for the same+ * reason. A bounded retry keeps a persistent outage failing (every attempt+ * 503s) while a transient one has to hold for the whole window to fail.+ * Sized for the observed worst case (~65% of probes lost under saturation):+ * 0.65^10 ≈ 1% per smoke, 20s worst case against the 120s smoke budget. */+const HEALTH_ATTEMPTS = Number(process.env.CUMORA_SMOKE_HEALTH_ATTEMPTS || 10)+const HEALTH_RETRY_MS = Number(process.env.CUMORA_SMOKE_HEALTH_RETRY_MS || 2_000)++async function checkHealth() {+ let lastError = null+ for (let attempt = 1; attempt <= HEALTH_ATTEMPTS; attempt++) {+ try {+ const health = await request('/api/health', { authenticated: false })+ if (health?.ok) return+ lastError = new Error('/api/health did not report ok')+ } catch (error) {+ lastError = error+ }+ if (attempt < HEALTH_ATTEMPTS) {+ console.log(` /api/health attempt ${attempt}/${HEALTH_ATTEMPTS} failed: ${lastError.message} — retrying in ${HEALTH_RETRY_MS}ms`)+ await new Promise((resolve) => setTimeout(resolve, HEALTH_RETRY_MS))+ }+ }+ throw new Error(`/api/health failed ${HEALTH_ATTEMPTS} consecutive attempts: ${lastError.message}`)+}+try {- const health = await request('/api/health', { authenticated: false })- if (!health?.ok) throw new Error('/api/health did not report ok')+ await checkHealth()const auth = await request('/api/auth/me')if (!Array.isArray(auth?.companies) || !auth.companies.some((company) => company.id === companyId)) {diff --git a/server/k8s/cumora-server.gke.yaml b/server/k8s/cumora-server.gke.yamlindex 0d84e56..53f0c10 100644--- a/server/k8s/cumora-server.gke.yaml+++ b/server/k8s/cumora-server.gke.yaml@@ -181,6 +181,13 @@ spec:httpGet: { path: /api/health, port: http }periodSeconds: 5timeoutSeconds: 2+ # /api/health races SELECT 1 against 1s, so a saturated (not dead)+ # Postgres fails a random fraction of probes. Every replica shares+ # that one DB, so at the default threshold (3 = 15s) they were all+ # pulled from the NEG together and the LB answered 502 for traffic+ # the pods could still serve, slowly. 60s of CONSECUTIVE failures+ # still pulls a pod on a real DB outage; a flap no longer does.+ failureThreshold: 12livenessProbe:httpGet: { path: /api/livez, port: http }periodSeconds: 30diff --git a/server/k8s/cumora-server.orbstack.yaml b/server/k8s/cumora-server.orbstack.yamlindex b1a7ff1..4538377 100644--- a/server/k8s/cumora-server.orbstack.yaml+++ b/server/k8s/cumora-server.orbstack.yaml@@ -124,6 +124,10 @@ spec:httpGet: { path: /api/health, port: http }periodSeconds: 5timeoutSeconds: 2+ # Same contract as cumora-server.gke.yaml / deploy/recovery.ts: a+ # DB under load fails a fraction of probes; only 60s of consecutive+ # failures should pull a pod.+ failureThreshold: 12livenessProbe:httpGet: { path: /api/livez, port: http }periodSeconds: 30diff --git a/server/src/deploy/recovery.ts b/server/src/deploy/recovery.tsindex fcaf5a2..3059926 100644--- a/server/src/deploy/recovery.ts+++ b/server/src/deploy/recovery.ts@@ -135,6 +135,10 @@ export const DEPLOYMENT_PROBE_CONTRACT = {httpGet: { path: '/api/health', port: 'http' },periodSeconds: 5,timeoutSeconds: 2,+ // /api/health races SELECT 1 against 1s, so a saturated Postgres fails a+ // random fraction of probes on every replica at once. 60s of consecutive+ // failures still pulls a pod; a flap must not (see the manifests).+ failureThreshold: 12,},livenessProbe: {httpGet: { path: '/api/livez', port: 'http' },