Signed-off-by: Dan Walsh <dwalsh@redhat.com>
| ... | ... |
@@ -132,6 +132,7 @@ type execOutput struct {
|
| 132 | 132 |
// Run implements the exec driver Driver interface, |
| 133 | 133 |
// it calls libcontainer APIs to run a container. |
| 134 | 134 |
func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execdriver.Hooks) (execdriver.ExitStatus, error) {
|
| 135 |
+ destroyed := false |
|
| 135 | 136 |
// take the Command and populate the libcontainer.Config from it |
| 136 | 137 |
container, err := d.createContainer(c, hooks) |
| 137 | 138 |
if err != nil {
|
| ... | ... |
@@ -157,7 +158,9 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd |
| 157 | 157 |
d.activeContainers[c.ID] = cont |
| 158 | 158 |
d.Unlock() |
| 159 | 159 |
defer func() {
|
| 160 |
- cont.Destroy() |
|
| 160 |
+ if !destroyed {
|
|
| 161 |
+ cont.Destroy() |
|
| 162 |
+ } |
|
| 161 | 163 |
d.cleanContainer(c.ID) |
| 162 | 164 |
}() |
| 163 | 165 |
|
| ... | ... |
@@ -191,6 +194,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd |
| 191 | 191 |
ps = execErr.ProcessState |
| 192 | 192 |
} |
| 193 | 193 |
cont.Destroy() |
| 194 |
+ destroyed = true |
|
| 194 | 195 |
_, oomKill := <-oom |
| 195 | 196 |
return execdriver.ExitStatus{ExitCode: utils.ExitStatus(ps.Sys().(syscall.WaitStatus)), OOMKilled: oomKill}, nil
|
| 196 | 197 |
} |