diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index c267e3b93..20f3a868b 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -765,24 +765,12 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS }, }, nil } - var snaps []snapshotInfo - // check the number of snapshots on image - snaps, err = rbdVol.listSnapshots(ctx, cr) + + err = flattenTemporaryClonedImages(ctx, rbdVol, cr) if err != nil { - var einf ErrImageNotFound - if errors.As(err, &einf) { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - return nil, status.Error(codes.Internal, err.Error()) + return nil, err } - if len(snaps) > int(maxSnapshotsOnImage) { - err = flattenClonedRbdImages(ctx, snaps, rbdVol.Pool, rbdVol.Monitors, cr) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - return nil, status.Errorf(codes.ResourceExhausted, "rbd image %s has %d snapshots", rbdVol, len(snaps)) - } err = reserveSnap(ctx, rbdSnap, rbdVol, cr) if err != nil { return nil, status.Error(codes.Internal, err.Error())