Support immutable fields check for Subnet/Subnetset #627
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.
This patch is to:
For Subnet CR, if there is already a nsx subnet created for the CR, The following fields are immutable:
IPv4SubnetSize/AccessMode/IPAddresses/DHCPConfig
For Subnetset CR, if there is already a nsx subnet allocated from Subnetset There are two cases:
1). For VM Subnetset
The following fields are immutable:
IPv4SubnetSize/AccessMode/DHCPConfig
2). For POD Subnetset
The following fields are immutable:
IPv4SubnetSize/DHCPConfig
Fix the bug that the nsx subnet IPv4SubnetSize is not set by user-defined CR, either from subnet CR or subnetset CR.The current value of IPv4SubnetSize is set by vpcnetworkconfiguration.
The test done:
Create a Subnet CR, and check nsx vpc subnet is created,
Try to change IPv4SubnetSize/AccessMode/IPAddresses/DHCPConfig in the Subnet CR
The modification fails because these fields are immutable.
Create a Subnet CR with invalid AccessMode value, in this case, there is no valid nsx VPC subnet created.
The user can still modify Subnet CR AccessMode until nsx VPC subnet created. Thereafter, AccessMode is unable
to changed any more.
Create a SubnetSet CR, and create a subnetport CR to use this SubnetSet CR. There is a corresponding nsx VPC subnet created for the subnetport.
Try to change IPv4SubnetSize/AccessMode/DHCPConfig in the Subnetset CR,
The modification failed because these fields are immutable.
Create a SubnetSet CR, and there is no any subnetport using this Subnetset CR.
The user can still modify SubnetSet CR until there is subnet allocated.
And then IPv4SubnetSize/AccessMode/DHCPConfig become immutable.
Modify the IPv4SubnetSize/AccessMode/DHCPConfig for the default VM SubnetSet in the namespace,
The modification can succeed when there is no any Subnet allocated from SubnetSet.
Create a subnetport to specify using default VM SubnetSet in the namespace.
The modification to IPv4SubnetSize/AccessMode/DHCPConfig fails because these fields become immutable.