fix(integration): NewIntegrationManager 改为返回 error,不再 panic#247
Merged
Conversation
NewIntegrationManager called panic(err) on three different K8s client construction failures. Any transient API-server issue at startup would dump a panic stack into the log instead of a clear single-line failure. Return an error and let cmd/backend/app/root.go decide. The caller now does klog.Fatal with a clean "init integration manager: <err>" message - same observable outcome (process exits) but no library panic in the logs. 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/integration/integration.go` 的 `NewIntegrationManager` 在三处 K8s client 构造失败时直接 `panic(err)`:
```go
config, err := ctrl.GetConfig(); if err != nil { panic(err) }
client, err := dynamic.NewForConfig(config); if err != nil { panic(err) }
kubeClient, err := kubernetes.NewForConfig(); if err != nil { panic(err) }
```
启动期 API server 短暂抖动就会让进程吐 panic stack 而不是一行清晰的失败原因。库代码 panic 也让上层无法选择是 fatal 还是降级。
改动
观感和原来一致(启动失败就退出),但日志里看到的是 "init integration manager: ..." 而非 panic backtrace。
验证方式
Made with Cursor