mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #91252 from alculquicondor/fix-reschedule
Skip Pod Conditions from scheduling queue updates
This commit is contained in:
commit
4b9b9ab753
@ -21,7 +21,6 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/profile"
|
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
@ -32,6 +31,7 @@ import (
|
|||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/internal/queue"
|
"k8s.io/kubernetes/pkg/scheduler/internal/queue"
|
||||||
|
"k8s.io/kubernetes/pkg/scheduler/profile"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (sched *Scheduler) onPvAdd(obj interface{}) {
|
func (sched *Scheduler) onPvAdd(obj interface{}) {
|
||||||
@ -306,8 +306,8 @@ func responsibleForPod(pod *v1.Pod, profiles profile.Map) bool {
|
|||||||
// skipPodUpdate checks whether the specified pod update should be ignored.
|
// skipPodUpdate checks whether the specified pod update should be ignored.
|
||||||
// This function will return true if
|
// This function will return true if
|
||||||
// - The pod has already been assumed, AND
|
// - The pod has already been assumed, AND
|
||||||
// - The pod has only its ResourceVersion, Spec.NodeName, Annotations, ManagedFields and/or Finalizers
|
// - The pod has only its ResourceVersion, Spec.NodeName, Annotations,
|
||||||
// updated.
|
// ManagedFields, Finalizers and/or Conditions updated.
|
||||||
func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
|
func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
|
||||||
// Non-assumed pods should never be skipped.
|
// Non-assumed pods should never be skipped.
|
||||||
isAssumed, err := sched.SchedulerCache.IsAssumedPod(pod)
|
isAssumed, err := sched.SchedulerCache.IsAssumedPod(pod)
|
||||||
@ -343,8 +343,10 @@ func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool {
|
|||||||
// Same as above, when annotations are modified with ServerSideApply,
|
// Same as above, when annotations are modified with ServerSideApply,
|
||||||
// ManagedFields may also change and must be excluded
|
// ManagedFields may also change and must be excluded
|
||||||
p.ManagedFields = nil
|
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.Finalizers = nil
|
||||||
|
p.Status.Conditions = nil
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
assumedPodCopy, podCopy := f(assumedPod), f(pod)
|
assumedPodCopy, podCopy := f(assumedPod), f(pod)
|
||||||
|
@ -204,6 +204,30 @@ func TestSkipPodUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: true,
|
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) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
c := &Scheduler{
|
c := &Scheduler{
|
||||||
|
Loading…
Reference in New Issue
Block a user