Skip to content

Commit da6fcfa

Browse files
Skip Pod Conditions from scheduling queue updates
Signed-off-by: Aldo Culquicondor <[email protected]>
1 parent 6c9aab2 commit da6fcfa

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

pkg/scheduler/eventhandlers.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"reflect"
2222

2323
"k8s.io/klog/v2"
24-
"k8s.io/kubernetes/pkg/scheduler/profile"
2524

2625
v1 "k8s.io/api/core/v1"
2726
storagev1 "k8s.io/api/storage/v1"
@@ -32,6 +31,7 @@ import (
3231
"k8s.io/client-go/tools/cache"
3332
"k8s.io/kubernetes/pkg/features"
3433
"k8s.io/kubernetes/pkg/scheduler/internal/queue"
34+
"k8s.io/kubernetes/pkg/scheduler/profile"
3535
)
3636

3737
func (sched *Scheduler) onPvAdd(obj interface{}) {
@@ -306,8 +306,8 @@ func responsibleForPod(pod *v1.Pod, profiles profile.Map) bool {
306306
// skipPodUpdate checks whether the specified pod update should be ignored.
307307
// This function will return true if
308308
// - The pod has already been assumed, AND
309-
// - The pod has only its ResourceVersion, Spec.NodeName, Annotations, ManagedFields and/or Finalizers
310-
// updated.
309+
// - The pod has only its ResourceVersion, Spec.NodeName, Annotations,
310+
// ManagedFields, Finalizers and/or Conditions updated.
311311
func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
312312
// Non-assumed pods should never be skipped.
313313
isAssumed, err := sched.SchedulerCache.IsAssumedPod(pod)
@@ -343,8 +343,10 @@ func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
343343
// Same as above, when annotations are modified with ServerSideApply,
344344
// ManagedFields may also change and must be excluded
345345
p.ManagedFields = nil
346-
// Finalizers must be excluded because scheduled result can not be affected
346+
// The following might be changed by external controllers, but they don't
347+
// affect scheduling decisions.
347348
p.Finalizers = nil
349+
p.Status.Conditions = nil
348350
return p
349351
}
350352
assumedPodCopy, podCopy := f(assumedPod), f(pod)

pkg/scheduler/eventhandlers_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,30 @@ func TestSkipPodUpdate(t *testing.T) {
204204
},
205205
expected: true,
206206
},
207+
{
208+
name: "with changes on Conditions",
209+
pod: &v1.Pod{
210+
ObjectMeta: metav1.ObjectMeta{
211+
Name: "pod-0",
212+
},
213+
Status: v1.PodStatus{
214+
Conditions: []v1.PodCondition{
215+
{Type: "foo"},
216+
},
217+
},
218+
},
219+
isAssumedPodFunc: func(*v1.Pod) bool {
220+
return true
221+
},
222+
getPodFunc: func(*v1.Pod) *v1.Pod {
223+
return &v1.Pod{
224+
ObjectMeta: metav1.ObjectMeta{
225+
Name: "pod-0",
226+
},
227+
}
228+
},
229+
expected: true,
230+
},
207231
} {
208232
t.Run(test.name, func(t *testing.T) {
209233
c := &Scheduler{

0 commit comments

Comments
 (0)