Merge pull request #86230 from hex108/skip_schedule

Scheduler handles pod annotation updates during scheduling more gracefully
This commit is contained in:
Kubernetes Prow Robot 2019-12-31 17:03:40 -08:00 committed by GitHub
commit 26b52e84a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View File

@ -599,9 +599,7 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
return
}
pod := podInfo.Pod
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)
if sched.skipPodSchedule(pod) {
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 {
Client clientset.Interface
}

View File

@ -291,6 +291,12 @@ func TestScheduler(t *testing.T) {
AssumeFunc: func(pod *v1.Pod) {
gotAssumedPod = pod
},
IsAssumedPodFunc: func(pod *v1.Pod) bool {
if pod == nil || gotAssumedPod == nil {
return false
}
return pod.UID == gotAssumedPod.UID
},
}
s := &Scheduler{