Remove process dir and entry on error
If we fail to exec a process make sure that it is cleaned up within the container's information and on disk state. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
ca6ae2e64b
commit
bd23df8fd1
1 changed files with 6 additions and 1 deletions
|
@ -164,11 +164,16 @@ func (c *container) Start(checkpoint string, s Stdio) (Process, error) {
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *container) Exec(pid string, pspec specs.ProcessSpec, s Stdio) (Process, error) {
|
func (c *container) Exec(pid string, pspec specs.ProcessSpec, s Stdio) (pp Process, err error) {
|
||||||
processRoot := filepath.Join(c.root, c.id, pid)
|
processRoot := filepath.Join(c.root, c.id, pid)
|
||||||
if err := os.Mkdir(processRoot, 0755); err != nil {
|
if err := os.Mkdir(processRoot, 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
c.RemoveProcess(pid)
|
||||||
|
}
|
||||||
|
}()
|
||||||
cmd := exec.Command("containerd-shim",
|
cmd := exec.Command("containerd-shim",
|
||||||
c.id, c.bundle, c.runtime,
|
c.id, c.bundle, c.runtime,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue