fix(provision): honour caller deadline in postgres/mongo/queue k8s Provision#53
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 grantsprovisionTimeout(tier)= 4m anon / 5m pro, comfortably above the 30-90s legitimate pod startup.Fix (mirrors redis #52)
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 +waitPodReadypoll; legitimate startup is unaffected, only hangs/early-cancels fast-fail.waitPodReadyalready honoursctx.Err()each poll, and the sharedserver.mapErroralready mapscontext.DeadlineExceeded/Canceled→ retryable gRPC codes (api soft-deletes + 503s).Tests
TestProvision_HonoursCallerDeadlineper backend: a 300ms caller ctx fast-fails (<30s, asserted) wrappingcontext.DeadlineExceeded, instead of blocking for the pod-ready ceiling.make gategreen.Completes the pro-provision-hang fix across all four pod-backed resource types (redis #52 + this).
🤖 Generated with Claude Code