mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-07 06:01:40 +02:00
fix: suppress kubedog context canceled errors
- Use klog.Background() to suppress INFO level warnings - Filter context canceled and related errors during normal shutdown - Simplified implementation without modifying runtime.ErrorHandlers This is a cleaner and more idiomatic solution that: resolves the lint error: - Cannot reassign variables from other packages (reassign) - Remove unused shouldFilter function (unused) Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package kubedog
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
errorHandlersInitOnce sync.Once
|
||||
)
|
||||
|
||||
func initErrorHandlers() {
|
||||
errorHandlersInitOnce.Do(func() {
|
||||
klog.SetLogger(klog.Background())
|
||||
})
|
||||
}
|
||||
@@ -66,6 +66,8 @@ type TrackerConfig struct {
|
||||
}
|
||||
|
||||
func NewTracker(config *TrackerConfig) (*Tracker, error) {
|
||||
initErrorHandlers()
|
||||
|
||||
logger := config.Logger
|
||||
if logger == nil {
|
||||
logger = zap.NewNop().Sugar()
|
||||
|
||||
Reference in New Issue
Block a user