Commit 6873d2a5 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #39081 from ChenLingPeng/no-schedule-deleting-pod

Automatic merge from submit-queue Skip schedule deleting pod Since binding a deleting pod will always return fail, we should skip that kind of pod early
parents c8e07f80 e2a465ae
...@@ -123,6 +123,11 @@ func (s *Scheduler) Run() { ...@@ -123,6 +123,11 @@ func (s *Scheduler) Run() {
func (s *Scheduler) scheduleOne() { func (s *Scheduler) scheduleOne() {
pod := s.config.NextPod() pod := s.config.NextPod()
if pod.DeletionTimestamp != nil {
s.config.Recorder.Eventf(pod, v1.EventTypeWarning, "FailedScheduling", "skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
glog.V(3).Infof("Skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
return
}
glog.V(3).Infof("Attempting to schedule pod: %v/%v", pod.Namespace, pod.Name) glog.V(3).Infof("Attempting to schedule pod: %v/%v", pod.Namespace, pod.Name)
start := time.Now() start := time.Now()
......
...@@ -59,6 +59,16 @@ func podWithID(id, desiredHost string) *v1.Pod { ...@@ -59,6 +59,16 @@ func podWithID(id, desiredHost string) *v1.Pod {
} }
} }
func deletingPod(id string) *v1.Pod {
deletionTimestamp := metav1.Now()
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: id, SelfLink: testapi.Default.SelfLink("pods", id), DeletionTimestamp: &deletionTimestamp},
Spec: v1.PodSpec{
NodeName: "",
},
}
}
func podWithPort(id, desiredHost string, port int) *v1.Pod { func podWithPort(id, desiredHost string, port int) *v1.Pod {
pod := podWithID(id, desiredHost) pod := podWithID(id, desiredHost)
pod.Spec.Containers = []v1.Container{ pod.Spec.Containers = []v1.Container{
...@@ -122,6 +132,10 @@ func TestScheduler(t *testing.T) { ...@@ -122,6 +132,10 @@ func TestScheduler(t *testing.T) {
expectError: errB, expectError: errB,
expectErrorPod: podWithID("foo", ""), expectErrorPod: podWithID("foo", ""),
eventReason: "FailedScheduling", eventReason: "FailedScheduling",
}, {
sendPod: deletingPod("foo"),
algo: mockScheduler{"", nil},
eventReason: "FailedScheduling",
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment