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

handle clusterctl block-move annotation #4213

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

nojnhuh
Copy link
Contributor

@nojnhuh nojnhuh commented Nov 1, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:

This PR makes CAPZ aware of the clusterctl clusterctl.cluster.x-k8s.io/block-move annotation added by kubernetes-sigs/cluster-api#8690 and uses it to block clusterctl move when ASO resources have not yet been paused. These changes modify the necessary controllers to add the annotation at the beginning of a "normal" reconciliation and remove it at the end of a "pause" reconciliation.

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

Special notes for your reviewer:

These changes are not expected to build until #4182 or any other CAPI bump to v1.6.0+.

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

CAPZ now adds the `clusterctl.cluster.x-k8s.io/block-move` annotation during `clusterctl move` to better synchronize pause operations

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Nov 1, 2023
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 1, 2023
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 1, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2023
@nojnhuh nojnhuh marked this pull request as ready for review December 12, 2023 04:35
@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 Dec 12, 2023
Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (703a98b) 60.88% compared to head (27d8eff) 60.97%.
Report is 39 commits behind head on main.

Files Patch % Lines
exp/controllers/azuremachinepool_controller.go 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4213      +/-   ##
==========================================
+ Coverage   60.88%   60.97%   +0.08%     
==========================================
  Files         190      190              
  Lines       18983    19029      +46     
==========================================
+ Hits        11557    11602      +45     
- Misses       6789     6790       +1     
  Partials      637      637              

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

@nojnhuh
Copy link
Contributor Author

nojnhuh commented Dec 12, 2023

/test ?

@k8s-ci-robot
Copy link
Contributor

@nojnhuh: The following commands are available to trigger required jobs:

  • /test pull-cluster-api-provider-azure-build
  • /test pull-cluster-api-provider-azure-ci-entrypoint
  • /test pull-cluster-api-provider-azure-e2e
  • /test pull-cluster-api-provider-azure-e2e-aks
  • /test pull-cluster-api-provider-azure-test
  • /test pull-cluster-api-provider-azure-verify

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-provider-azure-apidiff
  • /test pull-cluster-api-provider-azure-apiversion-upgrade
  • /test pull-cluster-api-provider-azure-capi-e2e
  • /test pull-cluster-api-provider-azure-conformance
  • /test pull-cluster-api-provider-azure-conformance-custom-builds
  • /test pull-cluster-api-provider-azure-conformance-dual-stack-with-ci-artifacts
  • /test pull-cluster-api-provider-azure-conformance-ipv6-with-ci-artifacts
  • /test pull-cluster-api-provider-azure-conformance-with-ci-artifacts
  • /test pull-cluster-api-provider-azure-e2e-optional
  • /test pull-cluster-api-provider-azure-e2e-workload-upgrade
  • /test pull-cluster-api-provider-azure-windows-containerd-upstream-with-ci-artifacts-serial-slow
  • /test pull-cluster-api-provider-azure-windows-custom-builds
  • /test pull-cluster-api-provider-azure-windows-with-ci-artifacts

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

  • pull-cluster-api-provider-azure-apidiff
  • pull-cluster-api-provider-azure-build
  • pull-cluster-api-provider-azure-ci-entrypoint
  • pull-cluster-api-provider-azure-e2e
  • pull-cluster-api-provider-azure-e2e-aks
  • pull-cluster-api-provider-azure-test
  • pull-cluster-api-provider-azure-verify

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.

@nojnhuh
Copy link
Contributor Author

nojnhuh commented Dec 12, 2023

/test pull-cluster-api-provider-azure-capi-e2e

@nojnhuh
Copy link
Contributor Author

nojnhuh commented Dec 12, 2023

/test pull-cluster-api-provider-azure-ci-entrypoint
/test pull-cluster-api-provider-azure-capi-e2e

@nojnhuh
Copy link
Contributor Author

nojnhuh commented Dec 13, 2023

/assign @Jont828

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.

Looks good pending one nit!

@@ -1120,3 +1121,29 @@ func GetClusterScoper(ctx context.Context, logger logr.Logger, c client.Client,

return nil, errors.Errorf("unsupported infrastructure type %q, should be AzureCluster or AzureManagedCluster", cluster.Spec.InfrastructureRef.Kind)
}

// AddBlockMoveAnnotation adds CAPI's block-move annotation returns whether or not the change had an effect.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// AddBlockMoveAnnotation adds CAPI's block-move annotation returns whether or not the change had an effect.
// AddBlockMoveAnnotation adds CAPI's block-move annotation and returns whether or not the annotation was added.

nit for more clarity

Copy link
Contributor

@Jont828 Jont828 left a comment

Choose a reason for hiding this comment

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

LGTM pending Willie's comment

// Register our finalizer immediately to avoid orphaning Azure resources on delete
needsPatch := controllerutil.AddFinalizer(azureCluster, infrav1.ClusterFinalizer)
// Register the block-move annotation immediately to avoid moving un-paused ASO resources
needsPatch = AddBlockMoveAnnotation(azureCluster) || needsPatch
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, this just means we don't want to allow clusterctl move to happen before we're done reconciling, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, this makes sure there isn't any interval of time where both an ASO resource has reconcile-policy: manage and the AzureCluster doesn't have the block-move label, which is the danger zone.

@willie-yao
Copy link
Contributor

/lgtm

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

LGTM label has been added.

Git tree hash: 52d8be664b66eb331ab38b7905783f2d869fa304

@dtzar dtzar added this to the v1.13 milestone Dec 14, 2023
@mboersma mboersma assigned mboersma and unassigned mboersma Dec 14, 2023
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/lgtm
/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 Dec 15, 2023
@k8s-ci-robot k8s-ci-robot merged commit ea84b59 into kubernetes-sigs:main Dec 15, 2023
20 checks passed
@nojnhuh nojnhuh deleted the aso-block-move branch December 19, 2023 16:34
@nojnhuh nojnhuh mentioned this pull request May 3, 2024
4 tasks
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Handle CAPI's block-move annotation
7 participants