From 511b2ecaa8025364e8ef43427ff08709b056f0cb Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 4 Nov 2016 02:12:31 -0400 Subject: [PATCH] Avoid hard-coding list of Node Conditions We assume that if a Condition isn't well-known, that it blocks scheduling of pods, and that the "unhealthy" value is api.ConditionTrue --- plugin/pkg/scheduler/factory/factory.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/plugin/pkg/scheduler/factory/factory.go b/plugin/pkg/scheduler/factory/factory.go index 23fd57f274..3f004682c1 100644 --- a/plugin/pkg/scheduler/factory/factory.go +++ b/plugin/pkg/scheduler/factory/factory.go @@ -507,15 +507,22 @@ func getNodeConditionPredicate() cache.NodeConditionPredicate { // - NodeReady condition status is ConditionTrue, // - NodeOutOfDisk condition status is ConditionFalse, // - NodeNetworkUnavailable condition status is ConditionFalse. - if cond.Type == api.NodeReady && cond.Status != api.ConditionTrue { - glog.V(4).Infof("Ignoring node %v with %v condition status %v", node.Name, cond.Type, cond.Status) - return false - } else if cond.Type == api.NodeOutOfDisk && cond.Status != api.ConditionFalse { - glog.V(4).Infof("Ignoring node %v with %v condition status %v", node.Name, cond.Type, cond.Status) - return false - } else if cond.Type == api.NodeNetworkUnavailable && cond.Status != api.ConditionFalse { - glog.V(4).Infof("Ignoring node %v with %v condition status %v", node.Name, cond.Type, cond.Status) - return false + switch cond.Type { + case api.NodeReady: + if cond.Status != api.ConditionTrue { + glog.V(4).Infof("Ignoring node %v with %v condition status %v", node.Name, cond.Type, cond.Status) + return false + } + + case api.NodeMemoryPressure, api.NodeDiskPressure: + // We don't block on "pressure" conditions; these are warnings, not errors! + + default: + // We assume everything else is blocking if the condition is True or Unknown + if cond.Status != api.ConditionFalse { + glog.V(4).Infof("Ignoring node %v with %v condition status %v", node.Name, cond.Type, cond.Status) + return false + } } } // Ignore nodes that are marked unschedulable