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:
parent
615e8132ee
commit
4950e4239a
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue