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

Update managed vnet check logic #5012

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

hrbasic
Copy link
Contributor

@hrbasic hrbasic commented Jul 23, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:
In some cases, using a BYO (Bring Your Own) VNet can cause problems with the deletion of route tables and network security groups due to an issue with checking if the VNet is managed. More information can be found in the related issue.

Which issue(s) this PR fixes:
Fixes #4930

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Refactor method for checking if a virtual network is managed

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Jul 23, 2024
Copy link

linux-foundation-easycla bot commented Jul 23, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: hrbasic / name: Hrvoje Basic (af19a3f)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 23, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @hrbasic!

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
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 23, 2024
@hrbasic
Copy link
Contributor Author

hrbasic commented Jul 23, 2024

/easycla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 23, 2024
@mboersma
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 Jul 23, 2024
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 51.23%. Comparing base (e40af9e) to head (af19a3f).
Report is 97 commits behind head on main.

Files with missing lines Patch % Lines
azure/scope/cluster.go 75.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5012      +/-   ##
==========================================
+ Coverage   51.19%   51.23%   +0.04%     
==========================================
  Files         274      274              
  Lines       24628    24637       +9     
==========================================
+ Hits        12608    12623      +15     
+ Misses      11234    11227       -7     
- Partials      786      787       +1     

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

@willie-yao
Copy link
Contributor

/assign

return false
}

isManaged := infrav1.Tags(vnet.Status.Tags).HasOwned(s.ClusterName())
Copy link
Contributor

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.

As described in the issue #4930, when AzureCluster is created using BYO Vnet: https://capz.sigs.k8s.io/topics/custom-vnet#pre-existing-vnet-and-subnets, virtual network object will be created, but during creation of Vnet, ID will be empty which will mark Vnet as managed. This causes creation of network security groups and route tables which will not be deleted (unless they are created manually using ASO). After certain time Vnet ID will be populated and marked as not-managed. So I believe that check s.Vnet().ID shouldn't be used here.
I was expecting that managed status will never be changed due to cache, but that wasn't the case.

Do we need this ID check for backward compatibility? Because I saw that this is not used in managed control plane.

Copy link
Contributor

Choose a reason for hiding this comment

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

That should be fine, thanks for the explanation!

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.

/lgtm
/assign @mboersma

return false
}

isManaged := infrav1.Tags(vnet.Status.Tags).HasOwned(s.ClusterName())
Copy link
Contributor

Choose a reason for hiding this comment

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

That should be fine, thanks for the explanation!

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

LGTM label has been added.

Git tree hash: 07d71e7b7097b2b4a4477f931cf5e935d92c4b01

@willie-yao
Copy link
Contributor

/assign @nojnhuh

Copy link
Contributor

@mboersma mboersma 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: mboersma

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 29, 2024
@k8s-ci-robot k8s-ci-robot merged commit 2b91b72 into kubernetes-sigs:main Aug 29, 2024
22 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Aug 29, 2024
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/bug Categorizes issue or PR as related to a bug. 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
Archived in project
Development

Successfully merging this pull request may close these issues.

BYO VNet Deletion Issues: Route Tables & NSGs
5 participants