1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

nfd-master: use Typed* workqueue types

Drop the usage of deprecated functions and types, makes linters happy.
This commit is contained in:
Markus Lehtonen 2024-09-16 14:41:25 +03:00
parent 9261c360b1
commit ca85075972

View file

@ -31,8 +31,8 @@ import (
type updaterPool struct { type updaterPool struct {
started bool started bool
queue workqueue.RateLimitingInterface queue workqueue.TypedRateLimitingInterface[string]
nfgQueue workqueue.RateLimitingInterface nfgQueue workqueue.TypedRateLimitingInterface[string]
sync.RWMutex sync.RWMutex
wg sync.WaitGroup wg sync.WaitGroup
@ -48,11 +48,10 @@ func newUpdaterPool(nfdMaster *nfdMaster) *updaterPool {
} }
func (u *updaterPool) processNodeUpdateRequest(cli k8sclient.Interface) bool { func (u *updaterPool) processNodeUpdateRequest(cli k8sclient.Interface) bool {
n, quit := u.queue.Get() nodeName, quit := u.queue.Get()
if quit { if quit {
return false return false
} }
nodeName := n.(string)
defer u.queue.Done(nodeName) defer u.queue.Done(nodeName)
@ -102,7 +101,7 @@ func (u *updaterPool) processNodeFeatureGroupUpdateRequest(cli nfdclientset.Inte
// Check if NodeFeatureGroup exists // Check if NodeFeatureGroup exists
var nfg *nfdv1alpha1.NodeFeatureGroup var nfg *nfdv1alpha1.NodeFeatureGroup
var err error var err error
if nfg, err = getNodeFeatureGroup(cli, u.nfdMaster.namespace, nfgName.(string)); apierrors.IsNotFound(err) { if nfg, err = getNodeFeatureGroup(cli, u.nfdMaster.namespace, nfgName); apierrors.IsNotFound(err) {
klog.InfoS("NodeFeatureGroup not found, skip update", "NodeFeatureGroupName", nfgName) klog.InfoS("NodeFeatureGroup not found, skip update", "NodeFeatureGroupName", nfgName)
} else if err := u.nfdMaster.nfdAPIUpdateNodeFeatureGroup(u.nfdMaster.nfdClient, nfg); err != nil { } else if err := u.nfdMaster.nfdAPIUpdateNodeFeatureGroup(u.nfdMaster.nfdClient, nfg); err != nil {
if n := u.nfgQueue.NumRequeues(nfgName); n < 15 { if n := u.nfgQueue.NumRequeues(nfgName); n < 15 {
@ -145,12 +144,12 @@ func (u *updaterPool) start(parallelism int) {
// Create ratelimiter. Mimic workqueue.DefaultControllerRateLimiter() but // Create ratelimiter. Mimic workqueue.DefaultControllerRateLimiter() but
// with modified per-item (node) rate limiting parameters. // with modified per-item (node) rate limiting parameters.
rl := workqueue.NewMaxOfRateLimiter( rl := workqueue.NewTypedMaxOfRateLimiter[string](
workqueue.NewItemExponentialFailureRateLimiter(50*time.Millisecond, 100*time.Second), workqueue.NewTypedItemExponentialFailureRateLimiter[string](50*time.Millisecond, 100*time.Second),
&workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Limit(10), 100)}, &workqueue.TypedBucketRateLimiter[string]{Limiter: rate.NewLimiter(rate.Limit(10), 100)},
) )
u.queue = workqueue.NewRateLimitingQueue(rl) u.queue = workqueue.NewTypedRateLimitingQueue[string](rl)
u.nfgQueue = workqueue.NewRateLimitingQueue(rl) u.nfgQueue = workqueue.NewTypedRateLimitingQueue[string](rl)
for i := 0; i < parallelism; i++ { for i := 0; i < parallelism; i++ {
u.wg.Add(1) u.wg.Add(1)