mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-18 04:10:22 +00:00
cleanup: re-use flattenTemporaryClonedImages to reduce duplicate code
re-use flattenTemporaryClonedImages to avoid code duplication Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
8fc9146056
commit
76c2f3c109
@ -765,24 +765,12 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
|
|||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
var snaps []snapshotInfo
|
|
||||||
// check the number of snapshots on image
|
err = flattenTemporaryClonedImages(ctx, rbdVol, cr)
|
||||||
snaps, err = rbdVol.listSnapshots(ctx, cr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var einf ErrImageNotFound
|
return nil, err
|
||||||
if errors.As(err, &einf) {
|
|
||||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
|
||||||
}
|
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
err = reserveSnap(ctx, rbdSnap, rbdVol, cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user