This commit is contained in:
Oleh Konko | semantic verification for trust infra | LLM-augmented operations pipeline (precision-first, claim≤evidence, submit-human) | verify the payload, not the signer 2026-03-21 17:29:44 -04:00 committed by GitHub
commit 9e2d300099
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View file

@ -87,7 +87,7 @@ func handleSysRaftJoinPost(core *vault.Core, w http.ResponseWriter, r *http.Requ
},
}
joined, err := core.JoinRaftCluster(context.Background(), leaderInfos, req.NonVoter)
joined, err := core.JoinRaftCluster(core.ShutdownContext(), leaderInfos, req.NonVoter)
if err != nil {
respondError(w, http.StatusInternalServerError, err)
return

View file

@ -314,6 +314,12 @@ type Core struct {
// that the join is complete
raftJoinDoneCh chan struct{}
// shutdownCtx is a context that is canceled when the Core is shut down.
// It is used to scope background operations (such as raft join retries)
// that must not outlive the server process.
shutdownCtx context.Context
shutdownCtxCancel context.CancelFunc
// postUnsealStarted informs the raft retry join routine that unseal key
// validation is completed and post unseal has started so that it can complete
// the join process when Shamir seal is in use
@ -1081,6 +1087,8 @@ func CreateCore(conf *CoreConfig) (*Core, error) {
mountsLock := locking.CreateConfigurableRWMutex(detectDeadlocks, "mountsLock")
authLock := locking.CreateConfigurableRWMutex(detectDeadlocks, "authLock")
shutdownCtx, shutdownCtxCancel := context.WithCancel(context.Background())
// Setup the core
c := &Core{
entCore: entCore{},
@ -1139,6 +1147,8 @@ func CreateCore(conf *CoreConfig) (*Core, error) {
postUnsealStarted: new(uint32),
raftInfo: new(atomic.Value),
raftJoinDoneCh: make(chan struct{}),
shutdownCtx: shutdownCtx,
shutdownCtxCancel: shutdownCtxCancel,
clusterHeartbeatInterval: clusterHeartbeatInterval,
activityLogConfig: conf.ActivityLogConfig,
billingConfig: conf.BillingConfig,
@ -1675,6 +1685,9 @@ func (c *Core) ShutdownCoreError(err error) {
// happens as quickly as possible.
func (c *Core) Shutdown() error {
c.logger.Debug("shutdown called")
if c.shutdownCtxCancel != nil {
c.shutdownCtxCancel()
}
err := c.sealInternal()
c.stateLock.Lock()
@ -1703,6 +1716,15 @@ func (c *Core) ShutdownDone() <-chan struct{} {
return c.shutdownDoneCh.Load().(chan struct{})
}
// ShutdownContext returns a context that is canceled when the Core shuts down.
// Use this for background operations that must not outlive the server process.
func (c *Core) ShutdownContext() context.Context {
if c.shutdownCtx == nil {
return context.Background()
}
return c.shutdownCtx
}
// CORSConfig returns the current CORS configuration
func (c *Core) CORSConfig() *CORSConfig {
return c.corsConfig