Skip to content

Commit a027b43

Browse files
committed
DRA: add device taint eviction controller
The controller is derived from the node taint eviction controller. In contrast to that controller it tracks the UID of pods to prevent deleting the wrong pod when it got replaced.
1 parent 13d04d4 commit a027b43

File tree

17 files changed

+2888
-1599
lines changed

17 files changed

+2888
-1599
lines changed

cmd/kube-controller-manager/app/controllermanager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ func NewControllerDescriptors() map[string]*ControllerDescriptor {
588588
// feature gated
589589
register(newStorageVersionGarbageCollectorControllerDescriptor())
590590
register(newResourceClaimControllerDescriptor())
591+
register(newDeviceTaintEvictionControllerDescriptor())
591592
register(newLegacyServiceAccountTokenCleanerControllerDescriptor())
592593
register(newValidatingAdmissionPolicyStatusControllerDescriptor())
593594
register(newTaintEvictionControllerDescriptor())

cmd/kube-controller-manager/app/controllermanager_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func TestControllerNamesDeclaration(t *testing.T) {
9393
names.EphemeralVolumeController,
9494
names.StorageVersionGarbageCollectorController,
9595
names.ResourceClaimController,
96+
names.DeviceTaintEvictionController,
9697
names.LegacyServiceAccountTokenCleanerController,
9798
names.ValidatingAdmissionPolicyStatusController,
9899
names.ServiceCIDRController,

cmd/kube-controller-manager/app/core.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"k8s.io/klog/v2"
4242
"k8s.io/kubernetes/cmd/kube-controller-manager/names"
4343
pkgcontroller "k8s.io/kubernetes/pkg/controller"
44+
"k8s.io/kubernetes/pkg/controller/devicetainteviction"
4445
endpointcontroller "k8s.io/kubernetes/pkg/controller/endpoint"
4546
"k8s.io/kubernetes/pkg/controller/garbagecollector"
4647
namespacecontroller "k8s.io/kubernetes/pkg/controller/namespace"
@@ -231,6 +232,32 @@ func startTaintEvictionController(ctx context.Context, controllerContext Control
231232
return nil, true, nil
232233
}
233234

235+
func newDeviceTaintEvictionControllerDescriptor() *ControllerDescriptor {
236+
return &ControllerDescriptor{
237+
name: names.DeviceTaintEvictionController,
238+
initFunc: startDeviceTaintEvictionController,
239+
requiredFeatureGates: []featuregate.Feature{
240+
// TODO update app.TestFeatureGatedControllersShouldNotDefineAliases when removing these feature gates.
241+
features.DynamicResourceAllocation,
242+
features.DRADeviceTaints,
243+
},
244+
}
245+
}
246+
247+
func startDeviceTaintEvictionController(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) {
248+
deviceTaintEvictionController := devicetainteviction.New(
249+
controllerContext.ClientBuilder.ClientOrDie(names.DeviceTaintEvictionController),
250+
controllerContext.InformerFactory.Core().V1().Pods(),
251+
controllerContext.InformerFactory.Resource().V1beta1().ResourceClaims(),
252+
controllerContext.InformerFactory.Resource().V1beta1().ResourceSlices(),
253+
controllerContext.InformerFactory.Resource().V1alpha3().DeviceTaintRules(),
254+
controllerContext.InformerFactory.Resource().V1beta1().DeviceClasses(),
255+
controllerName,
256+
)
257+
go deviceTaintEvictionController.Run(ctx)
258+
return nil, true, nil
259+
}
260+
234261
func newCloudNodeLifecycleControllerDescriptor() *ControllerDescriptor {
235262
return &ControllerDescriptor{
236263
name: cpnames.CloudNodeLifecycleController,

cmd/kube-controller-manager/names/controller_names.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const (
6969
NodeIpamController = "node-ipam-controller"
7070
NodeLifecycleController = "node-lifecycle-controller"
7171
TaintEvictionController = "taint-eviction-controller"
72+
DeviceTaintEvictionController = "device-taint-eviction-controller"
7273
PersistentVolumeBinderController = "persistentvolume-binder-controller"
7374
PersistentVolumeAttachDetachController = "persistentvolume-attach-detach-controller"
7475
PersistentVolumeExpanderController = "persistentvolume-expander-controller"

hack/verify-prometheus-imports.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ source "${KUBE_ROOT}/hack/lib/util.sh"
3737
# See: https://github.com/kubernetes/kubernetes/issues/89267
3838
allowed_prometheus_importers=(
3939
./cluster/images/etcd-version-monitor/etcd-version-monitor.go
40+
./pkg/controller/devicetainteviction/device_taint_eviction_test.go
4041
./staging/src/k8s.io/component-base/metrics/prometheusextension/timing_histogram.go
4142
./staging/src/k8s.io/component-base/metrics/prometheusextension/timing_histogram_test.go
4243
./staging/src/k8s.io/component-base/metrics/prometheusextension/timing_histogram_vec.go

0 commit comments

Comments
 (0)