Skip to content

Commit

Permalink
handle comm errors in script runner (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
hopkiw authored Oct 19, 2021
1 parent 2b3561a commit a1c10d1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion google_metadata_script_runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,20 @@ func runCmd(c *exec.Cmd, name string) error {
pw.Close()

in := bufio.NewScanner(pr)
for in.Scan() {
for {
if !in.Scan() {
if err := in.Err(); err != nil {
logger.Errorf("error while communicating with %q script: %v", name, err)
}
break
}
logger.Log(logger.LogEntry{
Message: fmt.Sprintf("%s: %s", name, in.Text()),
CallDepth: 3,
Severity: logger.Info,
})
}
pr.Close()

return c.Wait()
}
Expand Down

0 comments on commit a1c10d1

Please sign in to comment.