Kubernetes keeps sending traffic to a pod whose database connection is dead #50
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The readiness and startup probes both point at
/ready, which only looks at the drain flag. With Postgres unreachable or the Ecto pool exhausted, every pod still reports Ready, Endpoints stays fully populated, users get 500s on every page, and a rolling update completes over the top of pods that cannot serve. The database-backed check already exists at/healthand/health/db, and no probe references it.Evidence
At
2f150f66:k8s/deployment.yaml:254ispath: /readyfor the readiness probe and:239ispath: /startupfor the only gate before a new pod takes traffic.lib/aprsme_web/router.ex:131routes/readyand:139routes/health.lib/aprsme_web/controllers/page_controller.ex:121commentsCheap readiness check without database dependency, and:133is the only non-drain condition before it answersready.lib/aprsme_web/controllers/page_controller.ex:63is_ = Aprsme.Repo.query!("SELECT 1", [], timeout: 1_000), reached only from/health.Expected
Readiness answers 503 when the application cannot reach the database, so the pod leaves the Endpoints list and a rollout stalls instead of completing. Either point the readiness and startup probes at
/health, or make/readyrun the same bounded query while keeping the drain check.How to verify
Stop Postgres or block egress from a pod:
kubectl -n aprs get endpointsstays populated whilecurl pod:4000/readyreturns 200 and/healthreturns 503. Cheaper: a controller test stubsRepo.query!to raise and asserts/readyis 503.Acceptance criteria
Effort: S
Lens: ops