Call Finish in SourceManager after the semaphore is released (#2121)

This commit is contained in:
Miccah 2023-11-24 13:22:08 -08:00 committed by GitHub
parent 024aa056b9
commit 78219a27b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,6 +123,8 @@ func (s *SourceManager) asyncRun(ctx context.Context, sourceName string, source
}
s.wg.Add(1)
go func() {
// Call Finish after the semaphore has been released.
defer progress.Finish()
defer s.sem.Release(1)
defer s.wg.Done()
ctx := context.WithValues(ctx,
@ -216,7 +218,6 @@ func (s *SourceManager) preflightChecks(ctx context.Context) error {
// acquired resources. An error is returned if there was a fatal error during
// the run. This information is also recorded in the JobProgress.
func (s *SourceManager) run(ctx context.Context, source Source, report *JobProgress) error {
defer report.Finish()
report.Start(time.Now())
defer func() { report.End(time.Now()) }()