From 3ac6bbd87cb745b064cfcf602d0f56aab21ac3c5 Mon Sep 17 00:00:00 2001 From: Yug Date: Mon, 9 Nov 2020 11:31:38 +0530 Subject: [PATCH] cephfs: Add isCloneRetryError function The function isCloneRetryError verifies if the clone error is `pending` or `in-progress` error. Co-authored-by: Madhu Rajanna Signed-off-by: Yug --- internal/cephfs/clone.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/cephfs/clone.go b/internal/cephfs/clone.go index 24b347e4b..9ab9297a3 100644 --- a/internal/cephfs/clone.go +++ b/internal/cephfs/clone.go @@ -155,6 +155,12 @@ func cleanupCloneFromSubvolumeSnapshot(ctx context.Context, volID, cloneID volum return nil } +// isCloneRetryError returns true if the clone error is pending,in-progress +// error. +func isCloneRetryError(err error) bool { + return errors.Is(err, ErrCloneInProgress) || errors.Is(err, ErrClonePending) +} + func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volumeOptions, vID *volumeIdentifier, sID *snapshotIdentifier, cr *util.Credentials) error { snapID := volumeID(sID.FsSnapshotName) err := cloneSnapshot(ctx, parentVolOpt, cr, volumeID(sID.FsSubvolName), snapID, volumeID(vID.FsSubvolName), volOptions)