Use the generic/typed workqueue throughout

This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.
This commit is contained in:
Alvaro Aleman
2024-04-28 18:26:18 +02:00
parent d387c0c903
commit 6d0ac8c561
94 changed files with 830 additions and 603 deletions

View File

@@ -297,8 +297,8 @@ type Controller struct {
largeClusterThreshold int32
unhealthyZoneThreshold float32
nodeUpdateQueue workqueue.Interface
podUpdateQueue workqueue.RateLimitingInterface
nodeUpdateQueue workqueue.TypedInterface[string]
podUpdateQueue workqueue.TypedRateLimitingInterface[podUpdateItem]
}
// NewNodeLifecycleController returns a new taint controller.
@@ -344,8 +344,13 @@ func NewNodeLifecycleController(
secondaryEvictionLimiterQPS: secondaryEvictionLimiterQPS,
largeClusterThreshold: largeClusterThreshold,
unhealthyZoneThreshold: unhealthyZoneThreshold,
nodeUpdateQueue: workqueue.NewTypedWithConfig[any](workqueue.TypedQueueConfig[any]{Name: "node_lifecycle_controller"}),
podUpdateQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "node_lifecycle_controller_pods"),
nodeUpdateQueue: workqueue.NewTypedWithConfig(workqueue.TypedQueueConfig[string]{Name: "node_lifecycle_controller"}),
podUpdateQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
workqueue.DefaultTypedControllerRateLimiter[podUpdateItem](),
workqueue.TypedRateLimitingQueueConfig[podUpdateItem]{
Name: "node_lifecycle_controller_pods",
},
),
}
nc.enterPartialDisruptionFunc = nc.ReducedQPSFunc
@@ -515,7 +520,7 @@ func (nc *Controller) doNodeProcessingPassWorker(ctx context.Context) {
if shutdown {
return
}
nodeName := obj.(string)
nodeName := obj
if err := nc.doNoScheduleTaintingPass(ctx, nodeName); err != nil {
logger.Error(err, "Failed to taint NoSchedule on node, requeue it", "node", klog.KRef("", nodeName))
// TODO(k82cn): Add nodeName back to the queue
@@ -1096,7 +1101,7 @@ func (nc *Controller) doPodProcessingWorker(ctx context.Context) {
return
}
podItem := obj.(podUpdateItem)
podItem := obj
nc.processPod(ctx, podItem)
}
}