Skip to content

Commit d91f841

Browse files
crosbymichaelestesp
authored andcommitted
Increase reaper buffer size and non-blocking send
Fixes #2709 This increases the buffer size for process exit subscribers. It also implements a non-blocking send on the subscriber channel. It is better to drop an exit even than it is to block a shim for one slow subscriber. Signed-off-by: Michael Crosby <[email protected]>
1 parent a7dff7e commit d91f841

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

reaper/reaper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import (
2626
"github.com/containerd/containerd/sys"
2727
runc "github.com/containerd/go-runc"
2828
"github.com/pkg/errors"
29+
"github.com/sirupsen/logrus"
2930
)
3031

3132
// ErrNoSuchProcess is returned when the process no longer exists
3233
var ErrNoSuchProcess = errors.New("no such process")
3334

34-
const bufferSize = 32
35+
const bufferSize = 2048
3536

3637
// Reap should be called when the process receives an SIGCHLD. Reap will reap
3738
// all exited processes and close their wait channels
@@ -41,13 +42,20 @@ func Reap() error {
4142
Default.Lock()
4243
for c := range Default.subscribers {
4344
for _, e := range exits {
44-
c <- runc.Exit{
45+
select {
46+
case c <- runc.Exit{
4547
Timestamp: now,
4648
Pid: e.Pid,
4749
Status: e.Status,
50+
}:
51+
default:
52+
logrus.WithFields(logrus.Fields{
53+
"subscriber": c,
54+
"pid": e.Pid,
55+
"status": e.Status,
56+
}).Warn("failed to send exit to subscriber")
4857
}
4958
}
50-
5159
}
5260
Default.Unlock()
5361
return err

0 commit comments

Comments
 (0)