Skip to content

Commit 13d04d4

Browse files
committed
DRA device taints: copy taintseviction controller
This is a verbatim copy of the current pkg/controller/taintseviction code, revision fc268ec (v1.33.0 plus one commit), minus the TimedWorker helper. The intent is to modify the code such that it enforces eviction of pods which use tainted devices.
1 parent 6478ca5 commit 13d04d4

File tree

5 files changed

+1642
-0
lines changed

5 files changed

+1642
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See the OWNERS docs at https://go.k8s.io/owners
2+
3+
approvers:
4+
- sig-scheduling-maintainers
5+
reviewers:
6+
- sig-scheduling
7+
labels:
8+
- sig/scheduling
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package tainteviction contains the logic implementing taint-based eviction
18+
// for Pods running on Nodes with NoExecute taints.
19+
package tainteviction
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package metrics
18+
19+
import (
20+
"sync"
21+
22+
"k8s.io/component-base/metrics"
23+
"k8s.io/component-base/metrics/legacyregistry"
24+
)
25+
26+
const taintEvictionControllerSubsystem = "taint_eviction_controller"
27+
28+
var (
29+
// PodDeletionsTotal counts the number of Pods deleted by TaintEvictionController since its start.
30+
PodDeletionsTotal = metrics.NewCounter(
31+
&metrics.CounterOpts{
32+
Subsystem: taintEvictionControllerSubsystem,
33+
Name: "pod_deletions_total",
34+
Help: "Total number of Pods deleted by TaintEvictionController since its start.",
35+
StabilityLevel: metrics.ALPHA,
36+
},
37+
)
38+
39+
// PodDeletionsLatency tracks the latency, in seconds, between the time when a taint effect has been activated
40+
// for the Pod and its deletion.
41+
PodDeletionsLatency = metrics.NewHistogram(
42+
&metrics.HistogramOpts{
43+
Subsystem: taintEvictionControllerSubsystem,
44+
Name: "pod_deletion_duration_seconds",
45+
Help: "Latency, in seconds, between the time when a taint effect has been activated for the Pod and its deletion via TaintEvictionController.",
46+
Buckets: []float64{0.005, 0.025, 0.1, 0.5, 1, 2.5, 10, 30, 60, 120, 180, 240}, // 5ms to 4m
47+
StabilityLevel: metrics.ALPHA,
48+
},
49+
)
50+
)
51+
52+
var registerMetrics sync.Once
53+
54+
// Register registers TaintEvictionController metrics.
55+
func Register() {
56+
registerMetrics.Do(func() {
57+
legacyregistry.MustRegister(PodDeletionsTotal)
58+
legacyregistry.MustRegister(PodDeletionsLatency)
59+
})
60+
}

0 commit comments

Comments
 (0)