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

Replaces the use of client subnet to use armnetwork.SubnetsClient` #4012

Closed
wants to merge 14 commits into from

Conversation

ehvs
Copy link
Collaborator

@ehvs ehvs commented Dec 13, 2024

Which issue this PR addresses:

https://issues.redhat.com/browse/ARO-12538

Replaces the use of client subnet to use armnetwork.SubnetsClient.

What this PR does / why we need it:

Avoid deprecation.

Test plan for issue:

Tested a few times using on dryrun mode with pipeline Purge RedHat Dev-Gratis.
https://msazure.visualstudio.com/AzureRedHatOpenShift/_build/results?buildId=110288783&view=logs&j=a4f1910f-c367-5697-edcd-724d81cde23b&t=bc103e47-9b88-5c56-fcad-f3f2f0b2ed91

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

No

@ehvs ehvs requested review from bitoku and fahlmant as code owners December 13, 2024 14:26
Copy link
Collaborator

@bitoku bitoku left a comment

Choose a reason for hiding this comment

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

mostly LGTM
a few comments about parsing a subnetID.

Comment on lines 79 to 93
if secGroupSubnet.ID == nil || secGroupSubnet.Name == nil {
continue
}

vnetID, _, err := apisubnet.Split(*secGroupSubnet.ID)
if err != nil {
return err
}

rc.log.Debugf("Removing security group from subnet: %s/%s/%s", *resourceGroup.Name, *secGroup.Name, *subnet.Name)
r, err := azure.ParseResourceID(vnetID)
if err != nil {
return err
}

subnet, err := rc.subnet.Get(ctx, *resourceGroup.Name, r.ResourceName, *secGroupSubnet.Name, nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can parse subnet ID like this.

r, err := arm.ParseResourceID(subnetId)
if err != nil {
return err
}
subnet, err := m.armSubnets.Get(ctx, r.ResourceGroupName, r.Parent.Name, r.Name, nil)

Comment on lines 105 to 114
vnetID, _, err := apisubnet.Split(*subnet.ID)
if err != nil {
return err
}

err = rc.subnet.CreateOrUpdate(ctx, *subnet.ID, subnet)
r, err := azure.ParseResourceID(vnetID)
if err != nil {
return err
}
err = rc.subnet.CreateOrUpdateAndWait(ctx, *resourceGroup.Name, r.ResourceName, *subnet.Name, subnet.Subnet, nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can parse subnet ID like this.

r, err := arm.ParseResourceID(subnetId)
if err != nil {
return err
}
subnet, err := m.armSubnets.Get(ctx, r.ResourceGroupName, r.Parent.Name, r.Name, nil)

@ehvs ehvs closed this Dec 18, 2024
@ehvs ehvs deleted the hevs/ARO-12538 branch December 18, 2024 12:50
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.

2 participants