X Tutup
Skip to content

Commit 4cc882c

Browse files
authored
Merge pull request containerd#1996 from crosbymichael/bp-reaper
[release 1.0] Remove reaper from containerd daemon
2 parents 8cfebc0 + 4acee3f commit 4cc882c

File tree

6 files changed

+6
-39
lines changed

6 files changed

+6
-39
lines changed

cmd/containerd/config_linux.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ func defaultConfig() *server.Config {
1212
GRPC: server.GRPCConfig{
1313
Address: defaults.DefaultAddress,
1414
},
15-
NoSubreaper: false,
1615
Debug: server.Debug{
1716
Level: "info",
1817
Address: defaults.DefaultDebugAddress,

cmd/containerd/main_unix.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"golang.org/x/sys/unix"
1212

1313
"github.com/containerd/containerd/log"
14-
"github.com/containerd/containerd/reaper"
1514
"github.com/containerd/containerd/server"
1615
)
1716

@@ -21,7 +20,6 @@ var handledSignals = []os.Signal{
2120
unix.SIGTERM,
2221
unix.SIGINT,
2322
unix.SIGUSR1,
24-
unix.SIGCHLD,
2523
unix.SIGPIPE,
2624
}
2725

@@ -36,10 +34,6 @@ func handleSignals(ctx context.Context, signals chan os.Signal, serverC chan *se
3634
case s := <-signals:
3735
log.G(ctx).WithField("signal", s).Debug("received signal")
3836
switch s {
39-
case unix.SIGCHLD:
40-
if err := reaper.Reap(); err != nil {
41-
log.G(ctx).WithError(err).Error("reap containerd processes")
42-
}
4337
case unix.SIGUSR1:
4438
dumpStacks()
4539
case unix.SIGPIPE:

linux/runtime.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import (
2626
"github.com/containerd/containerd/namespaces"
2727
"github.com/containerd/containerd/platforms"
2828
"github.com/containerd/containerd/plugin"
29-
"github.com/containerd/containerd/reaper"
3029
"github.com/containerd/containerd/runtime"
31-
"github.com/containerd/containerd/sys"
3230
runc "github.com/containerd/go-runc"
3331
"github.com/containerd/typeurl"
3432
ptypes "github.com/gogo/protobuf/types"
@@ -159,9 +157,6 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
159157
return nil, err
160158
}
161159

162-
ec := reaper.Default.Subscribe()
163-
defer reaper.Default.Unsubscribe(ec)
164-
165160
bundle, err := newBundle(id,
166161
filepath.Join(r.state, namespace),
167162
filepath.Join(r.root, namespace),
@@ -206,7 +201,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
206201
"id": id,
207202
"namespace": namespace,
208203
}).Warn("cleaning up after killed shim")
209-
err = r.cleanupAfterDeadShim(context.Background(), bundle, namespace, id, lc.pid, ec)
204+
err = r.cleanupAfterDeadShim(context.Background(), bundle, namespace, id, lc.pid)
210205
if err == nil {
211206
r.tasks.Delete(ctx, lc)
212207
} else {
@@ -313,7 +308,7 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
313308

314309
rsp, err := lc.shim.Delete(ctx, empty)
315310
if err != nil {
316-
if cerr := r.cleanupAfterDeadShim(ctx, bundle, namespace, c.ID(), lc.pid, nil); cerr != nil {
311+
if cerr := r.cleanupAfterDeadShim(ctx, bundle, namespace, c.ID(), lc.pid); cerr != nil {
317312
log.G(ctx).WithError(err).Error("unable to cleanup task")
318313
}
319314
return nil, errdefs.FromGRPC(err)
@@ -394,7 +389,7 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
394389
"id": id,
395390
"namespace": ns,
396391
}).Error("connecting to shim")
397-
err := r.cleanupAfterDeadShim(ctx, bundle, ns, id, pid, nil)
392+
err := r.cleanupAfterDeadShim(ctx, bundle, ns, id, pid)
398393
if err != nil {
399394
log.G(ctx).WithError(err).WithField("bundle", bundle.path).
400395
Error("cleaning up after dead shim")
@@ -419,7 +414,7 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
419414
return o, nil
420415
}
421416

422-
func (r *Runtime) cleanupAfterDeadShim(ctx context.Context, bundle *bundle, ns, id string, pid int, ec chan runc.Exit) error {
417+
func (r *Runtime) cleanupAfterDeadShim(ctx context.Context, bundle *bundle, ns, id string, pid int) error {
423418
ctx = namespaces.WithNamespace(ctx, ns)
424419
if err := r.terminate(ctx, bundle, ns, id); err != nil {
425420
if r.config.ShimDebug {
@@ -428,17 +423,6 @@ func (r *Runtime) cleanupAfterDeadShim(ctx context.Context, bundle *bundle, ns,
428423
log.G(ctx).WithError(err).Warn("failed to terminate task")
429424
}
430425

431-
if ec != nil {
432-
// if sub-reaper is set, reap our new child
433-
if v, err := sys.GetSubreaper(); err == nil && v == 1 {
434-
for e := range ec {
435-
if e.Pid == pid {
436-
break
437-
}
438-
}
439-
}
440-
}
441-
442426
// Notify Client
443427
exitedAt := time.Now().UTC()
444428
r.events.Publish(ctx, runtime.TaskExitEventTopic, &eventstypes.TaskExit{

linux/shim/client/client.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/containerd/containerd/linux/shim"
2424
shimapi "github.com/containerd/containerd/linux/shim/v1"
2525
"github.com/containerd/containerd/log"
26-
"github.com/containerd/containerd/reaper"
2726
"github.com/containerd/containerd/sys"
2827
ptypes "github.com/gogo/protobuf/types"
2928
)
@@ -48,8 +47,7 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
4847
defer f.Close()
4948

5049
cmd := newCommand(binary, daemonAddress, debug, config, f)
51-
ec, err := reaper.Default.Start(cmd)
52-
if err != nil {
50+
if err := cmd.Start(); err != nil {
5351
return nil, nil, errors.Wrapf(err, "failed to start shim")
5452
}
5553
defer func() {
@@ -58,7 +56,7 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
5856
}
5957
}()
6058
go func() {
61-
reaper.Default.Wait(cmd, ec)
59+
cmd.Wait()
6260
exitHandler()
6361
}()
6462
log.G(ctx).WithFields(logrus.Fields{

server/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ type Config struct {
2323
Metrics MetricsConfig `toml:"metrics"`
2424
// Plugins provides plugin specific configuration for the initialization of a plugin
2525
Plugins map[string]toml.Primitive `toml:"plugins"`
26-
// NoSubreaper disables containerd as a subreaper
27-
NoSubreaper bool `toml:"no_subreaper"`
2826
// OOMScore adjust the containerd's oom score
2927
OOMScore int `toml:"oom_score"`
3028
// Cgroup specifies cgroup information for the containerd daemon process

server/server_linux.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ import (
1212

1313
// apply sets config settings on the server process
1414
func apply(ctx context.Context, config *Config) error {
15-
if !config.NoSubreaper {
16-
log.G(ctx).Info("setting subreaper...")
17-
if err := sys.SetSubreaper(1); err != nil {
18-
return err
19-
}
20-
}
2115
if config.OOMScore != 0 {
2216
log.G(ctx).Debugf("changing OOM score to %d", config.OOMScore)
2317
if err := sys.SetOOMScore(os.Getpid(), config.OOMScore); err != nil {

0 commit comments

Comments
 (0)
X Tutup