Skip to content

Commit

Permalink
block on send to finish goroutine
Browse files Browse the repository at this point in the history
Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>
  • Loading branch information
Adnan Abdulhussein committed Sep 10, 2019
1 parent efd166e commit 5d15598
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions pkg/restic/exec_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ func RunRestore(restoreCmd *Command, log logrus.FieldLogger, updateFunc func(vel
// create a channel to signal when to end the goroutine scanning for progress
// updates
quit := make(chan struct{})
var wg sync.WaitGroup

wg.Add(1)
go func() {
ticker := time.NewTicker(restoreProgressCheckInterval)
for {
Expand All @@ -211,15 +209,13 @@ func RunRestore(restoreCmd *Command, log logrus.FieldLogger, updateFunc func(vel
})
case <-quit:
ticker.Stop()
wg.Done()
return
}
}
}()

stdout, stderr, err := exec.RunCommand(restoreCmd.Cmd())
close(quit)
wg.Wait()
quit <- struct{}{}

// update progress to 100%
updateFunc(velerov1api.PodVolumeOperationProgress{
Expand Down

0 comments on commit 5d15598

Please sign in to comment.