Browse Source

Merge pull request #17180 from rhatdan/destroy

Docker is calling cont.Destroy twice on success
Brian Goff 9 years ago
parent
commit
5087e8c2e8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      daemon/execdriver/native/driver.go

+ 5 - 1
daemon/execdriver/native/driver.go

@@ -132,6 +132,7 @@ type execOutput struct {
 // Run implements the exec driver Driver interface,
 // Run implements the exec driver Driver interface,
 // it calls libcontainer APIs to run a container.
 // it calls libcontainer APIs to run a container.
 func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execdriver.Hooks) (execdriver.ExitStatus, error) {
 func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execdriver.Hooks) (execdriver.ExitStatus, error) {
+	destroyed := false
 	// take the Command and populate the libcontainer.Config from it
 	// take the Command and populate the libcontainer.Config from it
 	container, err := d.createContainer(c, hooks)
 	container, err := d.createContainer(c, hooks)
 	if err != nil {
 	if err != nil {
@@ -157,7 +158,9 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
 	d.activeContainers[c.ID] = cont
 	d.activeContainers[c.ID] = cont
 	d.Unlock()
 	d.Unlock()
 	defer func() {
 	defer func() {
-		cont.Destroy()
+		if !destroyed {
+			cont.Destroy()
+		}
 		d.cleanContainer(c.ID)
 		d.cleanContainer(c.ID)
 	}()
 	}()
 
 
@@ -191,6 +194,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
 		ps = execErr.ProcessState
 		ps = execErr.ProcessState
 	}
 	}
 	cont.Destroy()
 	cont.Destroy()
+	destroyed = true
 	_, oomKill := <-oom
 	_, oomKill := <-oom
 	return execdriver.ExitStatus{ExitCode: utils.ExitStatus(ps.Sys().(syscall.WaitStatus)), OOMKilled: oomKill}, nil
 	return execdriver.ExitStatus{ExitCode: utils.ExitStatus(ps.Sys().(syscall.WaitStatus)), OOMKilled: oomKill}, nil
 }
 }