@@ -108,7 +108,7 @@ func (service *HTTPRestService) SyncNodeStatus(dncEP, infraVnet, nodeID string,
108108 ncVersionListResp , err := service .nma .GetNCVersionList (ctx )
109109 if err != nil {
110110 skipNCVersionCheck = true
111- logger .Errorf ("failed to get nc version list from nmagent" )
111+ logger .Errorf ("Failed to retrieve network container version list from NMAgent, skipping version validation: %v" , err )
112112 }
113113
114114 if ! skipNCVersionCheck {
@@ -123,11 +123,11 @@ func (service *HTTPRestService) SyncNodeStatus(dncEP, infraVnet, nodeID string,
123123
124124 body , err = json .Marshal (ncsToBeAdded [ncid ])
125125 if err != nil {
126- logger .Errorf ("[Azure-CNS] Failed to marshal nc with nc id %s and content %v" , ncid , ncsToBeAdded [ ncid ] )
126+ logger .Errorf ("[Azure-CNS] Failed to marshal network container request for NC ID %s during sync: %v" , ncid , err )
127127 }
128128 req , err = http .NewRequestWithContext (ctx , http .MethodPost , "" , bytes .NewBuffer (body ))
129129 if err != nil {
130- logger .Errorf ("[Azure CNS] Error received while creating http POST request for nc % v" , ncsToBeAdded [ ncid ] )
130+ logger .Errorf ("[Azure CNS] Failed to create HTTP POST request for network container %s during sync: % v" , ncid , err )
131131 }
132132 req .Header .Set (common .ContentType , common .JsonContent )
133133
@@ -162,7 +162,7 @@ func (service *HTTPRestService) SyncNodeStatus(dncEP, infraVnet, nodeID string,
162162 req .Header .Set (common .JsonContent , common .JsonContent )
163163 service .deleteNetworkContainer (httptest .NewRecorder (), req )
164164 } else {
165- logger .Errorf ("[Azure-CNS] Failed to delete NC request to sync state: %s" , err .Error ())
165+ logger .Errorf ("[Azure-CNS] Failed to marshal delete NC request body during state sync for NC ID %s : %s" , ncID , err .Error ())
166166 }
167167 }
168168 return
@@ -182,7 +182,7 @@ func (service *HTTPRestService) SyncHostNCVersion(ctx context.Context, channelMo
182182 go service .MustGenerateCNIConflistOnce ()
183183 }
184184 if err != nil {
185- logger .Errorf ("sync host error %v" , err )
185+ logger .Errorf ("Failed to synchronize host network container versions with NMAgent: %v" , err )
186186 }
187187 syncHostNCVersionCount .WithLabelValues (strconv .FormatBool (err == nil )).Inc ()
188188 syncHostNCVersionLatency .WithLabelValues (strconv .FormatBool (err == nil )).Observe (time .Since (start ).Seconds ())
@@ -201,19 +201,19 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo
201201 // Will open a separate PR to convert all the NC version related variable to int. Change from string to int is a pain.
202202 localNCVersion , err := strconv .Atoi (service .state .ContainerStatus [idx ].HostVersion )
203203 if err != nil {
204- logger .Errorf ("Received err when change containerstatus.HostVersion %s to int, err msg % v" , service .state .ContainerStatus [idx ].HostVersion , err )
204+ logger .Errorf ("Failed to parse NC host version string '%s' to integer for container %s: % v" , service .state .ContainerStatus [idx ].HostVersion , service . state . ContainerStatus [ idx ]. ID , err )
205205 continue
206206 }
207207 dncNCVersion , err := strconv .Atoi (service .state .ContainerStatus [idx ].CreateNetworkContainerRequest .Version )
208208 if err != nil {
209- logger .Errorf ("Received err when change nc version %s in containerstatus to int, err msg % v" , service .state .ContainerStatus [idx ].CreateNetworkContainerRequest .Version , err )
209+ logger .Errorf ("Failed to parse NC version string '%s' to integer from DNC for container %s: % v" , service .state .ContainerStatus [idx ].CreateNetworkContainerRequest .Version , service . state . ContainerStatus [ idx ]. ID , err )
210210 continue
211211 }
212212 // host NC version is the NC version from NMAgent, if it's smaller than NC version from DNC, then append it to indicate it needs update.
213213 if localNCVersion < dncNCVersion {
214214 outdatedNCs [service .state .ContainerStatus [idx ].ID ] = struct {}{}
215215 } else if localNCVersion > dncNCVersion {
216- logger .Errorf ("NC version from NMAgent is larger than DNC, NC version from NMAgent is %d, NC version from DNC is %d " , localNCVersion , dncNCVersion )
216+ logger .Errorf ("Network container version inconsistency detected: NMAgent version (%d) is greater than DNC version (%d) for NC %s " , localNCVersion , dncNCVersion , service . state . ContainerStatus [ idx ]. ID )
217217 }
218218
219219 if localNCVersion > - 1 {
@@ -263,7 +263,7 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo
263263 }
264264 nmaProgrammedNCVersion , err := strconv .Atoi (nmaProgrammedNCVersionStr )
265265 if err != nil {
266- logger .Errorf ("failed to parse container version of %s : %s" , ncID , err )
266+ logger .Errorf ("Failed to parse NC version string '%s' from NMAgent for container %s : %s" , nmaProgrammedNCVersionStr , ncID , err )
267267 continue
268268 }
269269 // Check whether it exist in service state and get the related nc info
@@ -280,12 +280,12 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo
280280
281281 localNCVersion , err := strconv .Atoi (ncInfo .HostVersion )
282282 if err != nil {
283- logger .Errorf ("failed to parse host nc version string %s : %s" , ncInfo .HostVersion , err )
283+ logger .Errorf ("Failed to parse host NC version string '%s' to integer for container %s : %s" , ncInfo .HostVersion , ncID , err )
284284 continue
285285 }
286286 if localNCVersion > nmaProgrammedNCVersion {
287287 //nolint:staticcheck // SA1019: suppress deprecated logger.Printf usage. Todo: legacy logger usage is consistent in cns repo. Migrates when all logger usage is migrated
288- logger .Errorf ("NC version from consolidated sources is decreasing: have %d, got %d" , localNCVersion , nmaProgrammedNCVersion )
288+ logger .Errorf ("Network container version regression detected for NC %s: local version %d is greater than NMAgent programmed version %d" , ncID , localNCVersion , nmaProgrammedNCVersion )
289289 continue
290290 }
291291 if channelMode == cns .CRD {
@@ -342,7 +342,7 @@ func (service *HTTPRestService) ReconcileIPAssignment(podInfoByIP map[string]cns
342342
343343 podKeyToPodIPs , err := newPodKeyToPodIPsMap (podInfoByIP )
344344 if err != nil {
345- logger .Errorf ("could not transform pods indexed by IP address to pod IPs indexed by interface : %v" , err )
345+ logger .Errorf ("Failed to transform pod IP address map to interface-indexed pod IP map during reconciliation : %v" , err )
346346 return types .UnexpectedError
347347 }
348348
@@ -368,7 +368,7 @@ func (service *HTTPRestService) ReconcileIPAssignment(podInfoByIP map[string]cns
368368 } else {
369369 // it might still be possible to see host networking pods here (where ips are not from ncs) if we are restoring using the kube podinfo provider
370370 // todo: once kube podinfo provider reconcile flow is removed, this line will not be necessary/should be removed.
371- logger .Errorf ("ip %s assigned to pod %+v but not found in any nc " , ip , podIPs )
371+ logger .Errorf ("IP address %s is assigned to pod %+v but was not found in any network container " , ip , podIPs )
372372 }
373373 }
374374
@@ -379,7 +379,7 @@ func (service *HTTPRestService) ReconcileIPAssignment(podInfoByIP map[string]cns
379379
380380 jsonContext , err := podIPs .OrchestratorContext ()
381381 if err != nil {
382- logger .Errorf ("Failed to marshal KubernetesPodInfo, error : %v" , err )
382+ logger .Errorf ("Failed to marshal KubernetesPodInfo to JSON for pod %s : %v" , podKey , err )
383383 return types .UnexpectedError
384384 }
385385
@@ -431,7 +431,7 @@ func (service *HTTPRestService) ReconcileIPAMStateForSwift(ncReqs []*cns.CreateN
431431 }
432432
433433 if err := service .MarkExistingIPsAsPendingRelease (nnc .Spec .IPsNotInUse ); err != nil {
434- logger .Errorf ("[Azure CNS] Error. Failed to mark IPs as pending %v" , nnc . Spec . IPsNotInUse )
434+ logger .Errorf ("[Azure CNS] Failed to mark unused IPs as pending release from NodeNetworkConfig: %v" , err )
435435 return types .UnexpectedError
436436 }
437437
@@ -444,7 +444,7 @@ func (service *HTTPRestService) ReconcileIPAMStateForNodeSubnet(ncReqs []*cns.Cr
444444 logger .Printf ("Reconciling CNS IPAM state with nc requests: [%+v], PodInfo [%+v]" , ncReqs , podInfoByIP )
445445
446446 if len (ncReqs ) != 1 {
447- logger .Errorf ("Nodesubnet should always have 1 NC to hold secondary IPs" )
447+ logger .Errorf ("Node subnet mode requires exactly 1 network container for secondary IPs, but found %d" , len ( ncReqs ) )
448448 return types .NetworkContainerNotSpecified
449449 }
450450
@@ -577,7 +577,7 @@ func (service *HTTPRestService) MustEnsureNoStaleNCs(validNCIDs []string) {
577577 panic (msg )
578578 }
579579
580- logger .Errorf ("[Azure CNS] Found stale NC ID %s in CNS state. Removing..." , ncID )
580+ logger .Errorf ("[Azure CNS] Found stale network container ID %s in CNS state with no assigned IPs . Removing from state ..." , ncID )
581581 delete (service .state .ContainerStatus , ncID )
582582 mutated = true
583583 }
@@ -591,14 +591,14 @@ func (service *HTTPRestService) MustEnsureNoStaleNCs(validNCIDs []string) {
591591// This API will be called by CNS RequestController on CRD update.
592592func (service * HTTPRestService ) CreateOrUpdateNetworkContainerInternal (req * cns.CreateNetworkContainerRequest ) types.ResponseCode {
593593 if req .NetworkContainerid == "" {
594- logger .Errorf ("[Azure CNS] Error. NetworkContainerid is empty" )
594+ logger .Errorf ("[Azure CNS] Network container ID is empty in CreateOrUpdateNetworkContainer request " )
595595 return types .NetworkContainerNotSpecified
596596 }
597597
598598 // For now only RequestController uses this API which will be initialized only for AKS scenario.
599599 // Validate ContainerType is set as Docker
600600 if service .state .OrchestratorType != cns .KubernetesCRD && service .state .OrchestratorType != cns .Kubernetes {
601- logger .Errorf ("[Azure CNS] Error. Unsupported OrchestratorType: %s " , service .state .OrchestratorType )
601+ logger .Errorf ("[Azure CNS] Unsupported orchestrator type %s for CreateOrUpdateNetworkContainer operation " , service .state .OrchestratorType )
602602 return types .UnsupportedOrchestratorType
603603 }
604604
0 commit comments