cephfs: report detailed error message on clone failure

go-ceph provides a new GetFailure() method to retrieve details errors
when cloning failed. This is now included in the `cephFSCloneState`
struct, which was a simple string before.

While modifying the `cephFSCloneState` struct, the constants have been
removed, as go-ceph provides them as well.

Fixes: #3140
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2022-06-21 13:49:13 +02:00
committed by mergify[bot]
parent 5c40f1ef33
commit a1ed6207f6
3 changed files with 59 additions and 41 deletions

View File

@ -119,15 +119,17 @@ func CheckVolExists(ctx context.Context,
return nil, err
}
if cloneState == core.CephFSCloneInprogress {
return nil, cerrors.ErrCloneInProgress
err = cloneState.ToError()
if errors.Is(err, cerrors.ErrCloneInProgress) {
return nil, err
}
if cloneState == core.CephFSClonePending {
return nil, cerrors.ErrClonePending
if errors.Is(err, cerrors.ErrClonePending) {
return nil, err
}
if cloneState == core.CephFSCloneFailed {
if errors.Is(err, cerrors.ErrCloneFailed) {
log.ErrorLog(ctx,
"clone failed, deleting subvolume clone. vol=%s, subvol=%s subvolgroup=%s",
"clone failed (%v), deleting subvolume clone. vol=%s, subvol=%s subvolgroup=%s",
err,
volOptions.FsName,
vid.FsSubvolName,
volOptions.SubvolumeGroup)
@ -149,8 +151,8 @@ func CheckVolExists(ctx context.Context,
return nil, err
}
if cloneState != core.CephFSCloneComplete {
return nil, fmt.Errorf("clone is not in complete state for %s", vid.FsSubvolName)
if err != nil {
return nil, fmt.Errorf("clone is not in complete state for %s: %w", vid.FsSubvolName, err)
}
}