rbd: add support for flattenMode option for replication

This commit adds support for flattenMode option
for replication.
If the flattenMode is set to "force" in
volumereplicationclass parameters, cephcsi will
add a task to flatten the image if it has parent.
This enable cephcsi to then mirror such images after
flattening them.
The error message when the image's parent is
in trash or unmirrored is improved as well.

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R
2024-06-06 17:14:08 +05:30
committed by mergify[bot]
parent f8fbf2e95a
commit d166229d8f
5 changed files with 187 additions and 13 deletions

View File

@ -1020,21 +1020,11 @@ func cleanupRBDImage(ctx context.Context,
// delete the temporary rbd image created as part of volume clone during
// create volume
tempClone := rbdVol.generateTempClone()
err = tempClone.deleteImage(ctx)
err = rbdVol.DeleteTempImage(ctx)
if err != nil {
if errors.Is(err, ErrImageNotFound) {
err = tempClone.ensureImageCleanup(ctx)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
} else {
// return error if it is not ErrImageNotFound
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v",
tempClone, err)
log.ErrorLog(ctx, "failed to delete temporary rbd image: %v", err)
return nil, status.Error(codes.Internal, err.Error())
}
return nil, status.Error(codes.Internal, err.Error())
}
// Deleting rbd image