Merge pull request #5429 from hashicorp/b-blocking-executor-shutdown

executor: block shutdown on process exiting
This commit is contained in:
Nick Ethier
2019-03-19 15:18:01 -04:00
committed by GitHub
3 changed files with 52 additions and 2 deletions

View File

@@ -349,10 +349,21 @@ func (l *LibcontainerExecutor) Shutdown(signal string, grace time.Duration) erro
case <-time.After(grace):
// Force kill all container processes after grace period,
// hence `true` argument.
return l.container.Signal(os.Kill, true)
if err := l.container.Signal(os.Kill, true); err != nil {
return err
}
}
} else {
return l.container.Signal(os.Kill, true)
if err := l.container.Signal(os.Kill, true); err != nil {
return err
}
}
select {
case <-l.userProcExited:
return nil
case <-time.After(time.Second * 15):
return fmt.Errorf("process failed to exit after 15 seconds")
}
}