fix podInformer FilterFunc bug

This commit is contained in:
xushiwei 00425595 2019-06-03 15:21:35 +08:00 committed by wackxu
parent b7a3371ca1
commit 8b69136904
2 changed files with 10 additions and 4 deletions

View File

@ -18,7 +18,6 @@ package cache
import (
"fmt"
"strings"
"sync"
"time"
@ -250,10 +249,12 @@ func newSchedulerCache(config *rest.Config, schedulerName string, defaultQueue s
switch obj.(type) {
case *v1.Pod:
pod := obj.(*v1.Pod)
if strings.Compare(pod.Spec.SchedulerName, schedulerName) == 0 && pod.Status.Phase == v1.PodPending {
return true
if !responsibleForPod(pod, schedulerName) {
if len(pod.Spec.NodeName) == 0 {
return false
}
}
return pod.Status.Phase != v1.PodPending
return true
default:
return false
}

View File

@ -58,3 +58,8 @@ func createShadowPodGroup(pod *v1.Pod) *v1alpha1.PodGroup {
},
}
}
// responsibleForPod returns true if the pod has asked to be scheduled by the given scheduler.
func responsibleForPod(pod *v1.Pod, schedulerName string) bool {
return schedulerName == pod.Spec.SchedulerName
}