Move reaper under shim package

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2018-05-22 11:38:20 -04:00
parent cff5e75df8
commit 0bafe236b4
6 changed files with 11 additions and 13 deletions

View File

@ -39,7 +39,6 @@ import (
"github.com/containerd/containerd/linux/shim" "github.com/containerd/containerd/linux/shim"
shimapi "github.com/containerd/containerd/linux/shim/v1" shimapi "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/reaper"
"github.com/containerd/typeurl" "github.com/containerd/typeurl"
ptypes "github.com/gogo/protobuf/types" ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -194,7 +193,7 @@ func handleSignals(logger *logrus.Entry, signals chan os.Signal, server *ttrpc.S
case s := <-signals: case s := <-signals:
switch s { switch s {
case unix.SIGCHLD: case unix.SIGCHLD:
if err := reaper.Reap(); err != nil { if err := shim.Reap(); err != nil {
logger.WithError(err).Error("reap exit status") logger.WithError(err).Error("reap exit status")
} }
case unix.SIGTERM, unix.SIGINT: case unix.SIGTERM, unix.SIGINT:
@ -248,11 +247,11 @@ func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event
} }
cmd := exec.CommandContext(ctx, containerdBinaryFlag, "--address", l.address, "publish", "--topic", topic, "--namespace", ns) cmd := exec.CommandContext(ctx, containerdBinaryFlag, "--address", l.address, "publish", "--topic", topic, "--namespace", ns)
cmd.Stdin = bytes.NewReader(data) cmd.Stdin = bytes.NewReader(data)
c, err := reaper.Default.Start(cmd) c, err := shim.Default.Start(cmd)
if err != nil { if err != nil {
return err return err
} }
status, err := reaper.Default.Wait(cmd, c) status, err := shim.Default.Wait(cmd, c)
if err != nil { if err != nil {
return err return err
} }

View File

@ -22,7 +22,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"github.com/containerd/containerd/reaper" "github.com/containerd/containerd/linux/shim"
runc "github.com/containerd/go-runc" runc "github.com/containerd/go-runc"
"github.com/stevvooe/ttrpc" "github.com/stevvooe/ttrpc"
) )
@ -34,7 +34,7 @@ func setupSignals() (chan os.Signal, error) {
signal.Notify(signals) signal.Notify(signals)
// make sure runc is setup to use the monitor // make sure runc is setup to use the monitor
// for waiting on processes // for waiting on processes
runc.Monitor = reaper.Default runc.Monitor = shim.Default
return signals, nil return signals, nil
} }

View File

@ -20,7 +20,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"github.com/containerd/containerd/reaper" "github.com/containerd/containerd/linux/shim"
runc "github.com/containerd/go-runc" runc "github.com/containerd/go-runc"
"github.com/opencontainers/runc/libcontainer/system" "github.com/opencontainers/runc/libcontainer/system"
"github.com/stevvooe/ttrpc" "github.com/stevvooe/ttrpc"
@ -34,7 +34,7 @@ func setupSignals() (chan os.Signal, error) {
signal.Notify(signals, unix.SIGTERM, unix.SIGINT, unix.SIGCHLD, unix.SIGPIPE) signal.Notify(signals, unix.SIGTERM, unix.SIGINT, unix.SIGCHLD, unix.SIGPIPE)
// make sure runc is setup to use the monitor // make sure runc is setup to use the monitor
// for waiting on processes // for waiting on processes
runc.Monitor = reaper.Default runc.Monitor = shim.Default
// set the shim as the subreaper for all orphaned processes created by the container // set the shim as the subreaper for all orphaned processes created by the container
if err := system.SetSubreaper(1); err != nil { if err := system.SetSubreaper(1); err != nil {
return nil, err return nil, err

View File

@ -22,7 +22,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"github.com/containerd/containerd/reaper" "github.com/containerd/containerd/linux/shim"
runc "github.com/containerd/go-runc" runc "github.com/containerd/go-runc"
"github.com/stevvooe/ttrpc" "github.com/stevvooe/ttrpc"
) )
@ -34,7 +34,7 @@ func setupSignals() (chan os.Signal, error) {
signal.Notify(signals) signal.Notify(signals)
// make sure runc is setup to use the monitor // make sure runc is setup to use the monitor
// for waiting on processes // for waiting on processes
runc.Monitor = reaper.Default runc.Monitor = shim.Default
return signals, nil return signals, nil
} }

View File

@ -16,7 +16,7 @@
limitations under the License. limitations under the License.
*/ */
package reaper package shim
import ( import (
"os/exec" "os/exec"

View File

@ -34,7 +34,6 @@ import (
shimapi "github.com/containerd/containerd/linux/shim/v1" shimapi "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/reaper"
"github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime"
runc "github.com/containerd/go-runc" runc "github.com/containerd/go-runc"
"github.com/containerd/typeurl" "github.com/containerd/typeurl"
@ -81,7 +80,7 @@ func NewService(config Config, publisher events.Publisher) (*Service, error) {
context: ctx, context: ctx,
processes: make(map[string]proc.Process), processes: make(map[string]proc.Process),
events: make(chan interface{}, 128), events: make(chan interface{}, 128),
ec: reaper.Default.Subscribe(), ec: Default.Subscribe(),
} }
go s.processExits() go s.processExits()
if err := s.initPlatform(); err != nil { if err := s.initPlatform(); err != nil {