From 16478d8c6060a4dda26cfbd7e46aa8d9cba6dbd0 Mon Sep 17 00:00:00 2001 From: Abhishek Raut Date: Mon, 4 Nov 2019 15:38:10 -0800 Subject: [PATCH] Update logging levels Set an appropriate logging level in various modules such that debug level logs are not logged at default level. Closes: #4 --- pkg/agent/cniserver/pod_configuration.go | 14 +++++++------- pkg/agent/interface_cache.go | 2 +- .../networkpolicy/networkpolicy_controller.go | 2 +- pkg/monitor/monitor.go | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/agent/cniserver/pod_configuration.go b/pkg/agent/cniserver/pod_configuration.go index 467684c3c0d..0d8b82ad846 100644 --- a/pkg/agent/cniserver/pod_configuration.go +++ b/pkg/agent/cniserver/pod_configuration.go @@ -58,7 +58,7 @@ func setupInterface(podName string, podNamespace string, ifname string, netns ns if err != nil { return err } - klog.Infof("Setup interfaces host: %s, container %s", hostVeth.Name, containerVeth.Name) + klog.V(2).Infof("Setup interfaces host: %s, container %s", hostVeth.Name, containerVeth.Name) containerIface.Name = containerVeth.Name containerIface.Mac = containerVeth.HardwareAddr.String() containerIface.Sandbox = netns.Path() @@ -152,7 +152,7 @@ func validateContainerPeerInterface(hostIntf *current.Interface, containerVeth * } _, isVeth := link.(*netlink.Veth) if !isVeth { - klog.Infof("Link %s is not created by CNI", hostIntf.Name) + klog.V(2).Infof("Link %s is not created by CNI", hostIntf.Name) return hostVeth, nil } linkName := link.Attrs().Name @@ -290,7 +290,7 @@ func removeContainerLink(containerID string, containerNetns string, ifname strin _, err = ip.DelLinkByNameAddr(ifname) if err != nil && err == ip.ErrLinkNotFound { // Not found link should return success for deletion - klog.Infof("Interface %s not found in netns %s", ifname, containerNetns) + klog.V(2).Infof("Interface %s not found in netns %s", ifname, containerNetns) return nil } return err @@ -321,18 +321,18 @@ func removeInterfaces( // many resources as possible (e.g. releasing IPAM allocations) and return a // successful response. // In our case it means deleting the OVS port. - klog.Infof("Target netns not specified, not removing veth pair") + klog.V(2).Infof("Target netns not specified, not removing veth pair") } containerConfig, found := ifaceStore.GetContainerInterface(podName, podNamespace) if !found { - klog.Infof("Did not find the port for container %s in local cache", containerID) + klog.V(2).Infof("Did not find the port for container %s in local cache", containerID) return nil } portUUID := containerConfig.PortUUID ovsPortName := containerConfig.IfaceName - klog.Infof("Delete OVS port with UUID %s peer container %s", portUUID, containerID) + klog.V(2).Infof("Delete OVS port with UUID %s peer container %s", portUUID, containerID) // Remove openflow entries of target container if err := ofClient.UninstallPodFlows(ovsPortName); err != nil { klog.Errorf("Failed to delete Openflow entries for container %s: %v", containerID, err) @@ -429,7 +429,7 @@ func validateOVSPort(ifaceStore agent.InterfaceStore, ovsPortName string, contai } return fmt.Errorf("failed to find a valid IP equal to attached address") } else { - klog.Infof("Not found container %s config from local cache", containerID) + klog.V(2).Infof("Not found container %s config from local cache", containerID) return fmt.Errorf("not found OVS port %s", ovsPortName) } } diff --git a/pkg/agent/interface_cache.go b/pkg/agent/interface_cache.go index babb72cd86c..732bd144db1 100644 --- a/pkg/agent/interface_cache.go +++ b/pkg/agent/interface_cache.go @@ -109,7 +109,7 @@ func (c *interfaceCache) Initialize(ovsBridgeClient ovsconfig.OVSBridgeClient, g intf = &InterfaceConfig{Type: TunnelInterface, OVSPortConfig: ovsPort, ID: tunnelPort} default: if port.ExternalIDs == nil { - klog.Infof("OVS port %s has no external_ids, continue to next", port.Name) + klog.V(2).Infof("OVS port %s has no external_ids, continue to next", port.Name) continue } diff --git a/pkg/controller/networkpolicy/networkpolicy_controller.go b/pkg/controller/networkpolicy/networkpolicy_controller.go index 661640c7cfa..a4ce78c4de2 100644 --- a/pkg/controller/networkpolicy/networkpolicy_controller.go +++ b/pkg/controller/networkpolicy/networkpolicy_controller.go @@ -221,6 +221,6 @@ func (n *NetworkPolicyController) syncNetworkPolicy(key string) error { if err != nil { return fmt.Errorf("failed to get NetworkPolicy %s: %v", key, err) } - klog.Infof("Syncing NetworkPolicy %s: %v", key, networkPolicy.Spec.PodSelector) + klog.V(1).Infof("Syncing NetworkPolicy %s: %v", key, networkPolicy.Spec.PodSelector) return nil } diff --git a/pkg/monitor/monitor.go b/pkg/monitor/monitor.go index 9d29189a78f..55b4a60e0ed 100644 --- a/pkg/monitor/monitor.go +++ b/pkg/monitor/monitor.go @@ -110,13 +110,13 @@ func (monitor *controllerMonitor) createControllerCRD(controllerCRD *v1beta1.Ant NodeRef: monitor.GetSelfNode(), ServiceRef: monitor.GetService(), } - klog.Infof("Creating controller monitor CRD %v", controllerCRD) + klog.V(2).Infof("Creating controller monitor CRD %v", controllerCRD) return monitor.client.ClusterinformationV1beta1().AntreaControllerInfos().Create(controllerCRD) } // TODO: Update network policy related fields when the upstreaming is ready func (monitor *controllerMonitor) updateControllerCRD(controllerCRD *v1beta1.AntreaControllerInfo) (*v1beta1.AntreaControllerInfo, error) { - klog.Infof("Updating controller monitor CRD %v", controllerCRD) + klog.V(2).Infof("Updating controller monitor CRD %v", controllerCRD) return monitor.client.ClusterinformationV1beta1().AntreaControllerInfos().Update(controllerCRD) } @@ -132,7 +132,7 @@ func (monitor *agentMonitor) createAgentCRD(agentCRD *v1beta1.AntreaAgentInfo) ( OVSInfo: v1beta1.OVSInfo{BridgeName: monitor.ovsBridge, FlowTable: monitor.GetOVSFlowTable()}, LocalPodNum: monitor.GetLocalPodNum(), } - klog.Infof("Creating agent monitor CRD %v", agentCRD) + klog.V(2).Infof("Creating agent monitor CRD %v", agentCRD) return monitor.client.ClusterinformationV1beta1().AntreaAgentInfos().Create(agentCRD) } @@ -140,6 +140,6 @@ func (monitor *agentMonitor) updateAgentCRD(agentCRD *v1beta1.AntreaAgentInfo) ( // LocalPodNum and FlowTable can be changed, so reset these fields. agentCRD.LocalPodNum = monitor.GetLocalPodNum() agentCRD.OVSInfo.FlowTable = monitor.GetOVSFlowTable() - klog.Infof("Updating agent monitor CRD %v", agentCRD) + klog.V(2).Infof("Updating agent monitor CRD %v", agentCRD) return monitor.client.ClusterinformationV1beta1().AntreaAgentInfos().Update(agentCRD) }