internal/rest/resources/control: retry remaining join addresses on client connect err#760
internal/rest/resources/control: retry remaining join addresses on client connect err#760claudiubelu wants to merge 1 commit into
Conversation
…ient connect err When joining a cluster, joinWithToken iterates over all addresses in the token to find a reachable cluster member. However, if state.Connect().Member fails for an address, the function returns immediately instead of trying the next address. This is inconsistent with how other failures in the same loop are handled (GetRemoteCertificate and AddClusterMember both continue to the next address on error). The function now iterates over all the join addresses in this scenario. Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
|
@roosterfish, could you please take a quick glance? |
| client, err := state.Connect().Member(&url.URL, false, cert) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| logger.Warn("Failed to get client for cluster member", slog.String("address", url.String()), slog.String("error", err.Error())) |
There was a problem hiding this comment.
I suspect we currently simply return the error as the call to shared.GetRemoteCertificate should have already failed if it's not reachable.
Would you mind sharing a reproducer how to trigger this?
There was a problem hiding this comment.
Marking as draft until you get a chance to get back to it @claudiubelu.
There was a problem hiding this comment.
Pull request overview
This PR improves cluster join robustness in the internal REST control resource by ensuring join attempts continue across all addresses in a join token when connecting to a member fails, aligning this failure mode with the existing “try next address” behavior for other join-step errors.
Changes:
- Continue iterating over
token.JoinAddresseswhenstate.Connect().Member(...)fails, rather than returning immediately. - Emit a warning log for connection/client creation failures and preserve the last error for final reporting.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| client, err := state.Connect().Member(&url.URL, false, cert) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| logger.Warn("Failed to get client for cluster member", slog.String("address", url.String()), slog.String("error", err.Error())) | ||
| lastErr = err | ||
| continue |
When joining a cluster,
joinWithTokeniterates over all addresses in the token to find a reachable cluster member.However, if
state.Connect().Memberfails for an address, the function returns immediately instead of trying the next address. This is inconsistent with how other failures in the same loop are handled (GetRemoteCertificateandAddClusterMemberboth continue to the next address on error).The function now iterates over all the join addresses in this scenario.