diff --git a/internal/cephfs/core/clone.go b/internal/cephfs/core/clone.go index 6ec18db9481d..4d9231b445ff 100644 --- a/internal/cephfs/core/clone.go +++ b/internal/cephfs/core/clone.go @@ -28,9 +28,10 @@ import ( // cephFSCloneState describes the status of the clone. type cephFSCloneState struct { - state admin.CloneState - errno string - errorMsg string + state admin.CloneState + progressReport admin.CloneProgressReport + errno string + errorMsg string } // CephFSCloneError indicates that fetching the clone state returned an error. @@ -54,6 +55,14 @@ func (cs cephFSCloneState) ToError() error { return nil } +func (cs cephFSCloneState) GetProgressReport() admin.CloneProgressReport { + return admin.CloneProgressReport{ + PercentageCloned: cs.progressReport.PercentageCloned, + AmountCloned: cs.progressReport.AmountCloned, + FilesCloned: cs.progressReport.FilesCloned, + } +} + // CreateCloneFromSubvolume creates a clone from a subvolume. func (s *subVolumeClient) CreateCloneFromSubvolume( ctx context.Context, @@ -210,9 +219,10 @@ func (s *subVolumeClient) GetCloneState(ctx context.Context) (cephFSCloneState, } state := cephFSCloneState{ - state: cs.State, - errno: errno, - errorMsg: errStr, + state: cs.State, + progressReport: cs.ProgressReport, + errno: errno, + errorMsg: errStr, } return state, nil diff --git a/internal/cephfs/core/clone_test.go b/internal/cephfs/core/clone_test.go index 1cf9cd6c26b7..46474086acc7 100644 --- a/internal/cephfs/core/clone_test.go +++ b/internal/cephfs/core/clone_test.go @@ -28,11 +28,11 @@ import ( func TestCloneStateToError(t *testing.T) { t.Parallel() errorState := make(map[cephFSCloneState]error) - errorState[cephFSCloneState{fsa.CloneComplete, "", ""}] = nil + errorState[cephFSCloneState{fsa.CloneComplete, fsa.CloneProgressReport{}, "", ""}] = nil errorState[CephFSCloneError] = cerrors.ErrInvalidClone - errorState[cephFSCloneState{fsa.CloneInProgress, "", ""}] = cerrors.ErrCloneInProgress - errorState[cephFSCloneState{fsa.ClonePending, "", ""}] = cerrors.ErrClonePending - errorState[cephFSCloneState{fsa.CloneFailed, "", ""}] = cerrors.ErrCloneFailed + errorState[cephFSCloneState{fsa.CloneInProgress, fsa.CloneProgressReport{}, "", ""}] = cerrors.ErrCloneInProgress + errorState[cephFSCloneState{fsa.ClonePending, fsa.CloneProgressReport{}, "", ""}] = cerrors.ErrClonePending + errorState[cephFSCloneState{fsa.CloneFailed, fsa.CloneProgressReport{}, "", ""}] = cerrors.ErrCloneFailed for state, err := range errorState { require.ErrorIs(t, state.ToError(), err) diff --git a/internal/cephfs/store/fsjournal.go b/internal/cephfs/store/fsjournal.go index 3e3c676e5dfc..05a6b3342235 100644 --- a/internal/cephfs/store/fsjournal.go +++ b/internal/cephfs/store/fsjournal.go @@ -128,6 +128,14 @@ func CheckVolExists(ctx context.Context, } err = cloneState.ToError() if errors.Is(err, cerrors.ErrCloneInProgress) { + progressReport := cloneState.GetProgressReport() + log.UsefulLog(ctx, + "%s. progress report: percentage cloned=%s, amount cloned=%s, files cloned=%s", + err, + progressReport.PercentageCloned, + progressReport.AmountCloned, + progressReport.FilesCloned) + return nil, err } if errors.Is(err, cerrors.ErrClonePending) {