Fix public IP resolution when LB frontend uses static privateIPAddress - #622
Fix public IP resolution when LB frontend uses static privateIPAddress#622Adam Rudell (arudell) with Copilot wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…lookup
When a load balancer frontend IP configuration uses a static privateIPAddress
from the public VIP logical network instead of a publicIPAddress resource
reference, Get-PublicIpReference now returns the IP address directly rather
than returning null.
Changes:
- Get-PublicIpReference returns a PSCustomObject{ResourceRef, IPAddress}
instead of a plain resource ref string, supporting both publicIPAddress
(resource ref lookup) and privateIPAddress (static IP) frontend configs
- Get-SdnNetworkInterfaceOutboundPublicIPAddress handles both return cases
- Added mock LB (lb-outbound-0002) with static privateIPAddress frontend
and NIC (tenantvm3) referencing it
- Added Pester tests for all three public IP resolution scenarios
Closes #178
Co-authored-by: arudell <18577812+arudell@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/modules/SdnDiag.NetworkController.psm1:285
- This fallback treats every non-empty load-balancer frontend
privateIPAddressas public, but the condition never verifies the comment's required public VIP logical network. A frontend on a private logical subnet would therefore be returned asPublicIPAddressand can also trigger the public-IP trace path inSdnDiag.Common. Resolve the frontend subnet againstLogicalNetworksand requireisPublic(similar toGet-SdnPublicIPPoolUsageSummary) before returning it; include a private-subnet negative test.
elseif (![string]::IsNullOrEmpty($frontendConfig.properties.privateIPAddress)) {
tests/offline/data/SdnApiResources/loadBalancers.json:90
- This subnet reference is dangling:
logicalNetworks.jsoncontains noPublicVIPresource, while its existing public subnet is/logicalNetworks/transit-0001/subnets/transit-subnet-0001and its pool contains40.40.40.6. Point this frontend at that fixture so the test data models a consistent Network Controller resource graph.
"resourceRef": "/logicalNetworks/PublicVIP/subnets/PublicVIP-subnet-0001"
|
Copilot will this new output change downstream callers in how they call into this function? What does the new output look like if I were to run this against a resource associated with publicIP resource, vs if set to static? |
No change is required for downstream public callers.
For the helper output:
[pscustomobject]@{
ResourceRef = '/publicIPAddresses/pip-outbound-0001'
IPAddress = $null
}
[pscustomobject]@{
ResourceRef = $null
IPAddress = '40.40.40.6'
}Public cmdlet output shape remains the same (
|
Get-PublicIpReferenceonly resolved public IPs via apublicIPAddressresource reference on the LB frontend config. When the frontend instead configured a staticprivateIPAddressfrom the public VIP logical network, the function returned$nulland the outbound public IP was silently missed.Changes
Get-PublicIpReference— return type changed from a plain resource ref string toPSCustomObject{ResourceRef, IPAddress}:publicIPAddresspresent →ResourceRefpopulated, caller fetches IP from resourceprivateIPAddresspresent (nopublicIPAddress) →IPAddresspopulated directly, no secondary lookup neededGet-SdnNetworkInterfaceOutboundPublicIPAddress— updated caller to branch onResourceRefvsIPAddress:Test coverage
lb-outbound-0002withprivateIPAllocationMethod: Static/privateIPAddress: 40.40.40.6on its frontend (nopublicIPAddressresource ref)tenantvm3referencing this LB's backend poolChange type
Checklist: