New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2e: Treat tainted nodes as unschedulable #35210
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2350,15 +2350,27 @@ func waitListSchedulableNodesOrDie(c clientset.Interface) *api.NodeList { | |
return nodes | ||
} | ||
|
||
// isNodeTainted checks if a node is tainted and thus not schedulable to pods (without a toleration) | ||
func isNodeTainted(node *api.Node) bool { | ||
nodeTaints, err := api.GetTaintsFromNodeAnnotations(node.Annotations) | ||
if err != nil { | ||
Failf("error getting taints: %v", err) | ||
} | ||
|
||
return len(nodeTaints) > 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should only return true if the Effect is NoSchedule |
||
} | ||
|
||
// Node is schedulable if: | ||
// 1) doesn't have "unschedulable" field set | ||
// 2) it's Ready condition is set to true | ||
// 3) doesn't have NetworkUnavailable condition set to true | ||
// 4) it isn't tainted | ||
func isNodeSchedulable(node *api.Node) bool { | ||
nodeReady := IsNodeConditionSetAsExpected(node, api.NodeReady, true) | ||
isTainted := isNodeTainted(node) | ||
networkReady := IsNodeConditionUnset(node, api.NodeNetworkUnavailable) || | ||
IsNodeConditionSetAsExpectedSilent(node, api.NodeNetworkUnavailable, false) | ||
return !node.Spec.Unschedulable && nodeReady && networkReady | ||
return !node.Spec.Unschedulable && nodeReady && networkReady && !isTainted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this might happen to work now, but taints/tolerations really makes it impossible to say that a node is schedulable or unschedulable in isolation -- you have to look at the pod in question also, and say the node is unschedulable for that pod iff the node has a taint that the pod does not tolerate. For example see PodToleratesNodeTaints() in plugin/pkg/scheduler/algorithm/predicates/predicates.go. (Of course the other tests apply in addition, like nodeReady, networkReady, etc. that is earlier in this line) |
||
} | ||
|
||
// GetReadySchedulableNodesOrDie addresses the common use case of getting nodes you can do work on. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does "without a toleration" mean? how would a test specify that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you're asking for more than "what is an example of a toleration"... I suspect you are, but here is an example of a toleration anyway:
https://github.com/kubernetes/kops/blob/master/upup/models/cloudup/resources/addons/dns-controller/v1.4.0.yaml#L23