Skip to content

Commit 7dc161e

Browse files
committed
nfd-master: use Typed* workqueue types
Drop the usage of deprecated functions and types, makes linters happy. (cherry picked from commit ca85075)
1 parent 8502412 commit 7dc161e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

pkg/nfd-master/updater-pool.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import (
3131
)
3232

3333
type updaterPool struct {
34-
queue workqueue.RateLimitingInterface
35-
nfgQueue workqueue.RateLimitingInterface
34+
queue workqueue.TypedRateLimitingInterface[string]
35+
nfgQueue workqueue.TypedRateLimitingInterface[string]
3636
sync.RWMutex
3737

3838
wg sync.WaitGroup
@@ -47,12 +47,11 @@ func newUpdaterPool(nfdMaster *nfdMaster) *updaterPool {
4747
}
4848
}
4949

50-
func (u *updaterPool) processNodeUpdateRequest(cli k8sclient.Interface, queue workqueue.RateLimitingInterface) bool {
51-
n, quit := queue.Get()
50+
func (u *updaterPool) processNodeUpdateRequest(cli k8sclient.Interface, queue workqueue.TypedRateLimitingInterface[string]) bool {
51+
nodeName, quit := queue.Get()
5252
if quit {
5353
return false
5454
}
55-
nodeName := n.(string)
5655

5756
defer queue.Done(nodeName)
5857

@@ -76,7 +75,7 @@ func (u *updaterPool) processNodeUpdateRequest(cli k8sclient.Interface, queue wo
7675
return true
7776
}
7877

79-
func (u *updaterPool) runNodeUpdater(queue workqueue.RateLimitingInterface) {
78+
func (u *updaterPool) runNodeUpdater(queue workqueue.TypedRateLimitingInterface[string]) {
8079
var cli k8sclient.Interface
8180
if u.nfdMaster.kubeconfig != nil {
8281
// For normal execution, initialize a separate api client for each updater
@@ -90,7 +89,7 @@ func (u *updaterPool) runNodeUpdater(queue workqueue.RateLimitingInterface) {
9089
u.wg.Done()
9190
}
9291

93-
func (u *updaterPool) processNodeFeatureGroupUpdateRequest(cli nfdclientset.Interface, ngfQueue workqueue.RateLimitingInterface) bool {
92+
func (u *updaterPool) processNodeFeatureGroupUpdateRequest(cli nfdclientset.Interface, ngfQueue workqueue.TypedRateLimitingInterface[string]) bool {
9493
nfgName, quit := ngfQueue.Get()
9594
if quit {
9695
return false
@@ -102,7 +101,7 @@ func (u *updaterPool) processNodeFeatureGroupUpdateRequest(cli nfdclientset.Inte
102101
// Check if NodeFeatureGroup exists
103102
var nfg *nfdv1alpha1.NodeFeatureGroup
104103
var err error
105-
if nfg, err = getNodeFeatureGroup(cli, u.nfdMaster.namespace, nfgName.(string)); apierrors.IsNotFound(err) {
104+
if nfg, err = getNodeFeatureGroup(cli, u.nfdMaster.namespace, nfgName); apierrors.IsNotFound(err) {
106105
klog.InfoS("NodeFeatureGroup not found, skip update", "NodeFeatureGroupName", nfgName)
107106
} else if err := u.nfdMaster.nfdAPIUpdateNodeFeatureGroup(u.nfdMaster.nfdClient, nfg); err != nil {
108107
if n := ngfQueue.NumRequeues(nfgName); n < 15 {
@@ -118,7 +117,7 @@ func (u *updaterPool) processNodeFeatureGroupUpdateRequest(cli nfdclientset.Inte
118117
return true
119118
}
120119

121-
func (u *updaterPool) runNodeFeatureGroupUpdater(ngfQueue workqueue.RateLimitingInterface) {
120+
func (u *updaterPool) runNodeFeatureGroupUpdater(ngfQueue workqueue.TypedRateLimitingInterface[string]) {
122121
cli := nfdclientset.NewForConfigOrDie(u.nfdMaster.kubeconfig)
123122
for u.processNodeFeatureGroupUpdateRequest(cli, ngfQueue) {
124123
}
@@ -143,12 +142,12 @@ func (u *updaterPool) start(parallelism int) {
143142

144143
// Create ratelimiter. Mimic workqueue.DefaultControllerRateLimiter() but
145144
// with modified per-item (node) rate limiting parameters.
146-
rl := workqueue.NewMaxOfRateLimiter(
147-
workqueue.NewItemExponentialFailureRateLimiter(50*time.Millisecond, 100*time.Second),
148-
&workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Limit(10), 100)},
145+
rl := workqueue.NewTypedMaxOfRateLimiter[string](
146+
workqueue.NewTypedItemExponentialFailureRateLimiter[string](50*time.Millisecond, 100*time.Second),
147+
&workqueue.TypedBucketRateLimiter[string]{Limiter: rate.NewLimiter(rate.Limit(10), 100)},
149148
)
150-
u.queue = workqueue.NewRateLimitingQueue(rl)
151-
u.nfgQueue = workqueue.NewRateLimitingQueue(rl)
149+
u.queue = workqueue.NewTypedRateLimitingQueue[string](rl)
150+
u.nfgQueue = workqueue.NewTypedRateLimitingQueue[string](rl)
152151

153152
for i := 0; i < parallelism; i++ {
154153
u.wg.Add(1)

0 commit comments

Comments
 (0)