Skip to content

Commit

Permalink
Reduce verbose logs that dump large objects
Browse files Browse the repository at this point in the history
While debugging an issue with improved log level, I found that
periodical events like updating monitoring CRs and EndpointSlice events
lead to a lot of logs, each of which took considerable space as they
dump the entire objects, while we rarely need them.

This patch reduces some less useful verbose logs.

Signed-off-by: Quan Tian <[email protected]>
  • Loading branch information
tnqn committed Apr 8, 2024
1 parent 3ac87f6 commit 9f0bb00
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/monitor/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ func (monitor *agentMonitor) getAgentCRD() (*v1beta1.AntreaAgentInfo, error) {
func (monitor *agentMonitor) updateAgentCRD(partial bool) (*v1beta1.AntreaAgentInfo, error) {
monitor.querier.GetAgentInfo(monitor.agentCRD, partial)
monitor.agentCRD.APICABundle = monitor.apiCertData
klog.V(2).Infof("Updating agent monitoring CRD %+v, partial: %t", monitor.agentCRD, partial)
klog.V(2).InfoS("Updating agent monitoring CRD", "name", klog.KObj(monitor.agentCRD), "partial", partial)
return monitor.client.CrdV1beta1().AntreaAgentInfos().Update(context.TODO(), monitor.agentCRD, metav1.UpdateOptions{})
}
4 changes: 2 additions & 2 deletions pkg/monitor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ func (monitor *controllerMonitor) createControllerCRD(crdName string) (*v1beta1.
controllerCRD := new(v1beta1.AntreaControllerInfo)
controllerCRD.Name = crdName
monitor.querier.GetControllerInfo(controllerCRD, false)
klog.V(2).Infof("Creating controller monitoring CRD %+v", controllerCRD)
klog.V(2).InfoS("Creating controller monitoring CRD", "name", klog.KObj(controllerCRD))
return monitor.client.CrdV1beta1().AntreaControllerInfos().Create(context.TODO(), controllerCRD, metav1.CreateOptions{})
}

// updateControllerCRD updates the monitoring CRD.
func (monitor *controllerMonitor) updateControllerCRD(partial bool) (*v1beta1.AntreaControllerInfo, error) {
monitor.querier.GetControllerInfo(monitor.controllerCRD, partial)
klog.V(2).Infof("Updating controller monitoring CRD %+v, partial: %t", monitor.controllerCRD, partial)
klog.V(2).InfoS("Updating controller monitoring CRD", "name", klog.KObj(monitor.controllerCRD), "partial", partial)
return monitor.client.CrdV1beta1().AntreaControllerInfos().Update(context.TODO(), monitor.controllerCRD, metav1.UpdateOptions{})
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/ovs/openflow/ofctrl_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,13 @@ func (b *OFBridge) DumpTableStatus() []TableStatus {

// PacketRcvd is a callback when a packetIn is received on ofctrl.OFSwitch.
func (b *OFBridge) PacketRcvd(sw *ofctrl.OFSwitch, packet *ofctrl.PacketIn) {
klog.V(2).InfoS("Received packetIn", "packet", packet)
// Correspond to MessageStream.outbound log level.
if klog.V(7).Enabled() {
klog.InfoS("Received packetIn", "packet", packet)
} else {
klog.V(4).InfoS("Received packetIn")
}

if len(packet.UserData) == 0 {
klog.Info("Received packetIn without packetIn category in userdata")
return
Expand Down
6 changes: 3 additions & 3 deletions third_party/proxy/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (c *EndpointSliceConfig) handleAddEndpointSlice(obj interface{}) {
return
}
for _, h := range c.eventHandlers {
klog.V(4).InfoS("Calling handler.OnEndpointSliceAdd", "endpointSlice", endpointSlice)
klog.V(4).InfoS("Calling handler.OnEndpointSliceAdd", "endpointSlice", klog.KObj(endpointSlice))
h.OnEndpointSliceAdd(endpointSlice)
}
}
Expand All @@ -347,7 +347,7 @@ func (c *EndpointSliceConfig) handleUpdateEndpointSlice(oldObj, newObj interface
return
}
for _, h := range c.eventHandlers {
klog.V(4).InfoS("Calling handler.OnEndpointSliceUpdate", "from", oldEndpointSlice, "to", newEndpointSlice)
klog.V(4).InfoS("Calling handler.OnEndpointSliceUpdate", "endpointSlice", klog.KObj(newEndpointSlice))
h.OnEndpointSliceUpdate(oldEndpointSlice, newEndpointSlice)
}
}
Expand All @@ -366,7 +366,7 @@ func (c *EndpointSliceConfig) handleDeleteEndpointSlice(obj interface{}) {
}
}
for _, h := range c.eventHandlers {
klog.V(4).InfoS("Calling handler.OnEndpointSliceDelete", "endpointSlice", endpointSlice)
klog.V(4).InfoS("Calling handler.OnEndpointSliceDelete", "endpointSlice", klog.KObj(endpointSlice))
h.OnEndpointSliceDelete(endpointSlice)
}
}
Expand Down

0 comments on commit 9f0bb00

Please sign in to comment.