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

🐛 Machine Controller should try to retrieve node on delete #11032

Merged

Conversation

vincepri
Copy link
Member

@vincepri vincepri commented Aug 9, 2024

Consider this scenario:

  • Machine is created
  • InfraMachine is created
  • MachineHealthCheck is set to 10 minutes
  • [10 minutes pass]
  • Machine is marked as needing remediation
  • Machine and InfraMachine goes into deletion flow
  • Node finally joins the cluster, say 10 minutes + few seconds
  • InfraMachine is still waiting for VM to be deleted
  • Machine keeps retrying to delete, but nodeRef was never set
  • Machine, InfraMachine go away (finalizer removed)
  • Node object sticks around in the cluster

This changset allows the Machine controller to look into the cluster during deletion flow if the Node eventually got created before the infrastructure provider was able to fully delete the machine.

What this PR does / why we need it:

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 #

/area machine

@k8s-ci-robot k8s-ci-robot added area/machine Issues or PRs related to machine lifecycle management cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 9, 2024
@vincepri
Copy link
Member Author

vincepri commented Aug 9, 2024

Looking into tests if the change makes sense

Consider this scenario:

* Machine is created
* InfraMachine is created
* MachineHealthCheck is set to 10 minutes
* [10 minutes pass]
* Machine is marked as needing remediation
* Machine and InfraMachine goes into deletion flow
* Node finally joins the cluster, say 10 minutes + few seconds
* InfraMachine is still waiting for VM to be deleted
* Machine keeps retrying to delete, but `nodeRef` was never set
* Machine, InfraMachine go away (finalizer removed)
* Node object sticks around in the cluster

This changset allows the Machine controller to look into the cluster
during deletion flow if the Node eventually got created before the
infrastructure provider was able to fully delete the machine.

Signed-off-by: Vince Prignano <[email protected]>
@vincepri vincepri force-pushed the machine-node-deletion-fallback branch from f6d09ad to 9517bba Compare August 12, 2024 03:56
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Just some nits, please take a look for a follow-up PR.

Merging already as it makes sense to include it in the releases today

g.Expect(err).ToNot(HaveOccurred())
if tc.expectNodeDeletion {
n := &corev1.Node{}
g.Expect(fakeClient.Get(context.Background(), client.ObjectKeyFromObject(node), n)).NotTo(Succeed())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
g.Expect(fakeClient.Get(context.Background(), client.ObjectKeyFromObject(node), n)).NotTo(Succeed())
g.Expect(apierrors.IsNotFound(fakeClient.Get(context.Background(), client.ObjectKeyFromObject(node), n))).To(BeTrue())

nit

}

cluster := testCluster.DeepCopy()
if tc.clusterDeleted {
Copy link
Member

Choose a reason for hiding this comment

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

this seems to be unused

Name: "test",
Namespace: metav1.NamespaceDefault,
Labels: map[string]string{
clusterv1.MachineControlPlaneLabel: "",
Copy link
Member

@sbueringer sbueringer Aug 12, 2024

Choose a reason for hiding this comment

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

Should also have

clusterv1.ClusterNameLabel: "test-cluster",

(just noticed while diff'ing to figure out what the difference between the two Machines is)

@sbueringer
Copy link
Member

/lgtm
/approve

@sbueringer
Copy link
Member

/cherry-pick release-1.8

@sbueringer
Copy link
Member

/cherry-pick release-1.7

@k8s-infra-cherrypick-robot

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

In response to this:

/cherry-pick release-1.8

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-sigs/prow repository.

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

LGTM label has been added.

Git tree hash: 0d575840e42e4eb1686a6d581cfbaf1ea0996557

@k8s-infra-cherrypick-robot

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

In response to this:

/cherry-pick release-1.7

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-sigs/prow repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Aug 12, 2024
@k8s-ci-robot k8s-ci-robot merged commit 044dca2 into kubernetes-sigs:main Aug 12, 2024
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Aug 12, 2024
@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #11042

In response to this:

/cherry-pick release-1.8

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-sigs/prow repository.

@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #11043

In response to this:

/cherry-pick release-1.7

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-sigs/prow repository.

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/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/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.

4 participants