Repository navigation
[rds/kubernetes] Time out calls to the API server - #1485
Merged
Merged
Conversation
This was referenced Sep 12, 2026
The kubeapi client was built without an http.Client timeout and its requests carry no context, so only the cloned DefaultTransport's dial and TLS handshake timeouts applied. An API server that completes the handshake and then never sends response headers hung getURL forever. Each lister refreshes from a single goroutine driven by a ticker, so one stuck call freezes that resource type's refresh permanently: targets go stale silently and never recover without a restart. Set a 30s overall timeout, comfortably under the 60s default re_eval_sec. Client.Timeout covers the whole request lifecycle including the body read in getURL, and survives newClient wrapping the transport in oauth2.Transport.
manugarg
force-pushed
the
k8s-client-timeout
branch
from
September 12, 2026 06:08
1bc945a to
3e15948
Compare
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.
The kubeapi client was built without an
http.Clienttimeout and its requests carry no context, so only the clonedDefaultTransport's dial (30s) and TLS handshake (10s) timeouts applied. An API server that completes the handshake and then never sends response headers hangsgetURLforever.Each lister refreshes from a single goroutine driven by a ticker, so one stuck call freezes that resource type's refresh permanently: targets go stale silently and never recover without a restart.
Sets a 30s overall timeout, comfortably under the 60s default
re_eval_secso a slow call is abandoned before the next tick.Client.Timeoutcovers the whole request lifecycle including the body read ingetURL, and survivesnewClientwrapping the transport inoauth2.Transport.oauth.K8STokenSourceis local-file based, so nothing else in this path does I/O.Testing
TestGetURLTimeoutexercises the realgetURLpath against a test server that blocks until the request context is cancelled, plus an assertion inTestNewClientWithTLSthat the constructed client carries the timeout. RemovingTimeoutfrom thehttp.Clientfails the tests.Rebased onto #1486, which landed first. That merge added a
testK8sClienthelper covering exactly this setup, so the test now uses it instead of standing up its own TLS server. Verifiedgo build ./...andgo test -race ./internal/rds/...on the combined tree, not just on this branch's original base.Interaction with #1486
This was the riskier half when the two PRs were opened together: turning stalls into fast errors fed a bug where
expand()emptied the cache on any error, so an API outage would have flapped targets in and out every 60s instead of leaving them quietly stale.That is fixed on
mainas of #1486 —expand()now keeps the last good result when a refresh fails — so this change is strictly safer to merge than when it was written. A stall now surfaces as a logged warning and a retry on the next tick, with the existing targets left in place.