Skip to content

chore: Consider node.kubernetes.io/not-ready:NoExecute as ephemeral #2265

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/controllers/provisioning/scheduling/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,27 @@ var _ = Context("Scheduling", func() {
node2 := ExpectScheduled(ctx, env.Client, secondPod)
Expect(node1.Name).To(Equal(node2.Name))
})
It("should assume pod will schedule to a node with ephemeral taint node.kubernetes.io/not-ready:NoExecute when the node is uninitialized", func() {
ExpectApplied(ctx, env.Client, nodePool)
initialPod := test.UnschedulablePod()
bindings := ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, initialPod)
ExpectScheduled(ctx, env.Client, initialPod)

// delete the pod so that the node is empty
ExpectDeleted(ctx, env.Client, initialPod)
node1 := bindings.Get(initialPod).Node
node1.Spec.Taints = []corev1.Taint{{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute}}
node1.Labels = lo.Assign(node1.Labels, map[string]string{v1.NodeInitializedLabelKey: "true"})

ExpectApplied(ctx, env.Client, node1)
ExpectReconcileSucceeded(ctx, nodeStateController, client.ObjectKeyFromObject(node1))

opts := test.PodOptions{Tolerations: []corev1.Toleration{{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule}}}
secondPod := test.UnschedulablePod(opts)
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, secondPod)
node2 := ExpectScheduled(ctx, env.Client, secondPod)
Expect(node1.Name).To(Equal(node2.Name))
})
It("should not assume pod will schedule to a tainted node", func() {
opts := test.PodOptions{ResourceRequirements: corev1.ResourceRequirements{
Limits: map[corev1.ResourceName]resource.Quantity{
Expand Down
13 changes: 10 additions & 3 deletions pkg/controllers/state/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,7 @@ var _ = Describe("Taints", func() {
It("should not consider ephemeral taints on a managed node that isn't initialized", func() {
node.Spec.Taints = []corev1.Taint{
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
}
Expand All @@ -1823,6 +1824,7 @@ var _ = Describe("Taints", func() {
node = ExpectExists(ctx, env.Client, node)
node.Spec.Taints = []corev1.Taint{
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
}
Expand All @@ -1832,9 +1834,10 @@ var _ = Describe("Taints", func() {
ExpectReconcileSucceeded(ctx, nodeController, client.ObjectKeyFromObject(node))

stateNode := ExpectStateNodeExists(cluster, node)
Expect(stateNode.Taints()).To(HaveLen(3))
Expect(stateNode.Taints()).To(HaveLen(4))
Expect(stateNode.Taints()).To(ContainElements(
corev1.Taint{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
corev1.Taint{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
corev1.Taint{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
corev1.Taint{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
))
Expand Down Expand Up @@ -1883,16 +1886,18 @@ var _ = Describe("Taints", func() {
It("should consider ephemeral taints on an unmanaged node that isn't initialized", func() {
node.Spec.Taints = []corev1.Taint{
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
}
ExpectApplied(ctx, env.Client, node)
ExpectReconcileSucceeded(ctx, nodeController, client.ObjectKeyFromObject(node))

stateNode := ExpectStateNodeExists(cluster, node)
Expect(stateNode.Taints()).To(HaveLen(3))
Expect(stateNode.Taints()).To(HaveLen(4))
Expect(stateNode.Taints()).To(ContainElements(
corev1.Taint{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
corev1.Taint{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
corev1.Taint{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
corev1.Taint{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
))
Expand All @@ -1904,6 +1909,7 @@ var _ = Describe("Taints", func() {
node = ExpectExists(ctx, env.Client, node)
node.Spec.Taints = []corev1.Taint{
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
}
Expand All @@ -1912,9 +1918,10 @@ var _ = Describe("Taints", func() {
ExpectReconcileSucceeded(ctx, nodeController, client.ObjectKeyFromObject(node))

stateNode := ExpectStateNodeExists(cluster, node)
Expect(stateNode.Taints()).To(HaveLen(3))
Expect(stateNode.Taints()).To(HaveLen(4))
Expect(stateNode.Taints()).To(ContainElements(
corev1.Taint{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
corev1.Taint{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
corev1.Taint{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
corev1.Taint{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
))
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduling/taints.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
// since we expect these taints to eventually be removed
var KnownEphemeralTaints = []corev1.Taint{
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoSchedule},
{Key: corev1.TaintNodeNotReady, Effect: corev1.TaintEffectNoExecute},
{Key: corev1.TaintNodeUnreachable, Effect: corev1.TaintEffectNoSchedule},
{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: corev1.TaintEffectNoSchedule, Value: "true"},
v1.UnregisteredNoExecuteTaint,
Expand Down
Loading