Add isNodeSchedulableWithoutTainted()

For reducing usage of system.DeprecatedMightBeMasterNode(), this
adds isNodeSchedulableWithoutTainted().
This commit is contained in:
Kenichi Omichi 2020-06-23 23:52:31 +00:00
parent a463b25c9d
commit 13aae61789
2 changed files with 10 additions and 3 deletions

View File

@ -374,7 +374,7 @@ func GetMasterAndWorkerNodes(c clientset.Interface) (sets.String, *v1.NodeList,
for _, n := range all.Items {
if system.DeprecatedMightBeMasterNode(n.Name) {
masters.Insert(n.Name)
} else if IsNodeSchedulable(&n) && isNodeUntainted(&n) {
} else if isNodeSchedulableWithoutTaints(&n) {
nodes.Items = append(nodes.Items, n)
}
}
@ -478,6 +478,14 @@ func IsNodeReady(node *v1.Node) bool {
return nodeReady && networkReady
}
// isNodeSchedulableWithoutTaints returns true if:
// 1) doesn't have "unschedulable" field set
// 2) it also returns true from IsNodeReady
// 3) it also returns true from isNodeUntainted
func isNodeSchedulableWithoutTaints(node *v1.Node) bool {
return IsNodeSchedulable(node) && isNodeUntainted(node)
}
// hasNonblockingTaint returns true if the node contains at least
// one taint with a key matching the regexp.
func hasNonblockingTaint(node *v1.Node, nonblockingTaints string) bool {

View File

@ -28,7 +28,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
"k8s.io/kubernetes/test/e2e/system"
testutils "k8s.io/kubernetes/test/utils"
)
@ -84,7 +83,7 @@ func WaitForTotalHealthy(c clientset.Interface, timeout time.Duration) error {
}
missingPodsPerNode = make(map[string][]string)
for _, node := range nodes.Items {
if !system.DeprecatedMightBeMasterNode(node.Name) {
if isNodeSchedulableWithoutTaints(&node) {
for _, requiredPod := range requiredPerNodePods {
foundRequired := false
for _, presentPod := range systemPodsPerNode[node.Name] {