mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: flatten cloned images to freeup snapshot
flatten cloned images to remove the link with the snapshot as the parent snapshot can be removed from the trash. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
8ef7143e6c
commit
61a81d35e8
@ -723,7 +723,24 @@ 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)
|
||||
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())
|
||||
}
|
||||
|
||||
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())
|
||||
|
Reference in New Issue
Block a user