From 60cace8f7ba2df998bc623c16dbe89fe5bd7e669 Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Mon, 24 Jun 2019 11:12:19 -0700 Subject: [PATCH] util: add ValidNode variant without sched check this adds a variant of ValidNode that doesn't check for no-sched taint (e.g. kubectl cordon). Signed-off-by: Noah Watkins --- pkg/operator/k8sutil/node.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/operator/k8sutil/node.go b/pkg/operator/k8sutil/node.go index be9993ae2..ad3fb250a 100644 --- a/pkg/operator/k8sutil/node.go +++ b/pkg/operator/k8sutil/node.go @@ -36,13 +36,9 @@ var validTopologyLabelKeys = []string{ "failure-domain.kubernetes.io", } -// ValidNode returns true if the node (1) is schedulable, (2) meets Rook's placement terms, and -// (3) is ready. False otherwise. -func ValidNode(node v1.Node, placement rookalpha.Placement) (bool, error) { - if !GetNodeSchedulable(node) { - return false, nil - } - +// ValidNodeNoSched returns true if the node (1) meets Rook's placement terms, +// and (2) is ready. False otherwise. +func ValidNodeNoSched(node v1.Node, placement rookalpha.Placement) (bool, error) { p, err := NodeMeetsPlacementTerms(node, placement, false) if err != nil { return false, fmt.Errorf("failed to check if node meets Rook placement terms. %+v", err) @@ -58,6 +54,16 @@ func ValidNode(node v1.Node, placement rookalpha.Placement) (bool, error) { return true, nil } +// ValidNode returns true if the node (1) is schedulable, (2) meets Rook's placement terms, and +// (3) is ready. False otherwise. +func ValidNode(node v1.Node, placement rookalpha.Placement) (bool, error) { + if !GetNodeSchedulable(node) { + return false, nil + } + + return ValidNodeNoSched(node, placement) +} + // GetValidNodes returns all nodes that (1) are not cordoned, (2) meet Rook's placement terms, and // (3) are ready. func GetValidNodes(rookStorage rookalpha.StorageScopeSpec, clientset kubernetes.Interface, placement rookalpha.Placement) []rookalpha.Node {