Skip to content

Check more property for pre-created subnet#1428

Open
TaoZou1 wants to merge 1 commit into
vmware-tanzu:mainfrom
TaoZou1:validatesubnetset
Open

Check more property for pre-created subnet#1428
TaoZou1 wants to merge 1 commit into
vmware-tanzu:mainfrom
TaoZou1:validatesubnetset

Conversation

@TaoZou1
Copy link
Copy Markdown
Contributor

@TaoZou1 TaoZou1 commented May 9, 2026

Verify that DHCP mode and static IP allocation are identical across all pre-created subnets in the SubnetSet.

Test Done:
create subnet1, subnet2, subnet3
subnet 1
"advanced_config" : {
"static_ip_allocation" : {
"enabled" : true
},
"connectivity_state" : "CONNECTED"
},
"subnet_dhcp_config" : {
"mode" : "DHCP_DEACTIVATED"
},
subnet 2:
"advanced_config" : {
"static_ip_allocation" : {
"enabled" : false
},
"connectivity_state" : "CONNECTED"
},
"subnet_dhcp_config" : {
"mode" : "DHCP_SERVER"
},
subnet 3:
"advanced_config" : {
"static_ip_allocation" : {
"enabled" : false
},
"connectivity_state" : "CONNECTED"
},
"subnet_dhcp_config" : {
"mode" : "DHCP_DEACTIVATED"
},

Test case 1:

  1. update the vpcnetworkconfiguration with
    subnets:
  • name: subnet2
    path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet2
    podDefault: true
  • name: subnet1
    path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet1
    podDefault: true
  1. check the pod-default subnetset:
    status:
    conditions:
  • lastTransitionTime: "2026-05-09T01:30:34Z"
    message: SubnetSet CR has been successfully created/updated
    reason: SubnetSetReady
    status: "True"
    type: Ready
  • lastTransitionTime: "2026-05-09T01:39:31Z"
    message: 'admission webhook "subnetset.validating.crd.nsx.vmware.com" denied the
    request: Subnets in SubnetSet ns2/pod-default must have the same DHCPConfigMode,
    found different DHCPConfigModes: [DHCPServer, DHCPDeactivated]'
    reason: SubnetNamesUpdateFailure

Test case 2:

  1. update the vpcnetworkconfiguration with
    subnets:
  • name: subnet3
    path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet2
    podDefault: true
  • name: subnet1
    path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet1
    podDefault: true
  1. check the pod-default subnetset:
    status:
    conditions:
  • lastTransitionTime: "2026-05-09T01:30:34Z"
    message: SubnetSet CR has been successfully created/updated
    reason: SubnetSetReady
    status: "True"
    type: Ready
  • lastTransitionTime: "2026-05-09T01:42:05Z"
    message: 'admission webhook "subnetset.validating.crd.nsx.vmware.com" denied the
    request: Subnets in SubnetSet ns2/pod-default must have the same StaticIPAllocation,
    found different StaticIPAllocations: [false, true]'
    reason: SubnetNamesUpdateFailure
    status: "True"
    type: UpdateFailed

Verify that DHCP mode and static IP allocation are identical across all
pre-created subnets in the SubnetSet.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.01%. Comparing base (73f6e84) to head (174b953).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1428      +/-   ##
==========================================
+ Coverage   76.99%   77.01%   +0.01%     
==========================================
  Files         154      154              
  Lines       21993    22010      +17     
==========================================
+ Hits        16934    16951      +17     
  Misses       3855     3855              
  Partials     1204     1204              
Flag Coverage Δ
unit-tests 77.01% <100.00%> (+0.01%) ⬆️
Files with missing lines Coverage Δ
pkg/controllers/subnetset/subnetset_webhook.go 80.00% <100.00%> (+1.63%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TaoZou1
Copy link
Copy Markdown
Contributor Author

TaoZou1 commented May 12, 2026

/e2e

3 similar comments
@TaoZou1
Copy link
Copy Markdown
Contributor Author

TaoZou1 commented May 12, 2026

/e2e

@TaoZou1
Copy link
Copy Markdown
Contributor Author

TaoZou1 commented May 14, 2026

/e2e

@TaoZou1
Copy link
Copy Markdown
Contributor Author

TaoZou1 commented May 19, 2026

/e2e

Comment thread pkg/controllers/subnetset/subnetset_webhook.go
Comment thread pkg/controllers/subnetset/subnetset_webhook.go
if firstDHCPMode != string(crdSubnet.Spec.SubnetDHCPConfig.Mode) {
return true, fmt.Errorf("Subnets in SubnetSet %s/%s must have the same DHCPConfigMode, found different DHCPConfigModes: [%s, %s]", ns, subnetSet, firstDHCPMode, crdSubnet.Spec.SubnetDHCPConfig.Mode)
}
staticIPAlloc1 := "nil"
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.

nil staticIPAllocaiton is considered as

  • true when dhcp mode is DHCPDeactivated
  • false when dhcp mode is DHCPServer or DHCPRelay

if subnetCR.Spec.AdvancedConfig.StaticIPAllocation.Enabled == nil {
subnetCR.Spec.AdvancedConfig.StaticIPAllocation.Enabled = servicecommon.Bool(!util.CRSubnetDHCPEnabled(subnetCR))
specChanged = true
}

Maybe instead of parsing it to nil string, you will need to convert it to true or false based on the logic we used in subnet?

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