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

Skip system pool validation while cluster is paused/moved #2774

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

pkbhowmick
Copy link
Contributor

@pkbhowmick pkbhowmick commented Nov 3, 2022

Signed-off-by: Pulak Kanti Bhowmick [email protected]

What type of PR is this?
/kind bug

What this PR does / why we need it:
Fix bug for cluster move operation
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 #2656

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Fixed bug for cluster move operation.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 3, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @pkbhowmick!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-azure 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-azure has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 3, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @pkbhowmick. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 3, 2022
@@ -267,6 +267,10 @@ func (m *AzureManagedMachinePool) validateLastSystemNodePool(cli client.Client)
return nil
}

if ownerCluster.Spec.Paused {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd prefer some other "clusterctl move"-specific indication that we're O.K. to delete the system node pool. Does a move operation result in an annotation or other metadata that we can detect?

Also, we should probably just implement this in the (m *AzureManagedMachinePool) ValidateDelete method itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, I see there is no annotation is added in the move operation.
Move client library ref: https://github.com/kubernetes-sigs/cluster-api/blob/5eaf9e3c0e93d93b75e57675a7e9fb560d15ae37/cmd/clusterctl/client/cluster/mover.go#L334

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we want to implement this in ValidateDelete method, we need to get the cluster object which is already done in func (m *AzureManagedMachinePool) validateLastSystemNodePool method. I think, some code will be repeated then.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Jont828 @fabriziopandini does either of you know if there is any marker that indicates a delete is initiated as part of a move operation more specific than the pause annotation?

Copy link
Member

Choose a reason for hiding this comment

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

currently, we don't add any markers to resources before the move.
cluster being paused is the only proxy information, but it is not 100% reliable because a cluster can be paused for any reason.

note: if required, adding a "move" marker on one or more move-hierarchies root (cluster, cluster class, crs) is something that makes sense; adding a "move" marker on all resources is a little bit more complex...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I agree with @CecileRobertMichon

There are going to be edge cases with this change but I think they are sufficiently "weird" that preventing them isn't more important than addressing this broken core capi functionality for AKS.

My only feedback at this point would be a unit test for this (I think TestAzureManagedMachinePool_ValidateCreate is a good copy/paste candidate for scaffolding a new UT for this func.

Thank you @pkbhowmick!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, should I only add a new UT for this func?

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct, in order to UT this new func, you'll need a new func (for example a new UT func TestValidateLastSystemNodePool based on existing pattern in TestAzureManagedMachinePool_ValidateCreate).

You will be doing the project an extra credit favor by adding coverage for an existing func that we don't have coverage for, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it! Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think TestAzureManagedMachinePool_ValidateCreate does this already

@nawazkh
Copy link
Member

nawazkh commented Dec 14, 2022

Hey @pkbhowmick, how is this PR coming along?

@jackfrancis jackfrancis added this to the next milestone Dec 15, 2022
@pkbhowmick
Copy link
Contributor Author

pkbhowmick commented Dec 18, 2022

Hi @nawazkh ,
Sorry for replying late. The current fix is working fine. @jackfrancis wants some specific indicator to identify move operation.

While deleting objects for move operation, child objects are deleted first. So, we can say that, while deleting last system pool if there is a paused Cluster object without delation time stamp set, this is clear indication for cluster move operation.

If we agree with this, then we can proceed with current fix. Moreover, I am using this fix, which works fine so far.
ref: https://github.com/kubernetes-sigs/cluster-api/blob/main/cmd/clusterctl/client/cluster/mover.go#L311

@jackfrancis jackfrancis modified the milestones: next, v1.8 Jan 19, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2023
@CecileRobertMichon
Copy link
Contributor

/assign @jackfrancis

To decide how we want to move this forward

@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 Jan 25, 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 Jan 25, 2023
@pkbhowmick pkbhowmick changed the title WIP: Skip system pool validation while cluster is paused/moved Skip system pool validation while cluster is paused/moved Jan 25, 2023
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 25, 2023
@pkbhowmick pkbhowmick requested review from jackfrancis and CecileRobertMichon and removed request for jackfrancis and CecileRobertMichon January 25, 2023 19:35
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>

Add unit test for validateLastSystemNodePool method

Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
@CecileRobertMichon
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 31, 2023
@CecileRobertMichon
Copy link
Contributor

@jackfrancis is this ready to go (pending tests)?

@jackfrancis
Copy link
Contributor

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 0e82085bda3f02bde656234cf981fb0e800be069

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackfrancis

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 Jan 31, 2023
@pkbhowmick
Copy link
Contributor Author

/retest-required

@pkbhowmick
Copy link
Contributor Author

/retest

1 similar comment
@CecileRobertMichon
Copy link
Contributor

/retest

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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
None yet
Development

Successfully merging this pull request may close these issues.

AKS Cluster must have at least one system pool unless it is being clusterctl-moved
6 participants