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 SDK to track2 in ensureServiceEndpoints #3618

Closed
wants to merge 2 commits into from

Conversation

bitoku
Copy link
Collaborator

@bitoku bitoku commented Jun 6, 2024

Which issue this PR addresses:

Fixes a part of https://issues.redhat.com/browse/ARO-4665 and https://issues.redhat.com/browse/ARO-7316

This is blocked by #3616

What this PR does / why we need it:

This PR makes ensureServiceEndpoints action use track2 SDK.

It also contains the change of subnet manager, and I'm going to remove the subnet manager completely in the future.
I want to remove the subnet manager because some methods (CreateOrUpdateFromIds, CreateOrUpdateSubnets, and GetHighestFreeIP) are used only once, and I think it adds unnecessary complexity.
The merit to have it which I can think of is that it can be mocked and can keep the unit tests simple, but after removing it, the test is not that complex and I think the suggested change would make the behaviour clearer.

Any comments about removal of the subnet manager are welcome.

Test plan for issue:

unit tests for ensureServiceEndpoints.
e2e

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

tech debt cleanup N/A

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

cluster installation test

@bitoku
Copy link
Collaborator Author

bitoku commented Jun 6, 2024

/azp run ci,e2e

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@bitoku bitoku force-pushed the ensureServiceEndpoints-track2 branch from 405a124 to b6d3ae4 Compare June 6, 2024 18:35
@github-actions github-actions bot added the needs-rebase branch needs a rebase label Jun 7, 2024
Copy link

github-actions bot commented Jun 7, 2024

Please rebase pull request.

@bitoku bitoku force-pushed the ensureServiceEndpoints-track2 branch from b6d3ae4 to cde1d7c Compare June 7, 2024 11:13
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Jun 7, 2024
Copy link

@AldoFusterTurpin AldoFusterTurpin left a comment

Choose a reason for hiding this comment

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

Providing review as requested 🙂
LGTM. Just left a comment about one chunk of code to share an idea, NOT asking to change it. Thank you.

Comment on lines +32 to +48
for _, subnetId := range subnetIds {
r, err := arm.ParseResourceID(subnetId)
if err != nil {
return err
}
subnet, err := m.armSubnets.Get(ctx, r.ResourceGroupName, r.Parent.Name, r.Name, nil)
if err != nil {
return err
}
shouldUpdate := addEndpointsToSubnet(api.SubnetsEndpoints, &subnet.Subnet)
if !shouldUpdate {
continue
}
err = m.armSubnets.CreateOrUpdateAndWait(ctx, r.ResourceGroupName, r.Parent.Name, r.Name, subnet.Subnet, nil)
if err != nil {
return err
}

Choose a reason for hiding this comment

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

Just a comment off the top of my head.

There is nothing wrong with this, but a slightly different approach that could also work would be to divide that in the following way:

  • first get all the subnets that should be updated (in a function returning a slice)
  • pass those subnets that should be updated (return value from the previous function) to another function that would simply do CreateOrUpdateAndWait for each value in the slice.

I don't think is much better than what the PR does, but it sticks to the principle of not iterating + doing stuff with what you are iterating, but instead, first do some processing and once that is processed update the values in Azure. Not asking to change that, just a comment about a pattern that sometimes can be useful, even to simplify unit tests in some cases (as you don't need to mock m.armSubnets because you just want to test the function that does the business logic which is filtering the subnets).

🙂

@bitoku bitoku added the blocked Issue or pull request is blocked label Jun 12, 2024
@github-actions github-actions bot added the needs-rebase branch needs a rebase label Jun 28, 2024
Copy link

Please rebase pull request.

Copy link

github-actions bot commented Sep 5, 2024

Please rebase pull request.

@github-actions github-actions bot added the needs-rebase branch needs a rebase label Sep 5, 2024
@bitoku bitoku closed this Sep 20, 2024
@bitoku bitoku reopened this Sep 20, 2024
@bitoku bitoku force-pushed the ensureServiceEndpoints-track2 branch from e5ba65f to 590ccaf Compare September 20, 2024 09:58
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Sep 20, 2024
@bitoku bitoku force-pushed the ensureServiceEndpoints-track2 branch 2 times, most recently from 639eaa5 to 3da6a1e Compare September 20, 2024 10:32
@github-actions github-actions bot added the needs-rebase branch needs a rebase label Sep 24, 2024
Copy link

Please rebase pull request.

@bitoku bitoku force-pushed the ensureServiceEndpoints-track2 branch from 3da6a1e to 8a66831 Compare September 24, 2024 12:22
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Sep 24, 2024
@bitoku bitoku removed the blocked Issue or pull request is blocked label Sep 24, 2024
@github-actions github-actions bot added the needs-rebase branch needs a rebase label Sep 26, 2024
Copy link

Please rebase pull request.

@bitoku bitoku force-pushed the ensureServiceEndpoints-track2 branch from 8a66831 to 682af6a Compare September 30, 2024 18:35
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Sep 30, 2024
@bitoku bitoku force-pushed the ensureServiceEndpoints-track2 branch from 682af6a to 70b493c Compare October 2, 2024 15:57
@bitoku
Copy link
Collaborator Author

bitoku commented Oct 2, 2024

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link

github-actions bot commented Oct 3, 2024

Please rebase pull request.

@github-actions github-actions bot added the needs-rebase branch needs a rebase label Oct 3, 2024
@bitoku bitoku closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase branch needs a rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants