Skip to content
Snippets Groups Projects
Commit 37c77340 authored by kaiyou's avatar kaiyou
Browse files

Reap zombie processes

parent 5b740eb3
No related branches found
No related tags found
No related merge requests found
Pipeline #28593 passed
......@@ -38,7 +38,7 @@ import (
var kubeKubelet = &Unit{
Name: "kubelet",
Dependencies: []*Unit{masterDiscovery, containerdGRPC, containerdTTRPC, pkiCA, pkiNode, kubeLogger},
Dependencies: []*Unit{masterDiscovery, containerdGRPC, containerdTTRPC, pkiCA, pkiNode, kubeLogger, reaper},
Run: func(u *Unit, c *Cluster, ctx context.Context) error {
// Sleep before starting, to make sure that containerd is actually ready
// (very difficult to check otherwise)
......
package services
import (
"context"
"os"
"os/signal"
"time"
"golang.org/x/sys/unix"
)
var reaper = &Unit{
Name: "reaper",
Run: func(u *Unit, c *Cluster, ctx context.Context) error {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, unix.SIGCHLD)
u.Markready()
for {
<-sigs
// Sleep before reaping, to avoid racing with native waitpid
// any delay will do, since we merely try to avoid accumulating defuncts
time.Sleep(60 * time.Second)
for {
var status unix.WaitStatus
_, err := unix.Wait4(-1, &status, unix.WNOHANG, nil)
if err != nil {
break
}
}
}
},
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment