Skip to content

Commit 7ad904e

Browse files
P0-7: instant-api terminationGracePeriodSeconds=35 + preStop (MR-P0-7) (#15)
* feat(k8s/app.yaml): terminationGracePeriodSeconds=35 + preStop hook (MR-P0-7) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * alerts(prom): orphan_sweep reaped/failed alerts (PASS 3/6, 2026-05-20) Three new Prometheus alerts tied to the worker repo's PASS 3 enhanced reasons + PASS 6 stuck-build counters: - OrphanSweepNoDBRowReap (CRITICAL, 1h): a k8s namespace had no backing deployments row — the P0-3 atomic-provision symptom. Pages on first occurrence over 1h. - OrphanSweepStuckBuildSpike (WARNING, 15m): >5 stuck-build flips in 15m means the kaniko/GHCR build pipeline is degraded for many customers at once. - OrphanSweepReapFailureRate (WARNING, 30m): the reconciler detected orphans it cannot reap (k8s/DB write failure sustained). The counters land in worker master commit 7d2ff0d; the alerts go live once the deploy lands + scrape picks them up. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dffab5c commit 7ad904e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

k8s/app.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ spec:
2929
app: instant-api
3030
spec:
3131
serviceAccountName: instant-api # grants deploy-manager ClusterRole (see deploy-rbac.yaml)
32+
# terminationGracePeriodSeconds — 35s after SIGTERM before kubelet
33+
# escalates to SIGKILL. Budget (matches runServerWithGracefulShutdown
34+
# in api/main.go):
35+
# preStop sleep 5s ← LB sees /readyz 503 first
36+
# readinessDrainGrace 3s ← in-process probe-tick window
37+
# gracefulShutdownTimeout 25s ← Fiber drain in-flight handlers
38+
# safety margin 2s ← buffer before SIGKILL
39+
# ── ────
40+
# total 35s
41+
# Default is 30s, which collides with our 25+3+5=33s drain.
42+
# MR-P0-7 (BugBash 2026-05-20). Keep in sync with main.go consts.
43+
terminationGracePeriodSeconds: 35
3244
# Spread replicas across nodes when possible — preferred (not required)
3345
# so a 1-node dev cluster still schedules both pods.
3446
affinity:
@@ -54,6 +66,16 @@ spec:
5466
containers:
5567
- name: api
5668
image: instant-api:local # built with: docker build -t instant-api:local .
69+
# preStop — sleep 5s before SIGTERM is delivered so the kubelet
70+
# has a tick to observe the readinessProbe failure (the api
71+
# flips inside runServerWithGracefulShutdown via
72+
# hooks.Readyz.MarkDraining) and update Service endpoints.
73+
# Without this, the LB keeps routing new traffic to a pod that
74+
# is about to stop accepting connections. MR-P0-7.
75+
lifecycle:
76+
preStop:
77+
exec:
78+
command: ["/bin/sh", "-c", "sleep 5"]
5779
ports:
5880
- containerPort: 8080
5981
envFrom:

0 commit comments

Comments
 (0)