Skip to content
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

🐛 Fix MachinePool node taint patching #8462

Merged

Conversation

CecileRobertMichon
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon commented Apr 3, 2023

What this PR does / why we need it: Fixes flake observed in CAPZ testing with CAPI v1.4.0 where MachinePool Nodes {node.cluster.x-k8s.io/uninitialized: } taints don't get removed right away (~15 minute delay). The root cause is that we are escaping the second part of the if annotations.AddAnnotations(node, desired) || taints.RemoveNodeTaint(node, clusterv1.NodeUninitializedTaint) when the first part if true (see https://play.golang.com/p/i-6vDeSeeBE). This results in the controller returning no error without having patched the taints. Only after the resyncPeriod does the controller get requeued and Taints finally updated.

Credits to @nawazkh @willie-yao @jackfrancis for helping me find this

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #8442

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 3, 2023
@CecileRobertMichon
Copy link
Contributor Author

/cherry-pick release-1.4
/assign @ykakarap @fabriziopandini

I'm working on adding unit tests for this (it's not trivial because the unit tests are non existent at the moment) + testing this patch with kubernetes-sigs/cluster-api-provider-azure#3378

@k8s-infra-cherrypick-robot

@CecileRobertMichon: once the present PR merges, I will cherry-pick it on top of release-1.4 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.4
/assign @ykakarap @fabriziopandini

I'm working on adding unit tests for this (it's not trivial because the unit tests are non existent at the moment) + testing this patch with kubernetes-sigs/cluster-api-provider-azure#3378

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@ykakarap ykakarap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 3, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 6a083f25d17c237e3fc4c020d99039cae1463052

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 3, 2023
@k8s-ci-robot k8s-ci-robot requested a review from ykakarap April 3, 2023 23:45
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 3, 2023
clusterv1.OwnerKindAnnotation: mp.Kind,
clusterv1.OwnerNameAnnotation: mp.Name,
}
// Add annotations and drop NodeUninitializedTaint.
Copy link
Contributor Author

@CecileRobertMichon CecileRobertMichon Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the real change here (line 225-228). Everything else is just extracting the code into a function so it can be unit tested.

@CecileRobertMichon
Copy link
Contributor Author

Added unit tests. Had to extract the patching code into a helper function that takes a client so it could be unit tested.

@nawazkh
Copy link
Member

nawazkh commented Apr 4, 2023

Looks good to me! 🚀

@CecileRobertMichon
Copy link
Contributor Author

/retest

Copy link
Contributor

@willie-yao willie-yao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Copy link
Contributor

@ykakarap ykakarap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Thank you @CecileRobertMichon 🙂

internal/util/taints/taints_test.go Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 4, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 8d7f9ff4f3277b16c8a67df3bf99806bd79b40a5

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!
/lgtm

@CecileRobertMichon
Copy link
Contributor Author

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 52fc099 into kubernetes-sigs:main Apr 4, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.5 milestone Apr 4, 2023
@k8s-infra-cherrypick-robot

@CecileRobertMichon: new pull request created: #8468

In response to this:

/cherry-pick release-1.4
/assign @ykakarap @fabriziopandini

I'm working on adding unit tests for this (it's not trivial because the unit tests are non existent at the moment) + testing this patch with kubernetes-sigs/cluster-api-provider-azure#3378

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@johannesfrey
Copy link
Contributor

/area machinepool

@k8s-ci-robot k8s-ci-robot added the area/machinepool Issues or PRs related to machinepools label Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/machinepool Issues or PRs related to machinepools cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MachinePool controller does not watch nodes, causing delay in removing uninitialized node taint
9 participants