Relax node_id length limit to 256

This commit is contained in:
Jiawei Wang 2021-04-19 12:25:11 -07:00
parent bd67aeff26
commit 125fb04dbf
3 changed files with 7 additions and 7 deletions

View File

@ -44,8 +44,8 @@ const (
maxAttachedVolumeMetadataSize = 256 * (1 << 10) // 256 kB
maxVolumeErrorMessageSize = 1024
csiNodeIDMaxLength = 128
csiNodeIDLongerMaxLength = 192
csiNodeIDMaxLength = 192
csiNodeIDLongerMaxLength = 256
)
// CSINodeValidationOptions contains the validation options for validating CSINode

View File

@ -1034,7 +1034,7 @@ func TestCSINodeValidation(t *testing.T) {
driverName2 := "1io.kubernetes-storage-2-csi-driver3"
longName := "my-a-b-c-d-c-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-ABCDEFGHIJKLMNOPQRSTUVWXYZ-driver" // 88 chars
nodeID := "nodeA"
longID := longName + longName // 176 chars
longID := longName + longName + "abcdefghijklmnopqrstuvwxyz" // 202 chars
successCases := []storage.CSINode{
{
// driver name: dot only

View File

@ -48,8 +48,8 @@ func (csiNodeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object)
func (csiNodeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
csiNode := obj.(*storage.CSINode)
// in 1.21, on create, set AllowLongNodeID=false
// in 1.22, on create, set AllowLongNodeID=true
// in 1.22, on create, set AllowLongNodeID=false
// in 1.23, on create, set AllowLongNodeID=true
validateOptions := validation.CSINodeValidationOptions{
AllowLongNodeID: false,
}
@ -74,8 +74,8 @@ func (csiNodeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Ob
func (csiNodeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newCSINodeObj := obj.(*storage.CSINode)
oldCSINodeObj := old.(*storage.CSINode)
// in 1.21 on update, set AllowLongNodeID to true only if the old object already has a long node ID
// in 1.22 on update, set AllowLongNodeID=true
// in 1.22 on update, set AllowLongNodeID to true only if the old object already has a long node ID
// in 1.23 on update, set AllowLongNodeID=true
allowLongNodeID := false
for _, nodeDriver := range oldCSINodeObj.Spec.Drivers {
if validation.CSINodeLongerID(nodeDriver.NodeID) {