Skip to content

Enhance Subnet totalip calculation for shared subnet#1384

Open
yanjunz97 wants to merge 1 commit intovmware-tanzu:mainfrom
yanjunz97:shared-subnet-ip
Open

Enhance Subnet totalip calculation for shared subnet#1384
yanjunz97 wants to merge 1 commit intovmware-tanzu:mainfrom
yanjunz97:shared-subnet-ip

Conversation

@yanjunz97
Copy link
Contributor

@yanjunz97 yanjunz97 commented Mar 3, 2026

User can create IPReservation and SubnetPort on shared Subnet from NSX side.
Thus we need to always check the shared Subnet ip pool for totalip and allocated ip changes.

Testing done:
Static pool case
Created pre-created SubnetSet with 2 DHCPDeactivated Subnets

spec:
  subnetNames:
  - test-2
  - test
status:
  conditions:
  - lastTransitionTime: "2026-03-02T07:08:24Z"
    message: SubnetSet CR has been successfully created/updated
    reason: SubnetSetReady
    status: "True"
    type: Ready
  subnets:
  - gatewayAddresses:
    - 172.26.0.9/29
    networkAddresses:
    - 172.26.0.8/29
  - gatewayAddresses:
    - 172.26.0.1/29
    networkAddresses:
    - 172.26.0.0/29

Created a IPReservation of size 2 and a SubnetPort on subnet test-2 from NSX

Created 3 SubnetPort CR on SubnetSet and observed 2 of them are created on subnet test-2 and 1 is created on subnet test.

NAME                    VIFID                                  IPADDRESS        MACADDRESS
subnetport-1            30356437-6438-4265-ad65-3365322d3465   172.26.0.11/29   04:50:56:00:44:00
subnetport-2            61623535-3033-4435-ad61-3031352d3461   172.26.0.3/29    04:50:56:00:f0:00
subnetport-3            35396239-3539-4565-ad30-3334312d3466   172.26.0.12/29   04:50:56:00:9c:00

Deleted the IPReservation on the Subnet test-2 and wait 2 minutes for the IP release.
Created another SubnetPort CR on SubnetSet and observed it created on subnet test-2.

NAME                    VIFID                                  IPADDRESS        MACADDRESS
subnetport-1            30356437-6438-4265-ad65-3365322d3465   172.26.0.11/29   04:50:56:00:44:00
subnetport-2            61623535-3033-4435-ad61-3031352d3461   172.26.0.3/29    04:50:56:00:f0:00
subnetport-3            35396239-3539-4565-ad30-3334312d3466   172.26.0.12/29   04:50:56:00:9c:00
subnetport-4            62346433-3738-4864-ad32-6162642d3430   172.26.0.13/29   04:50:56:00:70:00

DHCP Server case
Create pre-created subnetset with 2 DHCPServer Subnets

spec:
  subnetNames:
  - subnet-1
  - subnet-2
status:
  conditions:
  - lastTransitionTime: "2026-03-09T02:37:37Z"
    message: SubnetSet CR has been successfully created/updated
    reason: SubnetSetReady
    status: "True"
    type: Ready
  subnets:
  - DHCPServerAddresses:
    - 192.168.0.10/29
    gatewayAddresses:
    - 192.168.0.9/29
    networkAddresses:
    - 192.168.0.8/29
  - DHCPServerAddresses:
    - 192.168.0.18/29
    gatewayAddresses:
    - 192.168.0.17/29
    networkAddresses:
    - 192.168.0.16/29

Created 2 vms on subnet-1 from VC and 2 vms from wcp

NAME   POWER-STATE   CLASS                IMAGE                   PRIMARY-IP4    AGE
vm-1   PoweredOn     best-effort-xsmall   vmi-d46e68f4b4f0886df   192.168.0.14   12m
vm-4   PoweredOn     best-effort-xsmall   vmi-d46e68f4b4f0886df   192.168.0.13   12m

Created 1 vm on subnetset-2, observed it is created on subnet-2.

kubectl get vm -n ns-1 -o wide  
NAME   POWER-STATE   CLASS                IMAGE                   PRIMARY-IP4    AGE
vm-5   PoweredOn     best-effort-xsmall   vmi-d46e68f4b4f0886df   192.168.0.19   4m57s

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.75%. Comparing base (4ba0355) to head (876b7f9).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/nsx/services/subnetport/subnetport.go 91.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1384   +/-   ##
=======================================
  Coverage   76.74%   76.75%           
=======================================
  Files         151      151           
  Lines       21307    21313    +6     
=======================================
+ Hits        16353    16359    +6     
  Misses       3784     3784           
  Partials     1170     1170           
Flag Coverage Δ
unit-tests 76.75% <92.85%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
pkg/controllers/common/utils.go 84.40% <100.00%> (ø)
...kg/controllers/subnetport/subnetport_controller.go 68.76% <100.00%> (ø)
pkg/nsx/services/subnetport/subnetport.go 85.02% <91.66%> (-0.32%) ⬇️

... and 1 file with indirect coverage changes

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

Signed-off-by: Yanjun Zhou <yanjun.zhou@broadcom.com>
@lxiaopei
Copy link
Contributor

@yanjunz97 for SubnetSet with auto-created Subnets, we should also check the subnet ip pool since in NSX 9.2, they plan to support multiple IPs per port.

@yanjunz97
Copy link
Contributor Author

@yanjunz97 for SubnetSet with auto-created Subnets, we should also check the subnet ip pool since in NSX 9.2, they plan to support multiple IPs per port.

As currently we are not sure if dhcp server config api can reflect the correct allocated ip number, let's leave the multiple IPs issue in 9.2 and get this patch in to fix the issue with shared subnet. Thanks!

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