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:
parent
aec5337862
commit
f149abfa41
|
@ -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)
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue