Skip to content

NetworkInfo support for IPv6 and dual stack#1432

Open
poojav25 wants to merge 2 commits into
vmware-tanzu:mainfrom
poojav25:networkinfo
Open

NetworkInfo support for IPv6 and dual stack#1432
poojav25 wants to merge 2 commits into
vmware-tanzu:mainfrom
poojav25:networkinfo

Conversation

@poojav25
Copy link
Copy Markdown

@poojav25 poojav25 commented May 11, 2026

The LoadBalancerBackendIPs field was declared in VPCState but never populated. This change wires it up for all three LB paths:

  • NSX LB non-TEP-less: read all IPs from ExtendedAttributes["IpAddresses"].Values on the realized interface via new GetPolicyInterfaceIPs helper (both IPv4+IPv6).
  • NSX LB TEP-less: best-effort fetch of both _DEFAULT--VPC_SERVICE_IP (IPv4) and _DEFAULT--VPC_SERVICE_IP_V6 (IPv6) allocations; NotFound is silently skipped so VNA-only, VNS-IPv4-only, VNS-IPv6-only, and VNS-dual-stack all work correctly.
  • AVI: collect NetworkAddress from every VpcSubnetStatus result (one per IP family for dual-stack) instead of only Results[0].

Testing done:

→ LoadBalancerBackendIPs populated (NSX LB non-TEP-less, CTGW testbed)

kubectl get networkinfo -n test-lb-backend test-lb-backend -o json | \
  python3 -c "
import json, sys
v = json.load(sys.stdin)['vpcs'][0]
print('LoadBalancerIPAddresses:', v.get('loadBalancerIPAddresses',''))
print('LoadBalancerBackendIPs: ', v.get('loadBalancerBackendIPs',[]))
"
LoadBalancerIPAddresses: 100.64.0.1
LoadBalancerBackendIPs:  ['100.64.0.1']

-> NSX API source confirmed — operator reads gateway-interface realized entity:

curl -sku admin:"..." \
  "https://<NSX>/policy/api/v1/infra/realized-state/realized-entity?\
realized_path=/orgs/default/projects/.../realized-state/enforcement-points/\
default/vpcs/test-lb-backend_cmd98/gateway-interface" \
  | python3 -m json.tool | grep -A5 "IpAddresses"
    "key": "IpAddresses",
    "values": [
        "100.64.0.1/31"
    ]

…nd AVI

The LoadBalancerBackendIPs field was declared in VPCState but never populated.
This change wires it up for all three LB paths:

- NSX LB non-TEP-less: read all IPs from ExtendedAttributes["IpAddresses"].Values
  on the realized interface via new GetPolicyInterfaceIPs helper (both IPv4+IPv6).
- NSX LB TEP-less: best-effort fetch of both _DEFAULT--VPC_SERVICE_IP (IPv4) and
  _DEFAULT--VPC_SERVICE_IP_V6 (IPv6) allocations; NotFound is silently skipped so
  VNA-only, VNS-IPv4-only, VNS-IPv6-only, and VNS-dual-stack all work correctly.
- AVI: collect NetworkAddress from every VpcSubnetStatus result (one per IP family
  for dual-stack) instead of only Results[0].

LoadBalancerIPAddresses (existing field) is kept backward-compatible via a new
primaryLBIP helper that follows the Kubernetes convention: IPv4 preferred for
dual-stack, IPv6-only fallback, empty for no-LB.

LoadBalancerBackendIPs is sorted before reflect.DeepEqual in setNetworkInfoVPCStatus
to prevent spurious CR updates when IPs are returned in a different order.

Unit tests added/updated for all modified functions across:
  pkg/nsx/services/realizestate, pkg/nsx/services/vpc,
  pkg/controllers/networkinfo (controller + utils).

E2E tests added in test/e2e/nsx_networkinfo_test.go:
  testLBBackendIPsPopulated, testDualStackLBBackendIPs, testLBBackendIPsIdempotent.
@dantingl
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@poojav25 poojav25 changed the title [WIP] NetworkInfo support for IPv6 and dual stack NetworkInfo support for IPv6 and dual stack May 13, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.38298% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.80%. Comparing base (f106c7f) to head (a5ec528).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/nsx/services/vpc/vpc.go 46.15% 20 Missing and 8 partials ⚠️
.../controllers/networkinfo/networkinfo_controller.go 54.16% 2 Missing and 9 partials ⚠️
pkg/nsx/services/realizestate/realize_state.go 87.50% 1 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (56.38%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1432      +/-   ##
==========================================
- Coverage   77.00%   75.80%   -1.20%     
==========================================
  Files         154      155       +1     
  Lines       21995    22103     +108     
==========================================
- Hits        16938    16756     -182     
- Misses       3854     3868      +14     
- Partials     1203     1479     +276     
Flag Coverage Δ
unit-tests 75.80% <56.38%> (-1.20%) ⬇️
Files with missing lines Coverage Δ
pkg/controllers/networkinfo/networkinfo_utils.go 66.51% <100.00%> (-15.18%) ⬇️
pkg/nsx/services/realizestate/realize_state.go 76.47% <87.50%> (+3.39%) ⬆️
.../controllers/networkinfo/networkinfo_controller.go 53.74% <54.16%> (-16.94%) ⬇️
pkg/nsx/services/vpc/vpc.go 53.79% <46.15%> (-19.13%) ⬇️

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@yanjunz97 yanjunz97 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just a nit

})
}

func (service *RealizeStateService) GetPolicyInterfaceIP(realizedPath string) (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe remove this function as it is not used any more?

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.

4 participants