From 9527987293659b005b51f9fd2be9e2fa7e699d58 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 5 Nov 2025 08:50:26 +0100 Subject: [PATCH] DRA device taint eviction: use NOP queue during simulation It's slightly more efficient and a bit cleaner. --- .../device_taint_eviction.go | 3 +- .../devicetainteviction/nopqueue.go | 79 +++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 pkg/controller/devicetainteviction/nopqueue.go diff --git a/pkg/controller/devicetainteviction/device_taint_eviction.go b/pkg/controller/devicetainteviction/device_taint_eviction.go index 7622558cc56..858ad1eff55 100644 --- a/pkg/controller/devicetainteviction/device_taint_eviction.go +++ b/pkg/controller/devicetainteviction/device_taint_eviction.go @@ -551,8 +551,7 @@ func (tc *Controller) maybeUpdateRuleStatus(ctx context.Context, ruleRef taintev allocatedClaims: maps.Clone(tc.allocatedClaims), pools: tc.pools, simulateRule: ruleEvict, - // TODO: stub implementation - workqueue: workqueue.NewTypedRateLimitingQueueWithConfig(workqueue.DefaultTypedControllerRateLimiter[workItem](), workqueue.TypedRateLimitingQueueConfig[workItem]{}), + workqueue: &NOPQueue[workItem]{}, } defer tc.workqueue.ShutDown() diff --git a/pkg/controller/devicetainteviction/nopqueue.go b/pkg/controller/devicetainteviction/nopqueue.go new file mode 100644 index 00000000000..97e9ef89dc6 --- /dev/null +++ b/pkg/controller/devicetainteviction/nopqueue.go @@ -0,0 +1,79 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package devicetainteviction + +import ( + "time" + + "k8s.io/client-go/util/workqueue" +) + +// NOPQueue is an implementation of [TypedRateLimitingInterface] which +// doesn't do anything. +type NOPQueue[T comparable] struct { +} + +var _ workqueue.TypedRateLimitingInterface[int] = &NOPQueue[int]{} + +// Add implements [TypedInterface]. +func (m *NOPQueue[T]) Add(item T) { +} + +// Len implements [TypedInterface]. +func (m *NOPQueue[T]) Len() int { + return 0 +} + +// Get implements [TypedInterface]. +func (m *NOPQueue[T]) Get() (item T, shutdown bool) { + shutdown = true + return +} + +// Done implements [TypedInterface]. +func (m *NOPQueue[T]) Done(item T) { +} + +// ShutDown implements [TypedInterface]. +func (m *NOPQueue[T]) ShutDown() { +} + +// ShutDownWithDrain implements [TypedInterface]. +func (m *NOPQueue[T]) ShutDownWithDrain() { +} + +// ShuttingDown implements [TypedInterface]. +func (m *NOPQueue[T]) ShuttingDown() bool { + return true +} + +// AddAfter implements [TypedDelayingInterface.AddAfter] +func (m *NOPQueue[T]) AddAfter(item T, duration time.Duration) { +} + +// AddRateLimited implements [TypedRateLimitingInterface.AddRateLimited]. +func (m *NOPQueue[T]) AddRateLimited(item T) { +} + +// Forget implements [TypedRateLimitingInterface.Forget]. +func (m *NOPQueue[T]) Forget(item T) { +} + +// NumRequeues implements [TypedRateLimitingInterface.NumRequeues]. +func (m *NOPQueue[T]) NumRequeues(item T) int { + return 0 +}