Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Quan Tian <[email protected]>
  • Loading branch information
hangyan and tnqn authored Apr 23, 2024
1 parent 41cfb13 commit ddfe4fb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/agent/controller/packetcapture/packetcapture_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
return
}

go func() {
wait.Until(c.checkPacketCaptureTimeout, timeoutCheckInterval, stopCh)
}()
go wait.Until(c.checkPacketCaptureTimeout, timeoutCheckInterval, stopCh)

for i := 0; i < defaultWorkers; i++ {
go wait.Until(c.worker, time.Second, stopCh)
Expand All @@ -218,7 +216,7 @@ func (c *Controller) Run(stopCh <-chan struct{}) {

func (c *Controller) checkPacketCaptureTimeout() {
c.runningPacketCapturesMutex.RLock()
ss := make([]string, 0, len(c.runningPacketCaptures))
pcs := make([]string, 0, len(c.runningPacketCaptures))
for _, pcState := range c.runningPacketCaptures {
ss = append(ss, pcState.name)
}
Expand All @@ -238,7 +236,7 @@ func (c *Controller) addPacketCapture(obj interface{}) {

func (c *Controller) updatePacketCapture(_, obj interface{}) {
pc := obj.(*crdv1alpha1.PacketCapture)
klog.InfoS("Processing PacketCapture UPDATE EVENT", "name", pc.Name)
klog.InfoS("Processing PacketCapture UPDATE event", "name", pc.Name)
c.enqueuePacketCapture(pc)
}

Expand Down Expand Up @@ -274,7 +272,7 @@ func (c *Controller) processPacketCaptureItem() bool {
defer c.queue.Done(obj)
if key, ok := obj.(string); !ok {
c.queue.Forget(obj)
klog.ErrorS(nil, "Expected string in work queue but got", "obj", obj)
klog.ErrorS(nil, "Expected string in work queue but got non-string object", "obj", obj)
return true
} else if err := c.syncPacketCapture(key); err == nil {
c.queue.Forget(key)
Expand Down

0 comments on commit ddfe4fb

Please sign in to comment.