Skip to content

Commit f590717

Browse files
authored
chore: consolidating logger package for cns aks swift scenario code (#805)
1 parent 4a17414 commit f590717

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

cns/requestcontroller/kubecontroller/crdtranslator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77

88
"github.com/Azure/azure-container-networking/cns"
9-
"github.com/Azure/azure-container-networking/log"
9+
"github.com/Azure/azure-container-networking/cns/logger"
1010
nnc "github.com/Azure/azure-container-networking/nodenetworkconfig/api/v1alpha"
1111
)
1212

@@ -67,9 +67,9 @@ func CRDStatusToNCRequest(crdStatus nnc.NodeNetworkConfigStatus) (cns.CreateNetw
6767
NCVersion: ncVersion,
6868
}
6969
ncRequest.SecondaryIPConfigs[ipAssignment.Name] = secondaryIPConfig
70-
log.Debugf("Seconday IP Configs got set, name is %s, config is %v", ipAssignment.Name, secondaryIPConfig)
70+
logger.Debugf("Seconday IP Configs got set, name is %s, config is %v", ipAssignment.Name, secondaryIPConfig)
7171
}
72-
log.Printf("Set NC request info with NetworkContainerid %s, NetworkContainerType %s, NC Version %s",
72+
logger.Printf("Set NC request info with NetworkContainerid %s, NetworkContainerType %s, NC Version %s",
7373
ncRequest.NetworkContainerid, ncRequest.NetworkContainerType, ncRequest.Version)
7474
}
7575

cns/restserver/internalapi.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/Azure/azure-container-networking/cns/logger"
1919
"github.com/Azure/azure-container-networking/cns/nmagentclient"
2020
"github.com/Azure/azure-container-networking/common"
21-
"github.com/Azure/azure-container-networking/log"
2221
nnc "github.com/Azure/azure-container-networking/nodenetworkconfig/api/v1alpha"
2322
)
2423

@@ -155,19 +154,19 @@ func (service *HTTPRestService) SyncHostNCVersion(ctx context.Context, channelMo
155154
// Will open a separate PR to convert all the NC version related variable to int. Change from string to int is a pain.
156155
hostVersion, err := strconv.Atoi(containerstatus.HostVersion)
157156
if err != nil {
158-
log.Errorf("Received err when change containerstatus.HostVersion %s to int, err msg %v", containerstatus.HostVersion, err)
157+
logger.Errorf("Received err when change containerstatus.HostVersion %s to int, err msg %v", containerstatus.HostVersion, err)
159158
continue
160159
}
161160
dncNcVersion, err := strconv.Atoi(containerstatus.CreateNetworkContainerRequest.Version)
162161
if err != nil {
163-
log.Errorf("Received err when change nc version %s in containerstatus to int, err msg %v", containerstatus.CreateNetworkContainerRequest.Version, err)
162+
logger.Errorf("Received err when change nc version %s in containerstatus to int, err msg %v", containerstatus.CreateNetworkContainerRequest.Version, err)
164163
continue
165164
}
166165
// 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.
167166
if hostVersion < dncNcVersion {
168167
hostVersionNeedUpdateNcList = append(hostVersionNeedUpdateNcList, containerstatus.ID)
169168
} else if hostVersion > dncNcVersion {
170-
log.Errorf("NC version from NMAgent is larger than DNC, NC version from NMAgent is %d, NC version from DNC is %d", hostVersion, dncNcVersion)
169+
logger.Errorf("NC version from NMAgent is larger than DNC, NC version from NMAgent is %d, NC version from DNC is %d", hostVersion, dncNcVersion)
171170
}
172171
}
173172
service.RUnlock()
@@ -208,7 +207,7 @@ func (service *HTTPRestService) SyncHostNCVersion(ctx context.Context, channelMo
208207
func (service *HTTPRestService) ReconcileNCState(ncRequest *cns.CreateNetworkContainerRequest, podInfoByIp map[string]cns.KubernetesPodInfo, scalar nnc.Scaler, spec nnc.NodeNetworkConfigSpec) int {
209208
// check if ncRequest is null, then return as there is no CRD state yet
210209
if ncRequest == nil {
211-
log.Logf("CNS starting with no NC state, podInfoMap count %d", len(podInfoByIp))
210+
logger.Printf("CNS starting with no NC state, podInfoMap count %d", len(podInfoByIp))
212211
return Success
213212
}
214213

@@ -222,7 +221,7 @@ func (service *HTTPRestService) ReconcileNCState(ncRequest *cns.CreateNetworkCon
222221
// now parse the secondaryIP list, if it exists in PodInfo list, then allocate that ip
223222
for _, secIpConfig := range ncRequest.SecondaryIPConfigs {
224223
if podInfo, exists := podInfoByIp[secIpConfig.IPAddress]; exists {
225-
log.Logf("SecondaryIP %+v is allocated to Pod. %+v, ncId: %s", secIpConfig, podInfo, ncRequest.NetworkContainerid)
224+
logger.Printf("SecondaryIP %+v is allocated to Pod. %+v, ncId: %s", secIpConfig, podInfo, ncRequest.NetworkContainerid)
226225

227226
kubernetesPodInfo := cns.KubernetesPodInfo{
228227
PodName: podInfo.PodName,
@@ -236,11 +235,11 @@ func (service *HTTPRestService) ReconcileNCState(ncRequest *cns.CreateNetworkCon
236235
}
237236

238237
if _, err := requestIPConfigHelper(service, ipconfigRequest); err != nil {
239-
log.Errorf("AllocateIPConfig failed for SecondaryIP %+v, podInfo %+v, ncId %s, error: %v", secIpConfig, podInfo, ncRequest.NetworkContainerid, err)
238+
logger.Errorf("AllocateIPConfig failed for SecondaryIP %+v, podInfo %+v, ncId %s, error: %v", secIpConfig, podInfo, ncRequest.NetworkContainerid, err)
240239
return FailedToAllocateIpConfig
241240
}
242241
} else {
243-
log.Logf("SecondaryIP %+v is not allocated. ncId: %s", secIpConfig, ncRequest.NetworkContainerid)
242+
logger.Printf("SecondaryIP %+v is not allocated. ncId: %s", secIpConfig, ncRequest.NetworkContainerid)
244243
}
245244
}
246245

0 commit comments

Comments
 (0)