fix(global/pvc): pvc 刷新 ticker 接受 ctx 并接入 lifecycle#252
Open
fix(global/pvc): pvc 刷新 ticker 接受 ctx 并接入 lifecycle#252
Conversation
InitGlobalData spawned a goroutine that ranged forever over a
120s ticker calling getGlobalData(). No ctx, no done signal -
the loop kept polling K8s past graceful shutdown.
Same shape as the global/node fix: add Data.cancel / Data.done,
switch the loop to select { ctx.Done | tick }, expose Data.Stop(ctx),
and register a "global-data" lifecycle hook in cmd/backend/app/root.go.
Co-authored-by: Cursor <cursoragent@cursor.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.
概要
`pkg/global/pvc.go` 的 `InitGlobalData` 同 B8b 模式:
```go
go func() {
ticker := time.NewTicker(120 * time.Second)
defer ticker.Stop()
for range ticker.C {
GlobalData.getGlobalData()
}
}()
```
`for range ticker.C` 永远不退出,graceful-shutdown 后仍每 120s 打 K8s。
改动
验证方式
Made with Cursor