Skip to content

Commit ab1b459

Browse files
authored
[fix] Report the unit in a single scan job (#4209)
* [fix] Report the unit in a single scan job * Eliminate divide by 0 possibility
1 parent 8b6aac3 commit ab1b459

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pkg/sources/job_progress.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ func (m JobProgressMetrics) PercentComplete() int {
355355
// Fallback to the source's self-reported percent complete if
356356
// the unit information isn't available.
357357
return int(m.SourcePercent)
358+
} else if den == 0 {
359+
// This should never happen. Return an invalid value so we can
360+
// trace it back to here if we ever see it.
361+
return -1
358362
}
359363
return int(num * 100 / den)
360364
}

pkg/sources/source_manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ func (s *SourceManager) scan(ctx context.Context, source Source, report *JobProg
417417
}
418418
}()
419419

420+
report.ReportUnit(unit)
420421
report.TrackProgress(source.GetProgress())
421422
if ctx.Value("job_id") == "" {
422423
ctx = context.WithValue(ctx, "job_id", report.JobID)

0 commit comments

Comments
 (0)