15954: Fix error reporting during shutdown.
authorTom Clegg <tom@tomclegg.ca>
Mon, 24 Feb 2020 20:26:15 +0000 (15:26 -0500)
committerTom Clegg <tom@tomclegg.ca>
Mon, 24 Feb 2020 20:30:07 +0000 (15:30 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/boot/cmd.go

index bf78c42d703fcd40bebe83f3a09a570f73c662da..62088a604d37bb875b5e906e2dd3e0032c927045 100644 (file)
@@ -528,8 +528,12 @@ func (boot *Booter) RunProgram(ctx context.Context, dir string, output io.Writer
                return err
        }
        err = cmd.Wait()
-       if err != nil && ctx.Err() == nil {
-               // Only report errors that happen before the context ends.
+       if ctx.Err() != nil {
+               // Return "context canceled", instead of the "killed"
+               // error that was probably caused by the context being
+               // canceled.
+               return ctx.Err()
+       } else if err != nil {
                return fmt.Errorf("%s: error: %v", cmdline, err)
        }
        return nil