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

🐛 Perform draining and volume detachment once until completion #11590

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Dec 17, 2024

What this PR does / why we need it:

The draining logic continues to access the cluster even after the hook is removed or completed, causing a deadlock on machine removal in a non KCP backed CP provider implementation.

In a cluster with a kubelet local mode, competed draining and etcd membership removal causes inability to access API server externally, so the operation continues to error out even after success. This does not allow underlying machine to be removed.

The solution makes the PreTeminateHook agnostic to the provider, and ensures that completion of the operation does not lead to further attempts to access the cluster.

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 #11591

/area machine

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 17, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign chrischdi for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 do-not-merge/needs-area PR is missing an area label label Dec 17, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 17, 2024
@Danil-Grigorev
Copy link
Member Author

/area bootstrap

@k8s-ci-robot k8s-ci-robot added area/bootstrap Issues or PRs related to bootstrap providers and removed do-not-merge/needs-area PR is missing an area label labels Dec 17, 2024
@Danil-Grigorev Danil-Grigorev force-pushed the drain-once-until-completion branch from df2f637 to 76d0706 Compare December 18, 2024 10:44
@Danil-Grigorev Danil-Grigorev changed the title 🐛 Perform draining and volume detaching once until completion 🐛 Perform draining and volume detachment once until completion Dec 18, 2024
@Danil-Grigorev Danil-Grigorev force-pushed the drain-once-until-completion branch from 76d0706 to f472e1a Compare December 18, 2024 16:56
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 18, 2024
@@ -657,14 +657,26 @@ func (r *Reconciler) isNodeDrainAllowed(m *clusterv1.Machine) bool {
return false
}

if conditions.IsTrue(m, clusterv1.DrainingSucceededCondition) {
Copy link
Member

Choose a reason for hiding this comment

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

We should not start to rely on this condition to be set as it is because its gonna be deprecated/removed in v1beta2.

Also propably a change in the behavior for all VMs (previously followed reconciliation may also run again through drain).

Copy link
Member Author

Choose a reason for hiding this comment

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

I unified the check under the PreTerminateDeleteHookSucceededCondition, which allows for both methods to run until completion. It is not listed in the proposal as a part of deprecation/removal AFAICT

Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
@Danil-Grigorev Danil-Grigorev force-pushed the drain-once-until-completion branch from f472e1a to 1021f8e Compare December 19, 2024 10:09
@furkatgofurov7
Copy link
Member

Thanks for review @chrischdi 👍🏼
cc @sbueringer @enxebre @fabriziopandini hey folks, would you please have a look at this when you have time since it is blocking us (CAPRKE2 provider) to bump and use CAPI v1.9.x series?

@alexander-demicev
Copy link
Contributor

/lgtm

A backport would be very much appreciated 🙏

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

LGTM label has been added.

Git tree hash: 0bcc510758d20e84eb7b2d56a889fcf26def4356

@Danil-Grigorev
Copy link
Member Author

/area machine

@k8s-ci-robot k8s-ci-robot added the area/machine Issues or PRs related to machine lifecycle management label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bootstrap Issues or PRs related to bootstrap providers area/machine Issues or PRs related to machine lifecycle management 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Machine fails to finish draining/volume detachment after successful completion
5 participants