Implement reaper with runc support in shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
df48983fe7
commit
9f3240364f
3 changed files with 9 additions and 5 deletions
|
@ -11,11 +11,12 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
runc "github.com/crosbymichael/go-runc"
|
||||
"github.com/docker/containerd"
|
||||
shimapi "github.com/docker/containerd/api/services/shim"
|
||||
"github.com/docker/containerd/linux/shim"
|
||||
"github.com/docker/containerd/reaper"
|
||||
"github.com/docker/containerd/sys"
|
||||
"github.com/docker/containerd/utils"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -78,6 +79,9 @@ func main() {
|
|||
func setupSignals() (chan os.Signal, error) {
|
||||
signals := make(chan os.Signal, 2048)
|
||||
signal.Notify(signals)
|
||||
// make sure runc is setup to use the monitor
|
||||
// for waiting on processes
|
||||
runc.Monitor = reaper.Default
|
||||
// set the shim as the subreaper for all orphaned processes created by the container
|
||||
if err := sys.SetSubreaper(1); err != nil {
|
||||
return nil, err
|
||||
|
@ -108,7 +112,7 @@ func handleSignals(signals chan os.Signal, server *grpc.Server, service *shim.Se
|
|||
logrus.WithField("signal", s).Debug("received signal")
|
||||
switch s {
|
||||
case syscall.SIGCHLD:
|
||||
exits, err := utils.Reap(false)
|
||||
exits, err := reaper.Reap()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("reap exit status")
|
||||
}
|
||||
|
|
|
@ -365,7 +365,7 @@ func handleSignals(signals chan os.Signal, server *grpc.Server) error {
|
|||
log.G(global).WithField("signal", s).Debug("received signal")
|
||||
switch s {
|
||||
case syscall.SIGCHLD:
|
||||
if err := reaper.Reap(); err != nil {
|
||||
if _, err := reaper.Reap(); err != nil {
|
||||
log.G(global).WithError(err).Error("reap containerd processes")
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// Reap should be called when the process receives an SIGCHLD. Reap will reap
|
||||
// all exited processes and close their wait channels
|
||||
func Reap() error {
|
||||
func Reap() ([]utils.Exit, error) {
|
||||
exits, err := utils.Reap(false)
|
||||
for _, e := range exits {
|
||||
Default.mu.Lock()
|
||||
|
@ -28,7 +28,7 @@ func Reap() error {
|
|||
delete(Default.cmds, e.Pid)
|
||||
Default.mu.Unlock()
|
||||
}
|
||||
return err
|
||||
return exits, err
|
||||
}
|
||||
|
||||
var Default = &Monitor{
|
||||
|
|
Loading…
Reference in a new issue