Skip to content

Commit 52d4972

Browse files
authored
Merge pull request kubernetes#127109 from sanposhiho/precheck-move
feat: disable preCheck when QHint is enabled
2 parents dfb763b + 4ee1394 commit 52d4972

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

pkg/scheduler/backend/queue/scheduling_queue.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ type SchedulingQueue interface {
111111
Done(types.UID)
112112
Update(logger klog.Logger, oldPod, newPod *v1.Pod)
113113
Delete(pod *v1.Pod)
114-
// TODO(sanposhiho): move all PreEnqueueCheck to Requeue and delete it from this parameter eventually.
115-
// Some PreEnqueueCheck include event filtering logic based on some in-tree plugins
116-
// and it affect badly to other plugins.
117-
// See https://github.com/kubernetes/kubernetes/issues/110175
114+
// Important Note: preCheck shouldn't include anything that depends on the in-tree plugins' logic.
115+
// (e.g., filter Pods based on added/updated Node's capacity, etc.)
116+
// We know currently some do, but we'll eventually remove them in favor of the scheduling queue hint.
118117
MoveAllToActiveOrBackoffQueue(logger klog.Logger, event framework.ClusterEvent, oldObj, newObj interface{}, preCheck PreEnqueueCheck)
119118
AssignedPodAdded(logger klog.Logger, pod *v1.Pod)
120119
AssignedPodUpdated(logger klog.Logger, oldPod, newPod *v1.Pod, event framework.ClusterEvent)

pkg/scheduler/eventhandlers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,13 @@ func addAllEventHandlers(
605605
}
606606

607607
func preCheckForNode(nodeInfo *framework.NodeInfo) queue.PreEnqueueCheck {
608+
if utilfeature.DefaultFeatureGate.Enabled(features.SchedulerQueueingHints) {
609+
// QHint is initially created from the motivation of replacing this preCheck.
610+
// It assumes that the scheduler only has in-tree plugins, which is problematic for our extensibility.
611+
// Here, we skip preCheck if QHint is enabled, and we eventually remove it after QHint is graduated.
612+
return nil
613+
}
614+
608615
// Note: the following checks doesn't take preemption into considerations, in very rare
609616
// cases (e.g., node resizing), "pod" may still fail a check but preemption helps. We deliberately
610617
// chose to ignore those cases as unschedulable pods will be re-queued eventually.

pkg/scheduler/eventhandlers_test.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func TestPreCheckForNode(t *testing.T) {
115115
nodeFn func() *v1.Node
116116
existingPods, pods []*v1.Pod
117117
want []bool
118+
qHintEnabled bool
118119
}{
119120
{
120121
name: "regular node, pods with a single constraint",
@@ -137,6 +138,28 @@ func TestPreCheckForNode(t *testing.T) {
137138
},
138139
want: []bool{true, false, false, true, false, true, false, true, false},
139140
},
141+
{
142+
name: "no filtering when QHint is enabled",
143+
nodeFn: func() *v1.Node {
144+
return st.MakeNode().Name("fake-node").Label("hostname", "fake-node").Capacity(cpu8).Obj()
145+
},
146+
existingPods: []*v1.Pod{
147+
st.MakePod().Name("p").HostPort(80).Obj(),
148+
},
149+
pods: []*v1.Pod{
150+
st.MakePod().Name("p1").Req(cpu4).Obj(),
151+
st.MakePod().Name("p2").Req(cpu16).Obj(),
152+
st.MakePod().Name("p3").Req(cpu4).Req(cpu8).Obj(),
153+
st.MakePod().Name("p4").NodeAffinityIn("hostname", []string{"fake-node"}).Obj(),
154+
st.MakePod().Name("p5").NodeAffinityNotIn("hostname", []string{"fake-node"}).Obj(),
155+
st.MakePod().Name("p6").Obj(),
156+
st.MakePod().Name("p7").Node("invalid-node").Obj(),
157+
st.MakePod().Name("p8").HostPort(8080).Obj(),
158+
st.MakePod().Name("p9").HostPort(80).Obj(),
159+
},
160+
qHintEnabled: true,
161+
want: []bool{true, true, true, true, true, true, true, true, true},
162+
},
140163
{
141164
name: "tainted node, pods with a single constraint",
142165
nodeFn: func() *v1.Node {
@@ -194,13 +217,15 @@ func TestPreCheckForNode(t *testing.T) {
194217

195218
for _, tt := range tests {
196219
t.Run(tt.name, func(t *testing.T) {
220+
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SchedulerQueueingHints, tt.qHintEnabled)
221+
197222
nodeInfo := framework.NewNodeInfo(tt.existingPods...)
198223
nodeInfo.SetNode(tt.nodeFn())
199224
preCheckFn := preCheckForNode(nodeInfo)
200225

201-
var got []bool
226+
got := make([]bool, 0, len(tt.pods))
202227
for _, pod := range tt.pods {
203-
got = append(got, preCheckFn(pod))
228+
got = append(got, preCheckFn == nil || preCheckFn(pod))
204229
}
205230

206231
if diff := cmp.Diff(tt.want, got); diff != "" {

0 commit comments

Comments
 (0)