Retry apiserver 429s instead of failing the mission - #428
Merged
sisuresh merged 5 commits intoAug 17, 2026
Conversation
A single 429 reaching a caller that does not retry ends a whole mission. That is what killed Jenkins stellar-supercluster #1913: one 429 on a `list events` inside WaitForAllReplicasReady, with no retry on that path. Throttling is routine rather than exceptional on a busy cluster -- ssc-eks served 36,784 429s in the week of 2026-08-17, peaking at 63/s -- so every one of the ~46 apiserver calls in this library is exposed, and nothing makes the one that happened to fail special. Retrying in the HttpClient pipeline covers all of them from one place, and sitting below the generated client means a retried 429 never becomes an exception at all. Only 429 is retried: it proves the request was rejected unapplied, so re-issuing is safe even for a write, whereas a 5xx or a timeout leaves that unknown. DELETE is exempt because every delete site already swallows failure, so retrying there buys fewer orphans at the price of multiplying a teardown that removes hundreds of objects in sequence. The 60s budget stays under HttpClientTimeout (100s), which bounds the whole handler chain and otherwise surfaces as a TaskCanceledException that loses the 429. Verified against injected 429s and against real APF throttling on ssc-test: 6 real rejections absorbed mid-mission, unbounded rejection still fails cleanly at the deadline, and 12 rejected DELETEs are not retried. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds centralized Kubernetes API retry handling for HTTP 429 responses while exempting DELETE requests.
Changes:
- Adds exponential-backoff retry handling with
Retry-Aftersupport. - Installs the handler for all Kubernetes client calls.
- Adds tests for success, DELETE exemption, and deadline behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/FSLibrary/ApiRateLimit.fs |
Implements the retry handler. |
src/FSLibrary/StellarSupercluster.fs |
Installs the handler on the Kubernetes client. |
src/FSLibrary.Tests/Tests.fs |
Adds retry-handler tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The deadline was checked before the wait, so the wait itself was unbudgeted: a 429 arriving at 59s under a 60s budget still waited, and a long Retry-After made the overrun arbitrary. APF sent 16s and 32s hints during testing, which is enough to start an attempt past the deadline and past HttpClientTimeout (100s), where the 429 is replaced by a TaskCanceledException that loses the response body and request path -- the exact diagnosability the 60s budget was chosen to preserve. Clamping to the remaining budget rather than bailing out keeps the whole budget usable: the final attempt still starts, it just starts no later than the deadline. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Replaces clamping the final wait with refusing the attempt outright, per review feedback: the wait now counts against the budget, so a retry is only started when the deadline can cover it. Clamping kept the last attempt inside the deadline but still began an attempt whose own duration was unbounded; refusing outright means the response returned to the caller is always a real 429 with its body and request path, never a TaskCanceledException from HttpClientTimeout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/FSLibrary.Tests/Tests.fs:778
- This wall-clock upper bound can fail even when the handler is correct: the test intentionally waits 500 ms, leaving only 250 ms for scheduler or GC pauses. Please verify the no-extra-delay behavior with an injectable delay/clock instead, so loaded CI workers cannot make this test flaky.
Assert.True(sw.Elapsed < System.TimeSpan.FromMilliseconds 750.0, sprintf "took %O" sw.Elapsed)
ThrottlingStub inherits HttpMessageHandler, which is IDisposable, so F# warns when it is built without `new`. The stub is still disposed by the HttpMessageInvoker's `use` binding, which owns the handler chain. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
sisuresh
approved these changes
Aug 17, 2026
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.
What
ApiRateLimit.ThrottleRetryHandler, aDelegatingHandlerthat retries apiserver429s with exponential backoff.new k8s.Kubernetes(...)site, so all ~46 apiserver calls in the library are covered without touching any call site.DELETEis exempt; only429is retried.Why
429on alist eventsinsideWaitForAllReplicasReadykilled a parallel catchup mission. That path has no retry, so the exception propagated throughMakeFormationand ended the mission.Testing
Unit (
FSLibrary.Tests, 3 new tests, full suite 31/31 green,fantomas --checkclean):DELETEalone429End-to-end on test cluster,
SimplePaymentmission (re-run against the final commit after review changes):3/3 replicas readyHttpOperationExceptioncarrying the 429, noTaskCanceledExceptionLog output
One
WRNper retry, naming the verb, the path, the budget consumed so far, and the next wait. Under real APF throttling on ssc-test:Giving up at the deadline needs no new logging -- the retries above it show the budget climbing, and the existing error path carries the 429 body and stack trace:
Known limitations
DELETEexemption means more orphaned objects during a throttling incident; the orphan sweep is the backstop.LogWarnper retry is loud during a throttling storm.🤖 Generated with Claude Code