From 430ebffe2b1dbad4347874933f6122fcbe24b3fd Mon Sep 17 00:00:00 2001 From: "Da K. Ma" Date: Tue, 23 Jan 2018 20:54:11 +0800 Subject: [PATCH] Checked node.Unscheulable in Toleration predicate. Signed-off-by: Da K. Ma --- pkg/scheduler/algorithm/predicates/predicates.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/scheduler/algorithm/predicates/predicates.go b/pkg/scheduler/algorithm/predicates/predicates.go index bd7d349d084..879f6a2272d 100644 --- a/pkg/scheduler/algorithm/predicates/predicates.go +++ b/pkg/scheduler/algorithm/predicates/predicates.go @@ -1395,6 +1395,14 @@ func (c *PodAffinityChecker) satisfiesPodsAffinityAntiAffinity(pod *v1.Pod, node // PodToleratesNodeTaints checks if a pod tolerations can tolerate the node taints func PodToleratesNodeTaints(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) { + if nodeInfo == nil || nodeInfo.Node() == nil { + return false, []algorithm.PredicateFailureReason{ErrNodeUnknownCondition}, nil + } + + if nodeInfo.Node().Spec.Unschedulable { + return false, []algorithm.PredicateFailureReason{ErrNodeUnschedulable}, nil + } + return podToleratesNodeTaints(pod, nodeInfo, func(t *v1.Taint) bool { // PodToleratesNodeTaints is only interested in NoSchedule and NoExecute taints. return t.Effect == v1.TaintEffectNoSchedule || t.Effect == v1.TaintEffectNoExecute