Skip to content

fix(provision): honour caller deadline in postgres/mongo/queue k8s Provision#53

Merged
mastermanas805 merged 1 commit into
masterfrom
fix/provision-ctx-deadline-pg-mongo-queue
Jun 8, 2026
Merged

fix(provision): honour caller deadline in postgres/mongo/queue k8s Provision#53
mastermanas805 merged 1 commit into
masterfrom
fix/provision-ctx-deadline-pg-mongo-queue

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Problem

Redis's k8s backend was fixed for the pro-provision-hang bug in #52, but the postgres, mongo, and queue backends still derived their provisioning context from context.Background() — discarding the caller's gRPC deadline. When the api caller's deadline fired (or it cancelled the RPC), the provisioner kept blocking up to 5 min on a wedged PVC/CSI attach and the api handler hung. This is the same hang class that drove the recent e2e-prod flakiness — just for db / nosql / queue instead of cache. (Found by a sibling-gap sweep after the deploy-failure fix; sections B/C of that sweep came back clean.)

The Background() was a relic from when the api passed a 10s provision deadline; the api now grants provisionTimeout(tier) = 4m anon / 5m pro, comfortably above the 30-90s legitimate pod startup.

Fix (mirrors redis #52)

  • All three: provCtx := context.WithTimeout(ctx, 5*time.Minute) — derive from the incoming ctx (min of caller deadline and the 5m ceiling backstop). Caller deadline/cancellation now propagates to every k8s call + waitPodReady poll; legitimate startup is unaffected, only hangs/early-cancels fast-fail.
  • Bounded the rollback namespace-delete to a fresh 30s background ctx (redis parity) so cleanup still runs when the incoming ctx is already cancelled, without a wedged apiserver pinning the goroutine.
  • No server change needed: waitPodReady already honours ctx.Err() each poll, and the shared server.mapError already maps context.DeadlineExceeded/Canceled → retryable gRPC codes (api soft-deletes + 503s).

Tests

TestProvision_HonoursCallerDeadline per backend: a 300ms caller ctx fast-fails (<30s, asserted) wrapping context.DeadlineExceeded, instead of blocking for the pod-ready ceiling. make gate green.

Completes the pro-provision-hang fix across all four pod-backed resource types (redis #52 + this).

🤖 Generated with Claude Code

…ovision

The redis k8s backend was fixed for the pro-provision-hang bug (#52) but the postgres, mongo, AND queue backends still derived their provisioning context from context.Background(), discarding the caller's gRPC deadline. When the api caller's deadline fired (or it cancelled the RPC), the provisioner kept blocking up to 5m on a wedged PVC/CSI attach and the api handler hung — the same class that drove the e2e-prod flakiness, for db/nosql/queue instead of cache.

Each backend now derives provCtx from the incoming ctx with a 5m ceiling backstop (min of the two), mirroring redis/k8s.go provisionContext. The api grants a generous provision deadline (provisionTimeout: 4m anon / 5m pro), so legitimate 30-90s pod startup is unaffected; only pathological hangs + early cancellations now fast-fail. waitPodReady already honours ctx.Err() each poll; the shared server.mapError already maps context.DeadlineExceeded/Canceled to retryable gRPC codes, so no server change is needed. Also bounded the rollback namespace-delete to a fresh 30s background ctx (redis parity) so cleanup runs even when the incoming ctx is cancelled without a wedged apiserver pinning the goroutine.

Tests: TestProvision_HonoursCallerDeadline per backend — a 300ms caller ctx fast-fails (<30s) wrapping context.DeadlineExceeded, instead of blocking for the pod-ready ceiling. make gate green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 18e1d64 into master Jun 8, 2026
12 checks passed
@mastermanas805 mastermanas805 deleted the fix/provision-ctx-deadline-pg-mongo-queue branch June 8, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant