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

[ARO-15009] fix: add logic to skip subnet update under certain conditions #4087

Merged
merged 3 commits into from
Feb 10, 2025

Conversation

scottd018
Copy link
Collaborator

Which issue this PR addresses:

Fixes https://issues.redhat.com/browse/ARO-15009

What this PR does / why we need it:

This commit addresses the need for the subnet/write permissions. Currently, in all scenarios, the subnet/write permission is used via the subnet.CreateOrUpdate method. This change adds logic to determine if the values are already set to Disabled and skips running the subnet.CreateOrUpdate method if it is already set appropriately. This will save the need to make an extra API call and also allow users to configure things like Azure policy where subnet/write permissions are not needed.

Closed #4084 in favor of this PR.

Test plan for issue:

Currently awaiting access for the Dev ARO-RP shared environment. Once I get access I can run a full E2E test and comment with the results.

Is there any documentation that needs to be updated for this PR?

No documentation needs to be updated, as the end user experience looks identical.

How do you know this will function as expected in production?

No change to the existing logic is introduced. We are only introducing a skip of the API call to create or update a subnet if it does not currently match a desired stated of "Disabled".

This commit addresses the need for the subnet/write permissions.  Currently, in all scenarios, the
subnet/write permission is used via the subnet.CreateOrUpdate method.  This change adds logic to
determine if the values are already set to Disabled and skips running the subnet.CreateOrUpdate
 method if it is already set appropriately.  This will save the need to make an extra API call and
also allow users to configure things like Azure policy where subnet/write permissions are not needed.

Signed-off-by: Dustin Scott <[email protected]>
Copy link
Contributor

@kimorris27 kimorris27 left a comment

Choose a reason for hiding this comment

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

The change LGTM, but one thing I missed from my original review - you could add a unit test case validating that CreateOrUpdate is not called when those two attributes both already have the correct values.

@scottd018
Copy link
Collaborator Author

The change LGTM, but one thing I missed from my original review - you could add a unit test case validating that CreateOrUpdate is not called when those two attributes both already have the correct values.

Absolutely can do that. I'll get a new commit added and pushed. I thought about doing it originally, but hadn't seen any test cases for the specific method (maybe I missed them...let me know if there's some specific place you want them otherwise I can add it to the _test.go file like I'm used to doing).

@kimorris27
Copy link
Contributor

The change LGTM, but one thing I missed from my original review - you could add a unit test case validating that CreateOrUpdate is not called when those two attributes both already have the correct values.

Absolutely can do that. I'll get a new commit added and pushed. I thought about doing it originally, but hadn't seen any test cases for the specific method (maybe I missed them...let me know if there's some specific place you want them otherwise I can add it to the _test.go file like I'm used to doing).

The unit tests for the function you tweaked are here:

func TestSetMasterSubnetPolicies(t *testing.T) {

@scottd018
Copy link
Collaborator Author

scottd018 commented Feb 6, 2025

The change LGTM, but one thing I missed from my original review - you could add a unit test case validating that CreateOrUpdate is not called when those two attributes both already have the correct values.

Absolutely can do that. I'll get a new commit added and pushed. I thought about doing it originally, but hadn't seen any test cases for the specific method (maybe I missed them...let me know if there's some specific place you want them otherwise I can add it to the _test.go file like I'm used to doing).

The unit tests for the function you tweaked are here:

func TestSetMasterSubnetPolicies(t *testing.T) {

@kimorris27 Take a look a 26139fa and ca2b1ca. I added a couple of tests that seem to align with the others that currently exist. Let me know if you need any other changes. Thanks!

@hawkowl
Copy link
Collaborator

hawkowl commented Feb 7, 2025

/azp run ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kimorris27 kimorris27 merged commit 59491b7 into master Feb 10, 2025
20 of 22 checks passed
@kimorris27 kimorris27 deleted the scottd018/ARO-15009 branch February 10, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants