CSI: volume creation/registration should not validate attachment

The CSI specification requires that we validate a list of `Capability` (access
mode + accessibility) when we create volume, but the existing volume
registration workflow incorrectly validates a single capability. The
specific capability required by a volume claim is checked at the time we make
the claim, so remove the check for `AttachmentMode`/`AcccessMode`.
This commit is contained in:
Tim Gross 2021-03-24 14:06:48 -04:00
parent aec5337862
commit f149abfa41
2 changed files with 0 additions and 21 deletions

View File

@ -162,11 +162,6 @@ func TestCSIVolumeEndpoint_Register(t *testing.T) {
}
resp1 := &structs.CSIVolumeRegisterResponse{}
err := msgpackrpc.CallWithCodec(codec, "CSIVolume.Register", req1, resp1)
require.Error(t, err, "expected validation error")
// Fix the registration so that it passes validation
vols[0].AttachmentMode = structs.CSIVolumeAttachmentModeFilesystem
err = msgpackrpc.CallWithCodec(codec, "CSIVolume.Register", req1, resp1)
require.NoError(t, err)
require.NotEqual(t, uint64(0), resp1.Index)

View File

@ -590,22 +590,6 @@ func (v *CSIVolume) Validate() error {
if v.Namespace == "" {
errs = append(errs, "missing namespace")
}
if v.AccessMode == "" {
errs = append(errs, "missing access mode")
}
if v.AttachmentMode == "" {
errs = append(errs, "missing attachment mode")
}
if v.AttachmentMode == CSIVolumeAttachmentModeBlockDevice {
if v.MountOptions != nil {
if v.MountOptions.FSType != "" {
errs = append(errs, "mount options not allowed for block-device")
}
if v.MountOptions.MountFlags != nil && len(v.MountOptions.MountFlags) != 0 {
errs = append(errs, "mount options not allowed for block-device")
}
}
}
if v.SnapshotID != "" && v.CloneID != "" {
errs = append(errs, "only one of snapshot_id and clone_id is allowed")
}