mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Skip scheduling the pod if it has been assumed and the pod updates could be skipped.
This commit is contained in:
parent
cfdfd043a0
commit
706e90a033
@ -599,9 +599,7 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
pod := podInfo.Pod
|
pod := podInfo.Pod
|
||||||
if pod.DeletionTimestamp != nil {
|
if sched.skipPodSchedule(pod) {
|
||||||
sched.Recorder.Eventf(pod, nil, v1.EventTypeWarning, "FailedScheduling", "Scheduling", "skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
|
|
||||||
klog.V(3).Infof("Skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,6 +762,25 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skipPodSchedule returns true if we could skip scheduling the pod for specified cases.
|
||||||
|
func (sched *Scheduler) skipPodSchedule(pod *v1.Pod) bool {
|
||||||
|
// Case 1: pod is being deleted.
|
||||||
|
if pod.DeletionTimestamp != nil {
|
||||||
|
sched.Recorder.Eventf(pod, nil, v1.EventTypeWarning, "FailedScheduling", "Scheduling", "skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
|
||||||
|
klog.V(3).Infof("Skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Case 2: pod has been assumed and pod updates could be skipped.
|
||||||
|
// An assumed pod can be added again to the scheduling queue if it got an update event
|
||||||
|
// during its previous scheduling cycle but before getting assumed.
|
||||||
|
if sched.skipPodUpdate(pod) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
type podConditionUpdaterImpl struct {
|
type podConditionUpdaterImpl struct {
|
||||||
Client clientset.Interface
|
Client clientset.Interface
|
||||||
}
|
}
|
||||||
|
@ -309,6 +309,12 @@ func TestScheduler(t *testing.T) {
|
|||||||
AssumeFunc: func(pod *v1.Pod) {
|
AssumeFunc: func(pod *v1.Pod) {
|
||||||
gotAssumedPod = pod
|
gotAssumedPod = pod
|
||||||
},
|
},
|
||||||
|
IsAssumedPodFunc: func(pod *v1.Pod) bool {
|
||||||
|
if pod == nil || gotAssumedPod == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return pod.UID == gotAssumedPod.UID
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
s := &Scheduler{
|
s := &Scheduler{
|
||||||
|
Loading…
Reference in New Issue
Block a user