Skip to content

Commit

Permalink
cephfs: log clone progress
Browse files Browse the repository at this point in the history
log cephfs clone progress report during cephfs clone
operation

Signed-off-by: Nikhil-Ladha <[email protected]>
  • Loading branch information
Nikhil-Ladha committed Oct 28, 2024
1 parent 7c0aa5f commit f109d3e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
22 changes: 16 additions & 6 deletions internal/cephfs/core/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions internal/cephfs/store/fsjournal.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ 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) {
Expand Down

0 comments on commit f109d3e

Please sign in to comment.