raft: scope join retry context to core shutdown lifecycle#31806
Open
1seal wants to merge 1 commit intohashicorp:mainfrom
Open
raft: scope join retry context to core shutdown lifecycle#318061seal wants to merge 1 commit intohashicorp:mainfrom
1seal wants to merge 1 commit intohashicorp:mainfrom
Conversation
The raft join HTTP handler passes context.Background() into JoinRaftCluster. When retry=true, this can spawn a background retry goroutine that cannot be canceled, because the context never finishes. Add a shutdown-scoped context to Core that is canceled in Core.Shutdown(), and use it in the raft join HTTP handler so that join retry goroutines are automatically stopped when the core shuts down. The config-based retry_join path (InitiateRetryJoin) already receives a properly scoped context from the server command, so it is not affected.
|
@1seal is attempting to deploy a commit to the HashiCorp Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
1seal
commented
Mar 23, 2026
Contributor
Author
1seal
left a comment
There was a problem hiding this comment.
thanks for the review — good call to check.
ShutdownCoreError already routes through Shutdown via ShutdownWait:
func (c *Core) ShutdownCoreError(err error) {
c.Logger().Error("shutting down core", "error", err)
if shutdownErr := c.ShutdownWait(); shutdownErr != nil { // ← calls Shutdown()
...
}
}so shutdownCtxCancel() fires on that path too — no additional wiring needed.
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
JoinRaftCluster.background
/v1/sys/storage/raft/joincurrently passescontext.Background()intoJoinRaftCluster. whenretry=true,JoinRaftClustermay spawn a retry loop that checksctx.Done()but will never observe cancellation.this change adds
Core.ShutdownContext()(canceled inCore.Shutdown()) and uses it in the raft join http handler, so retries are stopped automatically when the core is shutting down.testing
go test ./http/... -run TestNonExistentgo test ./vault/... -run TestNonExistent