847690583f
Because we are launching alot of different runc commands to do operations there is a race between doing a `cmd.Wait()` and getting the sigchld and reaping it. We can remove the sigchild reaper from containerd as long as we make sure we reap the shim process if we are the parent, i.e. not restored. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
81 lines
1.2 KiB
Go
81 lines
1.2 KiB
Go
package supervisor
|
|
|
|
import (
|
|
"os"
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/docker/containerd/runtime"
|
|
"github.com/docker/containerd/specs"
|
|
)
|
|
|
|
type testProcess struct {
|
|
id string
|
|
}
|
|
|
|
func (p *testProcess) ID() string {
|
|
return p.id
|
|
}
|
|
|
|
func (p *testProcess) CloseStdin() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *testProcess) Resize(w, h int) error {
|
|
return nil
|
|
}
|
|
|
|
func (p *testProcess) Stdio() runtime.Stdio {
|
|
return runtime.Stdio{}
|
|
}
|
|
|
|
func (p *testProcess) SystemPid() int {
|
|
return -1
|
|
}
|
|
|
|
func (p *testProcess) ExitFD() int {
|
|
return -1
|
|
}
|
|
|
|
func (p *testProcess) ExitStatus() (int, error) {
|
|
return -1, nil
|
|
}
|
|
|
|
func (p *testProcess) Container() runtime.Container {
|
|
return nil
|
|
}
|
|
|
|
func (p *testProcess) Spec() specs.ProcessSpec {
|
|
return specs.ProcessSpec{}
|
|
}
|
|
|
|
func (p *testProcess) Signal(os.Signal) error {
|
|
return nil
|
|
}
|
|
|
|
func (p *testProcess) Close() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *testProcess) State() runtime.State {
|
|
return runtime.Running
|
|
}
|
|
|
|
func (p *testProcess) Wait() {
|
|
|
|
}
|
|
|
|
func TestSortProcesses(t *testing.T) {
|
|
p := []runtime.Process{
|
|
&testProcess{"ls"},
|
|
&testProcess{"other"},
|
|
&testProcess{"init"},
|
|
&testProcess{"other2"},
|
|
}
|
|
s := &processSorter{p}
|
|
sort.Sort(s)
|
|
|
|
if id := p[len(p)-1].ID(); id != "init" {
|
|
t.Fatalf("expected init but received %q", id)
|
|
}
|
|
}
|