Skip to content

Commit

Permalink
add rate limiting workqueue for node watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
sonasingh46 committed Feb 6, 2022
1 parent fba209e commit d2eaf25
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
16 changes: 12 additions & 4 deletions pkg/controller/node_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@ type NodeWatcher struct {
}

// NewNodeWatcher creates a node watcher object that will watch the nodes
func NewNodeWatcher(driverName string, client kubernetes.Interface, volumeLister corelisters.PersistentVolumeLister,
pvcLister corelisters.PersistentVolumeClaimLister, nodeInformer coreinformers.NodeInformer,
recorder record.EventRecorder, pvcToPodsCache *util.PVCToPodsCache, nodeWorkerExecuteInterval time.Duration, nodeListAndAddInterval time.Duration) *NodeWatcher {
func NewNodeWatcher(driverName string,
client kubernetes.Interface,
volumeLister corelisters.PersistentVolumeLister,
pvcLister corelisters.PersistentVolumeClaimLister,
nodeInformer coreinformers.NodeInformer,
recorder record.EventRecorder,
pvcToPodsCache *util.PVCToPodsCache,
nodeWorkerExecuteInterval time.Duration,
nodeListAndAddInterval time.Duration,
contentRateLimiter workqueue.RateLimiter,
) *NodeWatcher {

watcher := &NodeWatcher{
driverName: driverName,
Expand All @@ -83,7 +91,7 @@ func NewNodeWatcher(driverName string, client kubernetes.Interface, volumeLister
recorder: recorder,
volumeLister: volumeLister,
pvcLister: pvcLister,
nodeQueue: workqueue.NewNamed("nodes"),
nodeQueue: workqueue.NewNamedRateLimitingQueue(contentRateLimiter, "nodes"),
nodeFirstBrokenMap: make(map[string]time.Time),
nodeEverMarkedDown: make(map[string]bool),
pvcToPodsCache: pvcToPodsCache,
Expand Down
13 changes: 12 additions & 1 deletion pkg/controller/pv_monitor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,18 @@ func NewPVMonitorController(
})

if ctrl.enableNodeWatcher {
ctrl.nodeWatcher = NewNodeWatcher(ctrl.driverName, ctrl.client, ctrl.pvLister, ctrl.pvcLister, nodeInformer, ctrl.eventRecorder, ctrl.pvcToPodsCache, option.NodeWorkerExecuteInterval, option.NodeListAndAddInterval)
ctrl.nodeWatcher = NewNodeWatcher(
ctrl.driverName,
ctrl.client,
ctrl.pvLister,
ctrl.pvcLister,
nodeInformer,
ctrl.eventRecorder,
ctrl.pvcToPodsCache,
option.NodeWorkerExecuteInterval,
option.NodeListAndAddInterval,
contentRateLimiter,
)
}

ctrl.pvChecker = handler.NewPVHealthConditionChecker(option.DriverName, conn, client, option.ContextTimeout, ctrl.pvcLister, ctrl.pvLister, eventInformer, ctrl.eventRecorder)
Expand Down

0 comments on commit d2eaf25

Please sign in to comment.