forgiveness library changes

This commit is contained in:
Kevin
2017-01-14 16:18:14 +08:00
parent 16164c6a54
commit 36dcb57407
6 changed files with 389 additions and 79 deletions

View File

@@ -1158,33 +1158,15 @@ func PodToleratesNodeTaints(pod *v1.Pod, meta interface{}, nodeInfo *schedulerca
return false, nil, err
}
if tolerationsToleratesTaints(tolerations, taints) {
if v1.TolerationsTolerateTaintsWithFilter(tolerations, taints, func(t *v1.Taint) bool {
// PodToleratesNodeTaints is only interested in NoSchedule taints.
return t.Effect == v1.TaintEffectNoSchedule
}) {
return true, nil, nil
}
return false, []algorithm.PredicateFailureReason{ErrTaintsTolerationsNotMatch}, nil
}
func tolerationsToleratesTaints(tolerations []v1.Toleration, taints []v1.Taint) bool {
// If the taint list is nil/empty, it is tolerated by all tolerations by default.
if len(taints) == 0 {
return true
}
for i := range taints {
taint := &taints[i]
// skip taints that have effect PreferNoSchedule, since it is for priorities
if taint.Effect == v1.TaintEffectPreferNoSchedule {
continue
}
if len(tolerations) == 0 || !v1.TaintToleratedByTolerations(taint, tolerations) {
return false
}
}
return true
}
// Determine if a pod is scheduled with best-effort QoS
func isPodBestEffort(pod *v1.Pod) bool {
return qos.GetPodQOS(pod) == v1.PodQOSBestEffort