client/status: notify user if size estimation is imprecise

There's plenty of room for improvement here.
For example, detect if we're past the last step without size estimation
and compute the remaining sum of bytes to be replicated from there on.
This commit is contained in:
Christian Schwarz 2020-01-01 15:45:55 +01:00
parent f8200a6386
commit 9a4763ceee
2 changed files with 22 additions and 7 deletions

View File

@ -461,7 +461,7 @@ func (t *tui) renderReplicationReport(rep *report.Report, history *bytesProgress
if latest.State != report.AttemptPlanning && latest.State != report.AttemptPlanningError { if latest.State != report.AttemptPlanning && latest.State != report.AttemptPlanningError {
// Draw global progress bar // Draw global progress bar
// Progress: [---------------] // Progress: [---------------]
expected, replicated := latest.BytesSum() expected, replicated, containsInvalidSizeEstimates := latest.BytesSum()
rate, changeCount := history.Update(replicated) rate, changeCount := history.Update(replicated)
eta := time.Duration(0) eta := time.Duration(0)
if rate > 0 { if rate > 0 {
@ -474,6 +474,10 @@ func (t *tui) renderReplicationReport(rep *report.Report, history *bytesProgress
t.write(fmt.Sprintf(" (%s remaining)", humanizeDuration(eta))) t.write(fmt.Sprintf(" (%s remaining)", humanizeDuration(eta)))
} }
t.newline() t.newline()
if containsInvalidSizeEstimates {
t.write("NOTE: not all steps could be size-estimated, total estimate is likely imprecise!")
t.newline()
}
var maxFSLen int var maxFSLen int
for _, fs := range latest.Filesystems { for _, fs := range latest.Filesystems {
@ -714,11 +718,20 @@ func (t *tui) drawBar(length int, bytes, totalBytes int64, changeCount int) {
func (t *tui) printFilesystemStatus(rep *report.FilesystemReport, active bool, maxFS int) { func (t *tui) printFilesystemStatus(rep *report.FilesystemReport, active bool, maxFS int) {
expected, replicated := rep.BytesSum() expected, replicated, containsInvalidSizeEstimates := rep.BytesSum()
status := fmt.Sprintf("%s (step %d/%d, %s/%s)", sizeEstimationImpreciseNotice := ""
if containsInvalidSizeEstimates {
sizeEstimationImpreciseNotice = " (some steps lack size estimation)"
}
if rep.CurrentStep < len(rep.Steps) && rep.Steps[rep.CurrentStep].Info.BytesExpected == 0 {
sizeEstimationImpreciseNotice = " (step lacks size estimation)"
}
status := fmt.Sprintf("%s (step %d/%d, %s/%s)%s",
strings.ToUpper(string(rep.State)), strings.ToUpper(string(rep.State)),
rep.CurrentStep, len(rep.Steps), rep.CurrentStep, len(rep.Steps),
ByteCountBinary(replicated), ByteCountBinary(expected), ByteCountBinary(replicated), ByteCountBinary(expected),
sizeEstimationImpreciseNotice,
) )
activeIndicator := " " activeIndicator := " "

View File

@ -91,19 +91,21 @@ type StepInfo struct {
BytesReplicated int64 BytesReplicated int64
} }
func (a *AttemptReport) BytesSum() (expected, replicated int64) { func (a *AttemptReport) BytesSum() (expected, replicated int64, containsInvalidSizeEstimates bool) {
for _, fs := range a.Filesystems { for _, fs := range a.Filesystems {
e, r := fs.BytesSum() e, r, fsContainsInvalidEstimate := fs.BytesSum()
containsInvalidSizeEstimates = containsInvalidSizeEstimates || fsContainsInvalidEstimate
expected += e expected += e
replicated += r replicated += r
} }
return expected, replicated return expected, replicated, containsInvalidSizeEstimates
} }
func (f *FilesystemReport) BytesSum() (expected, replicated int64) { func (f *FilesystemReport) BytesSum() (expected, replicated int64, containsInvalidSizeEstimates bool) {
for _, step := range f.Steps { for _, step := range f.Steps {
expected += step.Info.BytesExpected expected += step.Info.BytesExpected
replicated += step.Info.BytesReplicated replicated += step.Info.BytesReplicated
containsInvalidSizeEstimates = containsInvalidSizeEstimates || step.Info.BytesExpected == 0
} }
return return
} }