Skip to content

Commit 7625976

Browse files
authored
Merge pull request kubernetes#92890 from Huang-Wei/postfilter-impl-6
Refactor and expose common preemption functions
2 parents 2003246 + 4e8ccf0 commit 7625976

File tree

4 files changed

+339
-174
lines changed

4 files changed

+339
-174
lines changed

pkg/scheduler/framework/plugins/defaultpreemption/BUILD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "go_default_library",
5-
srcs = ["default_preemption.go"],
5+
srcs = [
6+
"candidate.go",
7+
"default_preemption.go",
8+
],
69
importpath = "k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption",
710
visibility = ["//visibility:public"],
811
deps = [
@@ -20,6 +23,7 @@ go_library(
2023
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
2124
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
2225
"//staging/src/k8s.io/client-go/informers:go_default_library",
26+
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
2327
"//staging/src/k8s.io/client-go/listers/policy/v1beta1:go_default_library",
2428
"//staging/src/k8s.io/kube-scheduler/extender/v1:go_default_library",
2529
"//vendor/k8s.io/klog/v2:go_default_library",
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2020 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 defaultpreemption
18+
19+
import (
20+
extenderv1 "k8s.io/kube-scheduler/extender/v1"
21+
)
22+
23+
// Candidate represents a nominated node on which the preemptor can be scheduled,
24+
// along with the list of victims that should be evicted for the preemptor to fit the node.
25+
type Candidate interface {
26+
// Victims wraps a list of to-be-preempted Pods and the number of PDB violation.
27+
Victims() *extenderv1.Victims
28+
// Name returns the target node name where the preemptor gets nominated to run.
29+
Name() string
30+
}
31+
32+
type candidate struct {
33+
victims *extenderv1.Victims
34+
name string
35+
}
36+
37+
// Victims returns s.victims.
38+
func (s *candidate) Victims() *extenderv1.Victims {
39+
return s.victims
40+
}
41+
42+
// Name returns s.name.
43+
func (s *candidate) Name() string {
44+
return s.name
45+
}

0 commit comments

Comments
 (0)