@@ -23,6 +23,7 @@ import (
2323 "github.com/Azure/azure-container-networking/common"
2424 "github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha"
2525 "github.com/pkg/errors"
26+ "go.uber.org/zap"
2627)
2728
2829const (
@@ -35,6 +36,9 @@ const (
3536// internal APIs (definde in internalapi.go).
3637// This will be used internally (say by RequestController in case of AKS)
3738
39+ // Initialize a zap logger instance
40+ var zapLogger , _ = zap .NewProduction ()
41+
3842// GetPartitionKey - Get dnc/service partition key
3943func (service * HTTPRestService ) GetPartitionKey () (dncPartitionKey string ) {
4044 service .RLock ()
@@ -631,15 +635,12 @@ func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req *cns.
631635 existingReq := existingNCInfo .CreateNetworkContainerRequest
632636 if ! reflect .DeepEqual (existingReq .IPConfiguration .IPSubnet , req .IPConfiguration .IPSubnet ) {
633637 if req .Scenario != v1alpha .Overlay { // if overlay -> potentially an overlay subnet expansion is occurring, skip this check
634- logger .Errorf ("[Azure CNS] Error. PrimaryCA is not same, NCId %s, old CA %s/%d, new CA %s/%d" ,
635- req .NetworkContainerid ,
636- existingReq .IPConfiguration .IPSubnet .IPAddress ,
637- existingReq .IPConfiguration .IPSubnet .PrefixLength ,
638- req .IPConfiguration .IPSubnet .IPAddress ,
639- req .IPConfiguration .IPSubnet .PrefixLength )
638+ zapLogger .Error ("[Azure CNS] Error. PrimaryCA is not same" ,
639+ zap .String ("NCId" , req .NetworkContainerid ),
640+ zap .String ("oldCA" , fmt .Sprintf ("%s/%d" , existingReq .IPConfiguration .IPSubnet .IPAddress , existingReq .IPConfiguration .IPSubnet .PrefixLength )),
641+ zap .String ("newCA" , fmt .Sprintf ("%s/%d" , req .IPConfiguration .IPSubnet .IPAddress , req .IPConfiguration .IPSubnet .PrefixLength )))
640642 return types .PrimaryCANotSame
641643 }
642- logger .Printf ("[Azure CNS] Its an overlay cluster! Skipping Primary CA check for NCId %s, old CA %s/%d, new CA %s/%d" )
643644 }
644645 }
645646
0 commit comments