Skip to content

Commit 6c6c4a4

Browse files
authored
chore: remove redundant logs (#2642)
* initial log cleanup * address feedback * undo modifying deprecated mode files
1 parent f7f13eb commit 6c6c4a4

File tree

9 files changed

+20
-55
lines changed

9 files changed

+20
-55
lines changed

cni/network/invoker_cns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func (invoker *CNSIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, erro
8888
PodNamespace: invoker.podNamespace,
8989
}
9090

91-
logger.Info(podInfo.PodName)
9291
orchestratorContext, err := json.Marshal(podInfo)
9392
if err != nil {
93+
logger.Info(podInfo.PodName)
9494
return IPAMAddResult{}, errors.Wrap(err, "Failed to unmarshal orchestrator context during add: %w")
9595
}
9696

cni/network/network.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,6 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
980980

981981
logger.Info("Execution mode", zap.String("mode", nwCfg.ExecutionMode))
982982
if nwCfg.ExecutionMode == string(util.Baremetal) {
983-
984-
logger.Info("Baremetal mode. Calling vnet agent for delete container")
985-
986983
// schedule send metric before attempting delete
987984
defer sendMetricFunc()
988985
_, err = plugin.nnsClient.DeleteContainerNetworking(context.Background(), k8sPodName, args.Netns)
@@ -1254,16 +1251,12 @@ func (plugin *NetPlugin) Update(args *cniSkel.CmdArgs) error {
12541251
targetEpInfo := &network.EndpointInfo{}
12551252

12561253
// get the target routes that should replace existingEpInfo.Routes inside the network namespace
1257-
logger.Info("Going to collect target routes for from targetNetworkConfig",
1258-
zap.String("pod", k8sPodName),
1259-
zap.String("namespace", k8sNamespace))
12601254
if targetNetworkConfig.Routes != nil && len(targetNetworkConfig.Routes) > 0 {
12611255
for _, route := range targetNetworkConfig.Routes {
1262-
logger.Info("Adding route from routes to targetEpInfo", zap.Any("route", route))
1256+
logger.Info("Adding route from routes from targetNetworkConfig to targetEpInfo", zap.Any("route", route))
12631257
_, dstIPNet, _ := net.ParseCIDR(route.IPAddress)
12641258
gwIP := net.ParseIP(route.GatewayIPAddress)
12651259
targetEpInfo.Routes = append(targetEpInfo.Routes, network.RouteInfo{Dst: *dstIPNet, Gw: gwIP, DevName: existingEpInfo.IfName})
1266-
logger.Info("Successfully added route from routes to targetEpInfo", zap.Any("route", route))
12671260
}
12681261
}
12691262

@@ -1278,7 +1271,6 @@ func (plugin *NetPlugin) Update(args *cniSkel.CmdArgs) error {
12781271
gwIP := net.ParseIP(ipconfig.GatewayIPAddress)
12791272
route := network.RouteInfo{Dst: dstIPNet, Gw: gwIP, DevName: existingEpInfo.IfName}
12801273
targetEpInfo.Routes = append(targetEpInfo.Routes, route)
1281-
logger.Info("Successfully added route from cnetAddressspace to targetEpInfo", zap.Any("subnet", ipRouteSubnet))
12821274
}
12831275

12841276
logger.Info("Finished collecting new routes in targetEpInfo", zap.Any("route", targetEpInfo.Routes))

network/endpoint.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,48 +309,43 @@ func (ep *endpoint) detach() error {
309309
}
310310

311311
// updateEndpoint updates an existing endpoint in the network.
312-
func (nm *networkManager) updateEndpoint(nw *network, exsitingEpInfo *EndpointInfo, targetEpInfo *EndpointInfo) error {
312+
func (nm *networkManager) updateEndpoint(nw *network, existingEpInfo, targetEpInfo *EndpointInfo) error {
313313
var err error
314314

315-
logger.Info("Updating existing endpoint in network to target", zap.Any("exsitingEpInfo", exsitingEpInfo),
315+
logger.Info("Updating existing endpoint in network to target", zap.Any("existingEpInfo", existingEpInfo),
316316
zap.String("id", nw.Id), zap.Any("targetEpInfo", targetEpInfo))
317317
defer func() {
318318
if err != nil {
319-
logger.Error("Failed to update endpoint with err", zap.String("id", exsitingEpInfo.Id), zap.Error(err))
319+
logger.Error("Failed to update endpoint with err", zap.String("id", existingEpInfo.Id), zap.Error(err))
320320
}
321321
}()
322322

323-
logger.Info("Trying to retrieve endpoint id", zap.String("id", exsitingEpInfo.Id))
324-
325-
ep := nw.Endpoints[exsitingEpInfo.Id]
323+
ep := nw.Endpoints[existingEpInfo.Id]
326324
if ep == nil {
327325
return errEndpointNotFound
328326
}
329327

330328
logger.Info("Retrieved endpoint to update", zap.Any("ep", ep))
331329

332330
// Call the platform implementation.
333-
ep, err = nm.updateEndpointImpl(nw, exsitingEpInfo, targetEpInfo)
331+
ep, err = nm.updateEndpointImpl(nw, existingEpInfo, targetEpInfo)
334332
if err != nil {
335333
return err
336334
}
337335

338336
// Update routes for existing endpoint
339-
nw.Endpoints[exsitingEpInfo.Id].Routes = ep.Routes
337+
nw.Endpoints[existingEpInfo.Id].Routes = ep.Routes
340338

341339
return nil
342340
}
343341

344342
func GetPodNameWithoutSuffix(podName string) string {
345343
nameSplit := strings.Split(podName, "-")
346-
logger.Info("namesplit", zap.Any("nameSplit", nameSplit))
347344
if len(nameSplit) > 2 {
348345
nameSplit = nameSplit[:len(nameSplit)-2]
349346
} else {
350347
return podName
351348
}
352-
353-
logger.Info("Pod name after splitting based on", zap.Any("nameSplit", nameSplit))
354349
return strings.Join(nameSplit, "-")
355350
}
356351

network/endpoint_linux.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,9 @@ func (nw *network) newEndpointImpl(
232232

233233
if epInfo.IPV6Mode != "" {
234234
// Enable ipv6 setting in container
235-
logger.Info("Enable ipv6 setting in container.")
236235
nuc := networkutils.NewNetworkUtils(nl, plc)
237236
if epErr := nuc.UpdateIPV6Setting(0); epErr != nil {
238-
return fmt.Errorf("Enable ipv6 in container failed:%w", epErr)
237+
return fmt.Errorf("enable ipv6 in container failed:%w", epErr)
239238
}
240239
}
241240

@@ -270,7 +269,6 @@ func (nw *network) deleteEndpointImpl(nl netlink.NetlinkInterface, plc platform.
270269
if ep.VlanID != 0 {
271270
epInfo := ep.getInfo()
272271
if nw.Mode == opModeTransparentVlan {
273-
logger.Info("Transparent vlan client")
274272
epClient = NewTransparentVlanEndpointClient(nw, epInfo, ep.HostIfName, "", ep.VlanID, ep.LocalIP, nl, plc, nsc, iptc)
275273

276274
} else {
@@ -462,7 +460,7 @@ func (nm *networkManager) updateRoutes(existingEp *EndpointInfo, targetEp *Endpo
462460
// we do not support enable/disable snat for now
463461
defaultDst := net.ParseIP("0.0.0.0")
464462

465-
logger.Info("Going to collect routes and skip default and infravnet routes if applicable.")
463+
// collect routes and skip default and infravnet routes if applicable
466464
logger.Info("Key for default route", zap.String("route", defaultDst.String()))
467465

468466
infraVnetKey := ""
@@ -476,7 +474,6 @@ func (nm *networkManager) updateRoutes(existingEp *EndpointInfo, targetEp *Endpo
476474
logger.Info("Key for route to infra vnet", zap.String("infraVnetKey", infraVnetKey))
477475
for _, route := range existingEp.Routes {
478476
destination := route.Dst.IP.String()
479-
logger.Info("Checking destination as to skip or not", zap.String("destination", destination))
480477
isDefaultRoute := destination == defaultDst.String()
481478
isInfraVnetRoute := targetEp.EnableInfraVnet && (destination == infraVnetKey)
482479
if !isDefaultRoute && !isInfraVnetRoute {

network/network_linux.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,13 @@ func (nm *networkManager) newNetworkImpl(nwInfo *NetworkInfo, extIf *externalInt
9797
if err := nu.EnableIPV4Forwarding(); err != nil {
9898
return nil, errors.Wrap(err, "ipv4 forwarding failed")
9999
}
100-
logger.Info("Ipv4 forwarding enabled")
101100
if err := nu.UpdateIPV6Setting(1); err != nil {
102101
return nil, errors.Wrap(err, "failed to disable ipv6 on vm")
103102
}
104-
logger.Info("Disabled ipv6")
105103
// Blocks wireserver traffic from apipa nic
106104
if err := nu.BlockEgressTrafficFromContainer(nm.iptablesClient, iptables.V4, networkutils.AzureDNS, iptables.TCP, iptables.HTTPPort); err != nil {
107105
return nil, errors.Wrap(err, "unable to insert vm iptables rule drop wireserver packets")
108106
}
109-
logger.Info("Block wireserver traffic rule added")
110107
default:
111108
return nil, errNetworkModeInvalid
112109
}
@@ -469,7 +466,6 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI
469466
networkClient NetworkClient
470467
)
471468

472-
logger.Info("Connecting interface", zap.String("Name", extIf.Name))
473469
defer func() {
474470
logger.Info("Connecting interface completed", zap.String("Name", extIf.Name), zap.Error(err))
475471
}()
@@ -548,37 +544,35 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI
548544
}
549545
}
550546

547+
logger.Info("Modifying interfaces", zap.String("Name", hostIf.Name))
548+
551549
// External interface down.
552-
logger.Info("Setting link state down", zap.String("Name", hostIf.Name))
553550
err = nm.netlink.SetLinkState(hostIf.Name, false)
554551
if err != nil {
555-
return err
552+
return errors.Wrap(err, "failed to set external interface down")
556553
}
557554

558555
// Connect the external interface to the bridge.
559-
logger.Info("Setting link master", zap.String("Name", hostIf.Name), zap.String("bridgeName", bridgeName))
560556
if err = networkClient.SetBridgeMasterToHostInterface(); err != nil {
561-
return err
557+
return errors.Wrap(err, "failed to connect external interface to bridge")
562558
}
563559

564560
// External interface up.
565-
logger.Info("Setting link state up", zap.String("Name", hostIf.Name))
566561
err = nm.netlink.SetLinkState(hostIf.Name, true)
567562
if err != nil {
568-
return err
563+
return errors.Wrap(err, "failed to set external interface up")
569564
}
570565

571566
// Bridge up.
572-
logger.Info("Setting link state up", zap.String("bridgeName", bridgeName))
573567
err = nm.netlink.SetLinkState(bridgeName, true)
574568
if err != nil {
575-
return err
569+
return errors.Wrap(err, "failed to set bridge link state up")
576570
}
577571

578572
// Add the bridge rules.
579573
err = networkClient.AddL2Rules(extIf)
580574
if err != nil {
581-
return err
575+
return errors.Wrap(err, "failed to add bridge rules")
582576
}
583577

584578
// External interface hairpin on.
@@ -597,8 +591,6 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI
597591
}
598592

599593
if isGreaterOrEqualUbuntu17 && isSystemdResolvedActive {
600-
logger.Info("Applying dns config on", zap.String("bridgeName", bridgeName))
601-
602594
if err = nm.applyDNSConfig(extIf, bridgeName); err != nil {
603595
logger.Error("Failed to apply DNS configuration with", zap.Error(err))
604596
return err
@@ -635,9 +627,7 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI
635627

636628
// DisconnectExternalInterface disconnects a host interface from its bridge.
637629
func (nm *networkManager) disconnectExternalInterface(extIf *externalInterface, networkClient NetworkClient) {
638-
logger.Info("Disconnecting interface", zap.String("Name", extIf.Name))
639-
640-
logger.Info("Deleting bridge rules")
630+
logger.Info("Disconnecting interface and deleting bridge rules", zap.String("Name", extIf.Name))
641631
// Delete bridge rules set on the external interface.
642632
networkClient.DeleteL2Rules(extIf)
643633

network/networkutils/networkutils_linux.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ func (nu NetworkUtils) CreateEndpoint(hostVethName, containerVethName string, ma
8282
return newErrorNetworkUtils(err.Error())
8383
}
8484

85-
logger.Info("Setting link state up", zap.String("hostVethName", hostVethName))
8685
err = nu.netlink.SetLinkState(hostVethName, true)
8786
if err != nil {
8887
return newErrorNetworkUtils(err.Error())
@@ -97,7 +96,6 @@ func (nu NetworkUtils) CreateEndpoint(hostVethName, containerVethName string, ma
9796

9897
func (nu NetworkUtils) SetupContainerInterface(containerVethName, targetIfName string) error {
9998
// Interface needs to be down before renaming.
100-
logger.Info("Setting link state down", zap.String("containerVethName", containerVethName))
10199
if err := nu.netlink.SetLinkState(containerVethName, false); err != nil {
102100
return newErrorNetworkUtils(err.Error())
103101
}
@@ -113,7 +111,6 @@ func (nu NetworkUtils) SetupContainerInterface(containerVethName, targetIfName s
113111
}
114112

115113
// Bring the interface back up.
116-
logger.Info("Setting link state up.", zap.String("targetIfName", targetIfName))
117114
err := nu.netlink.SetLinkState(targetIfName, true)
118115
if err != nil {
119116
return newErrorNetworkUtils(err.Error())

network/snat/snat_linux.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func NewSnatClient(hostIfName string,
6868
plClient platform.ExecClient,
6969
iptc ipTablesClient,
7070
) Client {
71-
logger.Info("Initialize new snat client")
7271
snatClient := Client{
7372
hostSnatVethName: hostIfName,
7473
containerSnatVethName: contIfName,
@@ -446,8 +445,6 @@ func (client *Client) createSnatBridge(snatBridgeIP, hostPrimaryMac string) erro
446445
return err
447446
}
448447

449-
logger.Info("Setting snat bridge mac", zap.String("hostPrimaryMac", hostPrimaryMac))
450-
451448
ip, addr, _ := net.ParseCIDR(snatBridgeIP)
452449
err = client.netlink.AddIPAddress(SnatBridgeName, ip, addr)
453450
if err != nil && !strings.Contains(strings.ToLower(err.Error()), "file exists") {

network/transparent_endpointclient_linux.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ func (client *TransparentEndpointClient) ConfigureContainerInterfacesAndRoutes(e
286286
}
287287

288288
func (client *TransparentEndpointClient) setupIPV6Routes() error {
289-
logger.Info("Setting up ipv6 routes in container")
290-
291289
// add route for virtualgwip
292290
// ip -6 route add fe80::1234:5678:9abc/128 dev eth0
293291
virtualGwIP, virtualGwNet, _ := net.ParseCIDR(virtualv6GwString)
@@ -298,7 +296,7 @@ func (client *TransparentEndpointClient) setupIPV6Routes() error {
298296

299297
// ip -6 route add default via fe80::1234:5678:9abc dev eth0
300298
_, defaultIPNet, _ := net.ParseCIDR(defaultv6Cidr)
301-
logger.Info("defaultv6ipnet", zap.Any("defaultIPNet", defaultIPNet))
299+
logger.Info("Setting up ipv6 routes in container", zap.Any("defaultIPNet", defaultIPNet))
302300
defaultRoute := RouteInfo{
303301
Dst: *defaultIPNet,
304302
Gw: virtualGwIP,

network/transparent_vlan_endpointclient_linux.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
212212
return errors.Wrap(err, "failed to get vm ns handle")
213213
}
214214

215-
logger.Info("Checking if NS exists...")
216215
var existingErr error
217216
client.vnetNSFileDescriptor, existingErr = client.netnsClient.GetFromName(client.vnetNSName)
218217
// If the ns does not exist, the below code will trigger to create it
@@ -308,7 +307,7 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
308307
// Get the default constant host veth mac
309308
mac, err := net.ParseMAC(defaultHostVethHwAddr)
310309
if err != nil {
311-
logger.Info("Failed to parse the mac addrress", zap.String("defaultHostVethHwAddr", defaultHostVethHwAddr))
310+
logger.Info("Failed to parse the mac address", zap.String("defaultHostVethHwAddr", defaultHostVethHwAddr))
312311
}
313312

314313
// Create veth pair

0 commit comments

Comments
 (0)