Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Pod Conditions from scheduling queue updates #91252

Merged
merged 1 commit into from May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/scheduler/eventhandlers.go
Expand Up @@ -21,7 +21,6 @@ import (
"reflect"

"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/scheduler/profile"

v1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
Expand All @@ -32,6 +31,7 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/scheduler/internal/queue"
"k8s.io/kubernetes/pkg/scheduler/profile"
)

func (sched *Scheduler) onPvAdd(obj interface{}) {
Expand Down Expand Up @@ -306,8 +306,8 @@ func responsibleForPod(pod *v1.Pod, profiles profile.Map) bool {
// skipPodUpdate checks whether the specified pod update should be ignored.
// This function will return true if
// - The pod has already been assumed, AND
// - The pod has only its ResourceVersion, Spec.NodeName, Annotations, ManagedFields and/or Finalizers
// updated.
// - The pod has only its ResourceVersion, Spec.NodeName, Annotations,
// ManagedFields, Finalizers and/or Conditions updated.
func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
// Non-assumed pods should never be skipped.
isAssumed, err := sched.SchedulerCache.IsAssumedPod(pod)
Expand Down Expand Up @@ -343,8 +343,10 @@ func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
// Same as above, when annotations are modified with ServerSideApply,
// ManagedFields may also change and must be excluded
p.ManagedFields = nil
// Finalizers must be excluded because scheduled result can not be affected
// The following might be changed by external controllers, but they don't
// affect scheduling decisions.
p.Finalizers = nil
p.Status.Conditions = nil
return p
}
assumedPodCopy, podCopy := f(assumedPod), f(pod)
Expand Down
24 changes: 24 additions & 0 deletions pkg/scheduler/eventhandlers_test.go
Expand Up @@ -204,6 +204,30 @@ func TestSkipPodUpdate(t *testing.T) {
},
expected: true,
},
{
name: "with changes on Conditions",
pod: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-0",
},
Status: v1.PodStatus{
Conditions: []v1.PodCondition{
{Type: "foo"},
},
},
},
isAssumedPodFunc: func(*v1.Pod) bool {
return true
},
getPodFunc: func(*v1.Pod) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-0",
},
}
},
expected: true,
},
} {
t.Run(test.name, func(t *testing.T) {
c := &Scheduler{
Expand Down