From e5bb8cc0cae7ec2d4dc0d83f80f539e953266d68 Mon Sep 17 00:00:00 2001 From: Alexandr Stefurishin Date: Tue, 26 Nov 2024 22:24:11 +0300 Subject: [PATCH] validate type of snapshotted/cloned volume to be thin Signed-off-by: Alexandr Stefurishin --- images/sds-local-volume-csi/src/driver/controller.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/images/sds-local-volume-csi/src/driver/controller.go b/images/sds-local-volume-csi/src/driver/controller.go index b39fe8db..139f458c 100644 --- a/images/sds-local-volume-csi/src/driver/controller.go +++ b/images/sds-local-volume-csi/src/driver/controller.go @@ -146,6 +146,10 @@ func (d *Driver) CreateVolume(ctx context.Context, request *csi.CreateVolumeRequ return nil, status.Errorf(codes.NotFound, "error getting LVMLogicalVolume %s: %s", sourceVolume.Name, err.Error()) } + if sourceVol.Spec.Type != internal.LVMTypeThin { + return nil, status.Errorf(codes.InvalidArgument, "Source LVMLogicalVolume '%s' is not of 'Thin' type", sourceVol.Name) + } + // check size sourceSizeQty, err := resource.ParseQuantity(sourceVol.Spec.Size) if err != nil { @@ -372,6 +376,10 @@ func (d *Driver) CreateSnapshot(ctx context.Context, request *csi.CreateSnapshot return nil, status.Errorf(codes.Internal, "error getting LVMLogicalVolume %s: %s", request.SourceVolumeId, err.Error()) } + if llv.Spec.Type != internal.LVMTypeThin { + return nil, status.Errorf(codes.InvalidArgument, "Source LVMLogicalVolume '%s' is not of 'Thin' type", request.SourceVolumeId) + } + // the snapshots are required to be created in the same node and device class as the source volume. // suggested name is in form "snapshot-{uuid}" and it can't be used, because