Skip to content

Commit

Permalink
Don't reuse exec.Cmd (open-telemetry#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek authored May 18, 2021
1 parent 5b5d3fb commit d8500e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ func GetModules(cfg Config) error {
}

cfg.Logger.Info("Getting go modules")
cmd := exec.Command(goBinary, "mod", "download")
cmd.Dir = cfg.Distribution.OutputPath

// basic retry if error from go mod command (in case of transient network error). This could be improved
// retry 3 times with 5 second spacing interval
retries := 3
failReason := "unknown"
for i := 1; i <= retries; i++ {
cmd := exec.Command(goBinary, "mod", "download")
cmd.Dir = cfg.Distribution.OutputPath
if out, err := cmd.CombinedOutput(); err != nil {
failReason = fmt.Sprintf("%s. Output: %q", err, out)
cfg.Logger.Info("Failed modules download", "retry", fmt.Sprintf("%d/%d", i, retries))
Expand Down

0 comments on commit d8500e6

Please sign in to comment.