From b051f39d3720cb4a9a959e8e885784c819b048f8 Mon Sep 17 00:00:00 2001 From: paulyufan2 Date: Tue, 12 Nov 2024 17:57:10 -0500 Subject: [PATCH 1/5] use cns logger lib --- cns/service/main.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cns/service/main.go b/cns/service/main.go index fdb842c828..1bb54b87cd 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -57,7 +57,6 @@ import ( "github.com/Azure/azure-container-networking/crd/nodenetworkconfig" "github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha" acnfs "github.com/Azure/azure-container-networking/internal/fs" - "github.com/Azure/azure-container-networking/log" "github.com/Azure/azure-container-networking/nmagent" "github.com/Azure/azure-container-networking/platform" "github.com/Azure/azure-container-networking/processlock" @@ -365,9 +364,9 @@ func init() { // Wait until receiving a signal. select { case sig := <-sigCh: - log.Errorf("caught exit signal %v, exiting", sig) + logger.Errorf("caught exit signal %v, exiting", sig) case err := <-rootErrCh: - log.Errorf("unhandled error %v, exiting", err) + logger.Errorf("unhandled error %v, exiting", err) } cancel() }() @@ -428,7 +427,7 @@ func sendRegisterNodeRequest(ctx context.Context, httpClient httpDoer, httpRestS var body bytes.Buffer err := json.NewEncoder(&body).Encode(nodeRegisterRequest) if err != nil { - log.Errorf("[Azure CNS] Failed to register node while encoding json failed with non-retryable err %v", err) + logger.Errorf("[Azure CNS] Failed to register node while encoding json failed with non-retryable err %v", err) return errors.Wrap(retry.Unrecoverable(err), "failed to sendRegisterNodeRequest") } @@ -454,7 +453,7 @@ func sendRegisterNodeRequest(ctx context.Context, httpClient httpDoer, httpRestS var req cns.SetOrchestratorTypeRequest err = json.NewDecoder(response.Body).Decode(&req) if err != nil { - log.Errorf("[Azure CNS] decoding Node Register response json failed with err %v", err) + logger.Errorf("[Azure CNS] decoding Node Register response json failed with err %v", err) return errors.Wrap(err, "failed to sendRegisterNodeRequest") } httpRestService.SetNodeOrchestrator(&req) @@ -469,7 +468,7 @@ func startTelemetryService(ctx context.Context) { tb := telemetry.NewTelemetryBuffer(nil) err := tb.CreateAITelemetryHandle(config, false, false, false) if err != nil { - log.Errorf("AI telemetry handle creation failed..:%w", err) + logger.Errorf("AI telemetry handle creation failed..:%w", err) return } @@ -478,9 +477,9 @@ func startTelemetryService(ctx context.Context) { tbtemp.Cleanup(telemetry.FdName) err = tb.StartServer() - log.Printf("Telemetry service for CNI started") + logger.Printf("Telemetry service for CNI started") if err != nil { - log.Errorf("Telemetry service failed to start: %w", err) + logger.Errorf("Telemetry service failed to start: %w", err) return } tb.PushData(ctx) @@ -1484,7 +1483,7 @@ func InitializeCRDState(ctx context.Context, httpRestService cns.HTTPService, cn // this false and the NNC Reconciler stuck/failed, log and retry. nncReadyCtx, cancel := context.WithTimeout(ctx, 15*time.Minute) //nolint // it will time out and not leak if started, err := nncReconciler.Started(nncReadyCtx); !started { - log.Errorf("NNC reconciler has not started, does the NNC exist? err: %v", err) + logger.Errorf("NNC reconciler has not started, does the NNC exist? err: %v", err) nncReconcilerStartFailures.Inc() continue } From 83654e2023236bdc443521980d5a18d17cbbc30f Mon Sep 17 00:00:00 2001 From: paulyufan2 Date: Tue, 12 Nov 2024 18:04:57 -0500 Subject: [PATCH 2/5] use cns logger lib --- cns/service/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cns/service/main.go b/cns/service/main.go index 1bb54b87cd..1a2e11b51b 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -57,6 +57,7 @@ import ( "github.com/Azure/azure-container-networking/crd/nodenetworkconfig" "github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha" acnfs "github.com/Azure/azure-container-networking/internal/fs" + "github.com/Azure/azure-container-networking/log" "github.com/Azure/azure-container-networking/nmagent" "github.com/Azure/azure-container-networking/platform" "github.com/Azure/azure-container-networking/processlock" From 9ca70d9ebf9f26d97893cf6a07e2e0255a3a9984 Mon Sep 17 00:00:00 2001 From: paulyufan2 Date: Tue, 12 Nov 2024 18:14:02 -0500 Subject: [PATCH 3/5] fix linter issues --- cns/service/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cns/service/main.go b/cns/service/main.go index 1a2e11b51b..590164a96e 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -469,7 +469,7 @@ func startTelemetryService(ctx context.Context) { tb := telemetry.NewTelemetryBuffer(nil) err := tb.CreateAITelemetryHandle(config, false, false, false) if err != nil { - logger.Errorf("AI telemetry handle creation failed..:%w", err) + logger.Errorf("[Azure CNS] AI telemetry handle creation failed: %v", err) return } @@ -480,7 +480,7 @@ func startTelemetryService(ctx context.Context) { err = tb.StartServer() logger.Printf("Telemetry service for CNI started") if err != nil { - logger.Errorf("Telemetry service failed to start: %w", err) + logger.Errorf("[Azure CNS] Telemetry service failed to start: %v", err) return } tb.PushData(ctx) From f558c535439b193452ff76e3f72e0233dac9fc98 Mon Sep 17 00:00:00 2001 From: paulyufan2 Date: Tue, 12 Nov 2024 18:23:06 -0500 Subject: [PATCH 4/5] add [Azure CNS] --- cns/service/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cns/service/main.go b/cns/service/main.go index 590164a96e..195d77ad86 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -478,7 +478,7 @@ func startTelemetryService(ctx context.Context) { tbtemp.Cleanup(telemetry.FdName) err = tb.StartServer() - logger.Printf("Telemetry service for CNI started") + logger.Printf("[Azure CNS] Telemetry service for CNI started") if err != nil { logger.Errorf("[Azure CNS] Telemetry service failed to start: %v", err) return From f2b1884c7e0be7d86ada4b8e11e46f285b7bcd1d Mon Sep 17 00:00:00 2001 From: paulyufan2 Date: Thu, 21 Nov 2024 10:32:47 -0500 Subject: [PATCH 5/5] remove [Azure CNS] log --- cns/service/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cns/service/main.go b/cns/service/main.go index 195d77ad86..36f24dffa7 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -428,7 +428,7 @@ func sendRegisterNodeRequest(ctx context.Context, httpClient httpDoer, httpRestS var body bytes.Buffer err := json.NewEncoder(&body).Encode(nodeRegisterRequest) if err != nil { - logger.Errorf("[Azure CNS] Failed to register node while encoding json failed with non-retryable err %v", err) + logger.Errorf("Failed to register node while encoding json failed with non-retryable err %v", err) return errors.Wrap(retry.Unrecoverable(err), "failed to sendRegisterNodeRequest") } @@ -454,7 +454,7 @@ func sendRegisterNodeRequest(ctx context.Context, httpClient httpDoer, httpRestS var req cns.SetOrchestratorTypeRequest err = json.NewDecoder(response.Body).Decode(&req) if err != nil { - logger.Errorf("[Azure CNS] decoding Node Register response json failed with err %v", err) + logger.Errorf("decoding Node Register response json failed with err %v", err) return errors.Wrap(err, "failed to sendRegisterNodeRequest") } httpRestService.SetNodeOrchestrator(&req) @@ -469,7 +469,7 @@ func startTelemetryService(ctx context.Context) { tb := telemetry.NewTelemetryBuffer(nil) err := tb.CreateAITelemetryHandle(config, false, false, false) if err != nil { - logger.Errorf("[Azure CNS] AI telemetry handle creation failed: %v", err) + logger.Errorf("AI telemetry handle creation failed: %v", err) return } @@ -478,9 +478,9 @@ func startTelemetryService(ctx context.Context) { tbtemp.Cleanup(telemetry.FdName) err = tb.StartServer() - logger.Printf("[Azure CNS] Telemetry service for CNI started") + logger.Printf("Telemetry service for CNI started") if err != nil { - logger.Errorf("[Azure CNS] Telemetry service failed to start: %v", err) + logger.Errorf("Telemetry service failed to start: %v", err) return } tb.PushData(ctx)