Check more property for pre-created subnet#1428
Open
TaoZou1 wants to merge 1 commit into
Open
Conversation
Verify that DHCP mode and static IP allocation are identical across all pre-created subnets in the SubnetSet.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
Contributor
Author
|
/e2e |
3 similar comments
Contributor
Author
|
/e2e |
Contributor
Author
|
/e2e |
Contributor
Author
|
/e2e |
yanjunz97
reviewed
May 19, 2026
| 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" |
Contributor
There was a problem hiding this comment.
nil staticIPAllocaiton is considered as
- true when dhcp mode is DHCPDeactivated
- false when dhcp mode is DHCPServer or DHCPRelay
nsx-operator/pkg/controllers/subnet/subnet_controller.go
Lines 172 to 175 in ff79596
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
subnets:
path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet2
podDefault: true
path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet1
podDefault: true
status:
conditions:
message: SubnetSet CR has been successfully created/updated
reason: SubnetSetReady
status: "True"
type: Ready
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:
subnets:
path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet2
podDefault: true
path: /orgs/default/projects/project-quality/vpcs/test1/subnets/subnet1
podDefault: true
status:
conditions:
message: SubnetSet CR has been successfully created/updated
reason: SubnetSetReady
status: "True"
type: Ready
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