Skip to content

Commit

Permalink
fix golangci
Browse files Browse the repository at this point in the history
Signed-off-by: Hang Yan <yhang@vmware.com>
  • Loading branch information
hangyan committed Oct 16, 2024
1 parent 5a645e8 commit c36a376
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
19 changes: 8 additions & 11 deletions pkg/agent/controller/packetcapture/packetcapture_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ type Controller struct {
ofClient openflow.Client
interfaceStore interfacestore.InterfaceStore
nodeConfig *config.NodeConfig
queue workqueue.RateLimitingInterface
queue workqueue.TypedRateLimitingInterface[string]
runningPacketCapturesMutex sync.RWMutex
runningPacketCaptures map[uint8]*packetCaptureState
sftpUploader ftp.Uploader
Expand All @@ -156,8 +156,10 @@ func NewPacketCaptureController(
ofClient: client,
interfaceStore: interfaceStore,
nodeConfig: nodeConfig,
queue: workqueue.NewRateLimitingQueueWithConfig(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay),
workqueue.RateLimitingQueueConfig{Name: "packetcapture"}),
queue: workqueue.NewTypedRateLimitingQueueWithConfig(
workqueue.NewTypedItemExponentialFailureRateLimiter[string](minRetryDelay, maxRetryDelay),
workqueue.TypedRateLimitingQueueConfig[string]{Name: "packetcapture"},
),
runningPacketCaptures: make(map[uint8]*packetCaptureState),
sftpUploader: &ftp.SftpUploader{},
}
Expand Down Expand Up @@ -255,17 +257,12 @@ func (c *Controller) worker() {
}

func (c *Controller) processPacketCaptureItem() bool {
obj, quit := c.queue.Get()
key, quit := c.queue.Get()
if quit {
return false
}

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 non-string object", "obj", obj)
return true
} else if err := c.syncPacketCapture(key); err == nil {
defer c.queue.Done(key)
if err := c.syncPacketCapture(key); err == nil {
c.queue.Forget(key)
} else {
klog.ErrorS(err, "Error syncing PacketCapture, exiting", "key", key)
Expand Down
12 changes: 6 additions & 6 deletions pkg/agent/supportbundlecollection/support_bundle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ func NewSupportBundleController(nodeName string,
queue: workqueue.NewTypedWithConfig(workqueue.TypedQueueConfig[string]{
Name: "supportbundle",
}),
ovsCtlClient: ovsCtlClient,
aq: aq,
npq: npq,
v4Enabled: v4Enabled,
v6Enabled: v6Enabled,
sftpUploader: &ftp.SftpUploader{},
ovsCtlClient: ovsCtlClient,
aq: aq,
npq: npq,
v4Enabled: v4Enabled,
v6Enabled: v6Enabled,
sftpUploader: &ftp.SftpUploader{},
}
return c
}
Expand Down

0 comments on commit c36a376

Please sign in to comment.