2015-10-20 16:36:09 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2015-12-04 15:34:43 -05:00
|
|
|
"github.com/docker/docker/api/types"
|
2015-12-18 13:36:17 -05:00
|
|
|
containertypes "github.com/docker/docker/api/types/container"
|
2015-11-12 14:55:17 -05:00
|
|
|
"github.com/docker/docker/container"
|
2015-10-20 16:36:09 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestContainerDoubleDelete(t *testing.T) {
|
|
|
|
tmp, err := ioutil.TempDir("", "docker-daemon-unix-test-")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(tmp)
|
|
|
|
daemon := &Daemon{
|
|
|
|
repository: tmp,
|
|
|
|
root: tmp,
|
|
|
|
}
|
2015-11-12 14:55:17 -05:00
|
|
|
daemon.containers = &contStore{s: make(map[string]*container.Container)}
|
2015-10-20 16:36:09 -04:00
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
container := &container.Container{
|
|
|
|
CommonContainer: container.CommonContainer{
|
2015-12-01 12:54:26 -05:00
|
|
|
ID: "test",
|
2015-11-12 14:55:17 -05:00
|
|
|
State: container.NewState(),
|
2015-12-18 13:36:17 -05:00
|
|
|
Config: &containertypes.Config{},
|
2015-10-20 16:36:09 -04:00
|
|
|
},
|
|
|
|
}
|
2015-12-01 12:54:26 -05:00
|
|
|
daemon.containers.Add(container.ID, container)
|
2015-10-20 16:36:09 -04:00
|
|
|
|
|
|
|
// Mark the container as having a delete in progress
|
2015-11-12 14:55:17 -05:00
|
|
|
if err := container.SetRemovalInProgress(); err != nil {
|
2015-10-20 16:36:09 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to remove the container when it's start is removalInProgress.
|
|
|
|
// It should ignore the container and not return an error.
|
2015-12-04 15:34:43 -05:00
|
|
|
if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil {
|
2015-10-20 16:36:09 -04:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|