Commit 05fae56
fix(provisioner): bound ProvisionCache gRPC with a 45s deadline
Authed /cache/new (PRO Redis provision) was observed hanging >60s while
anonymous /cache/new returned in ~6s. The provisioner-side root cause is
fixed separately; this is the defensive api-side guard.
provClient ALREADY applies a per-call deadline to every provision RPC via
provisionTimeout(tier) — the issue is the value: 4m (anon/free/hobby) and
5m (pro/team/growth). Those budgets exist for Postgres/Mongo, which spin up
a per-tenant pod (PVC bind + image pull + DB init, 30-90s on a cold node).
A Redis namespace carve does none of that (~1-6s for every tier), so a hung
provisioner could hang the whole /cache/new request for up to 5 minutes.
Introduce cacheProvisionTimeout = 45s (named, no inline magic number; a
package var so the timeout->503 unit test can shrink it) and use it in
ProvisionCache only. 45s is ~7x the slowest observed healthy carve, so a
legitimately slow-but-OK provision still succeeds while a genuine hang
fails fast. On timeout the existing handler path runs unchanged:
soft-delete the pending resource + 503 provision_failed — no orphan, no hang.
db/vector/nosql/queue intentionally keep provisionTimeout(tier): they are
pod-backed and genuinely need the cold-pod budget; tightening them to 45s
would regress legitimate slow provisions. Noted as a deliberate non-change.
Tests (internal/provisioner, no DB needed):
- TestProvisionCache_HangBecomesDeadlineError: blocking mock provisioner ->
ProvisionCache returns gRPC DeadlineExceeded in ~the bounded window, not
an indefinite hang (the error the handler turns into a 503).
- TestCacheProvisionTimeout_Value: pins 45s and asserts it stays tighter
than provisionTimeout(pro) so a future edit can't silently reintroduce
the multi-minute hang.
ProvisionCache coverage 100%.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9239227 commit 05fae56
2 files changed
Lines changed: 111 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
36 | 58 | | |
37 | 59 | | |
38 | 60 | | |
| |||
313 | 335 | | |
314 | 336 | | |
315 | 337 | | |
316 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
317 | 342 | | |
318 | 343 | | |
319 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
| |||
411 | 425 | | |
412 | 426 | | |
413 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
414 | 499 | | |
415 | 500 | | |
416 | 501 | | |
| |||
0 commit comments