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

🌱 Remove handling for orphaned VSphereMachines #2429

Conversation

killianmuldoon
Copy link
Contributor

Remove special handling for orphaned VSphereMachines. VSphereMachines should no longer be orphaned by CAPI MachineSets on creation so this safeguard is no longer needed.

Fixes #2054

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 12, 2023
@killianmuldoon killianmuldoon changed the title 🌱 Remove handling for orphaned VSphereMachines [WIP] 🌱 Remove handling for orphaned VSphereMachines Oct 12, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Oct 12, 2023
@killianmuldoon killianmuldoon changed the title [WIP] 🌱 Remove handling for orphaned VSphereMachines 🌱 Remove handling for orphaned VSphereMachines Oct 13, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 13, 2023
@killianmuldoon killianmuldoon force-pushed the pr-remove-orphaned-machine-handling branch from 93511ad to c242fe5 Compare October 13, 2023 10:59
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 13, 2023
@killianmuldoon killianmuldoon force-pushed the pr-remove-orphaned-machine-handling branch from c242fe5 to 004b849 Compare October 13, 2023 11:22
@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@a1db12e). Click here to learn what that means.
Report is 62 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2429   +/-   ##
=======================================
  Coverage        ?   63.93%           
=======================================
  Files           ?      123           
  Lines           ?     8731           
  Branches        ?        0           
=======================================
  Hits            ?     5582           
  Misses          ?     2741           
  Partials        ?      408           
Files Coverage Δ
controllers/vspherecluster_reconciler.go 67.76% <ø> (ø)
controllers/vspheremachine_controller.go 77.38% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@killianmuldoon
Copy link
Contributor Author

/retest

@sbueringer
Copy link
Member

/lgtm

/assign @chrischdi

@killianmuldoon Would it be possible to test this once manually or with the clusterctl upgrade test? (Just to get some additional confidence)

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

LGTM label has been added.

Git tree hash: 547100069e49269d72c4bd3262499a6ddcd8b4bf

@@ -158,12 +154,6 @@ func (r *clusterReconciler) reconcileDelete(ctx context.Context, clusterCtx *cap
log := log.WithValues("VSphereMachine", klog.KObj(vsphereMachine))
ctx := ctrl.LoggerInto(ctx, log)

Copy link
Member

Choose a reason for hiding this comment

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

Missed this before. Shouldn't we be able to drop the entire finalizer handling here?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right - we can get rid of the entire block that deals with deleting Machines here.

@sbueringer
Copy link
Member

cc @srm09

@killianmuldoon
Copy link
Contributor Author

/hold

Will test this manually

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 23, 2023
@sbueringer
Copy link
Member

Will test this manually

WDYT about #2429 (comment)?

@killianmuldoon killianmuldoon force-pushed the pr-remove-orphaned-machine-handling branch from 004b849 to 959691c Compare November 1, 2023 15:51
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 1, 2023
@killianmuldoon
Copy link
Contributor Author

/test

@k8s-ci-robot
Copy link
Contributor

@killianmuldoon: The /test command needs one or more targets.
The following commands are available to trigger required jobs:

  • /test pull-cluster-api-provider-vsphere-conformance-main
  • /test pull-cluster-api-provider-vsphere-e2e-full-main
  • /test pull-cluster-api-provider-vsphere-e2e-main
  • /test pull-cluster-api-provider-vsphere-test-integration-main
  • /test pull-cluster-api-provider-vsphere-test-main
  • /test pull-cluster-api-provider-vsphere-verify-main

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-provider-vsphere-apidiff-main

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-provider-vsphere-apidiff-main
  • pull-cluster-api-provider-vsphere-e2e-main
  • pull-cluster-api-provider-vsphere-test-integration-main
  • pull-cluster-api-provider-vsphere-test-main
  • pull-cluster-api-provider-vsphere-verify-main

In response to this:

/test

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.

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

LGTM label has been added.

Git tree hash: 9b2b2e4f1ef12d07edfb17895569cc981a719577

@killianmuldoon
Copy link
Contributor Author

One questions: This PR builds up on the base, that a user did first upgraded to a CAPV version >= v1.8.x , so owner refs are all okay, right?

Yeah - exactly we should consider this directly a part of the ownerReferences fixes.

@chrischdi
Copy link
Member

Sounds great!

/approve

There's a still a hold on it :-)

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 2, 2023
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

one left nit

/approve cancel

// If the VSphereCluster has been previously set as an ownerReference remove it. This may have been set in an older
// version of CAPV to prevent VSphereMachines from being orphaned, but is no longer needed.
// For more info see: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/issues/2054
// TODO (killianmuldoon): Decide when this can be removed.
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove this comment or code? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was meant to be a bit longer term - i.e. this is migration code and eventually when all existing Clusters have passed through this migration we shouldn't need it any more. I've updated this to be a bit clearer, without asserting when it should be removed.

@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 2, 2023
machineDeletionCount++
// Remove the finalizer since VM creation wouldn't proceed
log.Info("Removing finalizer from VSphereMachine")
ctrlutil.RemoveFinalizer(vsphereMachine, infrav1.MachineFinalizer)
Copy link
Member

Choose a reason for hiding this comment

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

Don't we still need something which removes this finalizer? Or should this already have happened a longer time ago?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right - let me put this on [WIP] - I'm still trying to test it properly.

Copy link
Contributor Author

@killianmuldoon killianmuldoon Nov 7, 2023

Choose a reason for hiding this comment

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

This finalizer is going to be removed in the vspheremachine_controller at

if apierrors.IsNotFound(err) {
// The VM is deleted so remove the finalizer.
ctrlutil.RemoveFinalizer(machineCtx.GetVSphereMachine(), infrav1.MachineFinalizer)
return reconcile.Result{}, nil
}

Previously the VSphereCluster was able to do a full cleanup in case VSphereMachines were orphaned. They shouldn't be able to become orphaned now as CAPI ensure InfrastructureMachines should always have an ownerReference.

@killianmuldoon killianmuldoon changed the title 🌱 Remove handling for orphaned VSphereMachines [WIP] 🌱 Remove handling for orphaned VSphereMachines Nov 2, 2023
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 2, 2023
@killianmuldoon killianmuldoon force-pushed the pr-remove-orphaned-machine-handling branch from 959691c to f4c6b2d Compare November 7, 2023 16:23
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 7, 2023
@killianmuldoon
Copy link
Contributor Author

One questions: This PR builds up on the base, that a user did first upgraded to a CAPV version >= v1.8.x , so owner refs are all okay, right?

One comment on this - contradicting what I said above 😅

The migration here is independent from the owner reference migration in v1.8.2 as it doesn't deal with versions. In this case we should keep the owner reference migration code - which removes the VSphereCluster owner reference from the VSphereMachine - for as long as we'd like to to ensure all Clusters are migrated.

@killianmuldoon killianmuldoon changed the title [WIP] 🌱 Remove handling for orphaned VSphereMachines 🌱 Remove handling for orphaned VSphereMachines Nov 7, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 7, 2023
@sbueringer
Copy link
Member

One final comment

@killianmuldoon killianmuldoon force-pushed the pr-remove-orphaned-machine-handling branch from f4c6b2d to c82f792 Compare November 9, 2023 14:54
@killianmuldoon
Copy link
Contributor Author

/retest

@sbueringer
Copy link
Member

Thx!

/lgtm
/approve

Feel free to hold cancel

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

LGTM label has been added.

Git tree hash: c049b412588caf3dacf7f3350536139e7aec5bc1

@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 Nov 9, 2023
@killianmuldoon
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 10, 2023
@k8s-ci-robot k8s-ci-robot merged commit 0ba8082 into kubernetes-sigs:main Nov 10, 2023
17 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Nov 10, 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. 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.

Remove handling of orphaned Machines in reconcileDelete of vspherecluster_controller
4 participants