Skip to content

Commit

Permalink
validate type of snapshotted/cloned volume to be thin
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Stefurishin <alexandr.stefurishin@flant.com>
  • Loading branch information
Alexandr Stefurishin committed Nov 26, 2024
1 parent 97536b3 commit e5bb8cc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions images/sds-local-volume-csi/src/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e5bb8cc

Please sign in to comment.