Repository navigation
Conversation
Signed-off-by: Roc Ribera <roc@mailerlite.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.
Summary
NewClientpings Redis once and returns an error if that fails, so a process that starts while Redis is briefly unavailable exits. In Kubernetes this puts the ToolHive proxy (embedded auth server with Redis storage) into CrashLoopBackOff whenever Redis is rescheduled at the same time as the proxies, for example after a node failure.This adds an opt-in
Config.ConnectRetryTimeout:NewClientretries the initial PING with backoff (100ms, doubling, capped at 2s) until it succeeds, the timeout elapses, or the caller's context is done. The timeout bounds every attempt, including the first, so the total wait never exceeds it, which callers can size against Kubernetes probe budgets.WRONGPASS/NOAUTH), permission (NOPERM) and TLS certificate verification errors, so a misconfiguration isn't hidden behind the retry window.connection refused) rather than the deadline error, so the cause stays visible. If the caller's context ended, its error is joined in, soerrors.Is(err, context.Canceled)still works.Validate.The embedded auth server will opt in, with a default, in a follow-up PR in toolhive.
Refs stacklok/toolhive#7260
Test plan
task(lint + tests)scripts/check-redisconn-modules.sh, andgo mod tidy/verify,go vet,go test -racefor eachredisconnmoduleTestNewClientConnectRetry:context.DeadlineExceededTestConfigValidatecase for a negative timeout