From 11307e99cdaab741018467b15127ee329afd98b3 Mon Sep 17 00:00:00 2001 From: paulyu Date: Wed, 8 Oct 2025 14:04:15 +0000 Subject: [PATCH 1/2] fix cns zap logger issue --- cns/logger/cnslogger.go | 7 ++++++- cns/restserver/metrics.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cns/logger/cnslogger.go b/cns/logger/cnslogger.go index 5289259903..49d6dad45a 100644 --- a/cns/logger/cnslogger.go +++ b/cns/logger/cnslogger.go @@ -45,7 +45,12 @@ func New(fileName string, logLevel, logTarget int, logDir string) (loggershim, e if err != nil { l.Errorf("Failed to get zap Platform cores: %v", err) } - zapLogger := zap.New(platformCore, zap.AddCaller()).With(zap.Int("pid", os.Getpid())) + + zapLogger := zap.New( + platformCore, + zap.AddCaller(), + zap.AddStacktrace(zapcore.WarnLevel), + ).With(zap.Int("pid", os.Getpid())) return &logger{ logger: l, diff --git a/cns/restserver/metrics.go b/cns/restserver/metrics.go index b4c0dae8dd..39a472ec57 100644 --- a/cns/restserver/metrics.go +++ b/cns/restserver/metrics.go @@ -219,7 +219,7 @@ func (a *asyncMetricsRecorder) record() { func (service *HTTPRestService) publishIPStateMetrics() { recorder.once.Do(func() { recorder.podIPConfigSrc = service.PodIPConfigStates - recorder.sig = make(chan struct{}) + recorder.sig = make(chan struct{}, 1) go recorder.run() }) select { From 7310ebb0b225d9910177f299b8acc96f2dad8807 Mon Sep 17 00:00:00 2001 From: paulyu Date: Wed, 8 Oct 2025 14:43:02 +0000 Subject: [PATCH 2/2] fix linter issue --- cns/logger/cnslogger.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cns/logger/cnslogger.go b/cns/logger/cnslogger.go index 49d6dad45a..81b91045f3 100644 --- a/cns/logger/cnslogger.go +++ b/cns/logger/cnslogger.go @@ -45,11 +45,11 @@ func New(fileName string, logLevel, logTarget int, logDir string) (loggershim, e if err != nil { l.Errorf("Failed to get zap Platform cores: %v", err) } - - zapLogger := zap.New( + + zapLogger := zap.New( platformCore, zap.AddCaller(), - zap.AddStacktrace(zapcore.WarnLevel), + zap.AddStacktrace(zapcore.WarnLevel), ).With(zap.Int("pid", os.Getpid())) return &logger{