Merge component 'engine' from git@github.com:moby/moby master
This commit is contained in:
@@ -71,18 +71,15 @@
|
||||
# - close an issue or pull request when it's inappropriate or off-topic
|
||||
|
||||
people = [
|
||||
"aboch",
|
||||
"alexellis",
|
||||
"andrewhsu",
|
||||
"anonymuse",
|
||||
"chanwit",
|
||||
"ehazlett",
|
||||
"fntlnz",
|
||||
"gianarb",
|
||||
"mgoelzer",
|
||||
"programmerq",
|
||||
"rheinwein",
|
||||
"ripcurld0",
|
||||
"ripcurld",
|
||||
"thajeztah"
|
||||
]
|
||||
|
||||
@@ -242,11 +239,6 @@
|
||||
Email = "aaron.lehmann@docker.com"
|
||||
GitHub = "aaronlehmann"
|
||||
|
||||
[people.aboch]
|
||||
Name = "Alessandro Boch"
|
||||
Email = "aboch@docker.com"
|
||||
GitHub = "aboch"
|
||||
|
||||
[people.alexellis]
|
||||
Name = "Alex Ellis"
|
||||
Email = "alexellis2@gmail.com"
|
||||
@@ -382,11 +374,6 @@
|
||||
Email = "madhu@docker.com"
|
||||
GitHub = "mavenugo"
|
||||
|
||||
[people.mgoelzer]
|
||||
Name = "Mike Goelzer"
|
||||
Email = "mike.goelzer@docker.com"
|
||||
GitHub = "mgoelzer"
|
||||
|
||||
[people.mhbauer]
|
||||
Name = "Morgan Bauer"
|
||||
Email = "mbauer@us.ibm.com"
|
||||
@@ -422,10 +409,10 @@
|
||||
Email = "laura@codeship.com"
|
||||
GitHub = "rheinwein"
|
||||
|
||||
[people.ripcurld0]
|
||||
[people.ripcurld]
|
||||
Name = "Boaz Shuster"
|
||||
Email = "ripcurld.github@gmail.com"
|
||||
GitHub = "ripcurld0"
|
||||
GitHub = "ripcurld"
|
||||
|
||||
[people.runcom]
|
||||
Name = "Antonio Murdaca"
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/integration/internal/container"
|
||||
"github.com/docker/docker/integration/internal/request"
|
||||
@@ -26,22 +27,24 @@ func TestRenameLinkedContainer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
client := request.NewAPIClient(t)
|
||||
|
||||
aID := container.Run(t, ctx, client, container.WithName("a0"))
|
||||
bID := container.Run(t, ctx, client, container.WithName("b0"), container.WithLinks("a0"))
|
||||
aName := "a0" + t.Name()
|
||||
bName := "b0" + t.Name()
|
||||
aID := container.Run(t, ctx, client, container.WithName(aName))
|
||||
bID := container.Run(t, ctx, client, container.WithName(bName), container.WithLinks(aName))
|
||||
|
||||
err := client.ContainerRename(ctx, aID, "a1")
|
||||
err := client.ContainerRename(ctx, aID, "a1"+t.Name())
|
||||
assert.NilError(t, err)
|
||||
|
||||
container.Run(t, ctx, client, container.WithName("a0"))
|
||||
container.Run(t, ctx, client, container.WithName(aName))
|
||||
|
||||
err = client.ContainerRemove(ctx, bID, types.ContainerRemoveOptions{Force: true})
|
||||
assert.NilError(t, err)
|
||||
|
||||
bID = container.Run(t, ctx, client, container.WithName("b0"), container.WithLinks("a0"))
|
||||
bID = container.Run(t, ctx, client, container.WithName(bName), container.WithLinks(aName))
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, bID)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual([]string{"/a0:/b0/a0"}, inspect.HostConfig.Links))
|
||||
assert.Check(t, is.DeepEqual([]string{"/" + aName + ":/" + bName + "/" + aName}, inspect.HostConfig.Links))
|
||||
}
|
||||
|
||||
func TestRenameStoppedContainer(t *testing.T) {
|
||||
@@ -49,7 +52,7 @@ func TestRenameStoppedContainer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
client := request.NewAPIClient(t)
|
||||
|
||||
oldName := "first_name"
|
||||
oldName := "first_name" + t.Name()
|
||||
cID := container.Run(t, ctx, client, container.WithName(oldName), container.WithCmd("sh"))
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
@@ -71,7 +74,7 @@ func TestRenameRunningContainerAndReuse(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
client := request.NewAPIClient(t)
|
||||
|
||||
oldName := "first_name"
|
||||
oldName := "first_name" + t.Name()
|
||||
cID := container.Run(t, ctx, client, container.WithName(oldName))
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
@@ -99,7 +102,7 @@ func TestRenameInvalidName(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
client := request.NewAPIClient(t)
|
||||
|
||||
oldName := "first_name"
|
||||
oldName := "first_name" + t.Name()
|
||||
cID := container.Run(t, ctx, client, container.WithName(oldName))
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
@@ -123,21 +126,25 @@ func TestRenameAnonymousContainer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
client := request.NewAPIClient(t)
|
||||
|
||||
_, err := client.NetworkCreate(ctx, "network1", types.NetworkCreate{})
|
||||
networkName := "network1" + t.Name()
|
||||
_, err := client.NetworkCreate(ctx, networkName, types.NetworkCreate{})
|
||||
|
||||
assert.NilError(t, err)
|
||||
cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) {
|
||||
c.NetworkingConfig.EndpointsConfig = map[string]*network.EndpointSettings{
|
||||
"network1": {},
|
||||
networkName: {},
|
||||
}
|
||||
c.HostConfig.NetworkMode = "network1"
|
||||
c.HostConfig.NetworkMode = containertypes.NetworkMode(networkName)
|
||||
})
|
||||
err = client.ContainerRename(ctx, cID, "container1")
|
||||
|
||||
container1Name := "container1" + t.Name()
|
||||
err = client.ContainerRename(ctx, cID, container1Name)
|
||||
assert.NilError(t, err)
|
||||
// Stop/Start the container to get registered
|
||||
// FIXME(vdemeester) this is a really weird behavior as it fails otherwise
|
||||
err = client.ContainerStop(ctx, "container1", nil)
|
||||
err = client.ContainerStop(ctx, container1Name, nil)
|
||||
assert.NilError(t, err)
|
||||
err = client.ContainerStart(ctx, "container1", types.ContainerStartOptions{})
|
||||
err = client.ContainerStart(ctx, container1Name, types.ContainerStartOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||
@@ -148,10 +155,10 @@ func TestRenameAnonymousContainer(t *testing.T) {
|
||||
}
|
||||
cID = container.Run(t, ctx, client, func(c *container.TestContainerConfig) {
|
||||
c.NetworkingConfig.EndpointsConfig = map[string]*network.EndpointSettings{
|
||||
"network1": {},
|
||||
networkName: {},
|
||||
}
|
||||
c.HostConfig.NetworkMode = "network1"
|
||||
}, container.WithCmd("ping", count, "1", "container1"))
|
||||
c.HostConfig.NetworkMode = containertypes.NetworkMode(networkName)
|
||||
}, container.WithCmd("ping", count, "1", container1Name))
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, cID)
|
||||
@@ -165,11 +172,13 @@ func TestRenameContainerWithSameName(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
client := request.NewAPIClient(t)
|
||||
|
||||
cID := container.Run(t, ctx, client, container.WithName("old"))
|
||||
oldName := "old" + t.Name()
|
||||
cID := container.Run(t, ctx, client, container.WithName(oldName))
|
||||
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||
err := client.ContainerRename(ctx, "old", "old")
|
||||
err := client.ContainerRename(ctx, oldName, oldName)
|
||||
testutil.ErrorContains(t, err, "Renaming a container with the same name")
|
||||
err = client.ContainerRename(ctx, cID, "old")
|
||||
err = client.ContainerRename(ctx, cID, oldName)
|
||||
testutil.ErrorContains(t, err, "Renaming a container with the same name")
|
||||
}
|
||||
|
||||
@@ -185,16 +194,19 @@ func TestRenameContainerWithLinkedContainer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
client := request.NewAPIClient(t)
|
||||
|
||||
db1ID := container.Run(t, ctx, client, container.WithName("db1"))
|
||||
db1Name := "db1" + t.Name()
|
||||
db1ID := container.Run(t, ctx, client, container.WithName(db1Name))
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, db1ID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
app1ID := container.Run(t, ctx, client, container.WithName("app1"), container.WithLinks("db1:/mysql"))
|
||||
app1Name := "app1" + t.Name()
|
||||
app2Name := "app2" + t.Name()
|
||||
app1ID := container.Run(t, ctx, client, container.WithName(app1Name), container.WithLinks(db1Name+":/mysql"))
|
||||
poll.WaitOn(t, container.IsInState(ctx, client, app1ID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||
|
||||
err := client.ContainerRename(ctx, "app1", "app2")
|
||||
err := client.ContainerRename(ctx, app1Name, app2Name)
|
||||
assert.NilError(t, err)
|
||||
|
||||
inspect, err := client.ContainerInspect(ctx, "app2/mysql")
|
||||
inspect, err := client.ContainerInspect(ctx, app2Name+"/mysql")
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(db1ID, inspect.ID))
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error {
|
||||
logrus.Warnf("Could not unmount %s: %v", propRoot, err)
|
||||
}
|
||||
}
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return pm.pluginPostStart(p, c)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package plugin // import "github.com/docker/docker/plugin"
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -10,6 +11,8 @@ import (
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/plugin/v2"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func TestManagerWithPluginMounts(t *testing.T) {
|
||||
@@ -77,3 +80,58 @@ func newTestPlugin(t *testing.T, name, cap, root string) *v2.Plugin {
|
||||
|
||||
return &p
|
||||
}
|
||||
|
||||
type simpleExecutor struct {
|
||||
}
|
||||
|
||||
func (e *simpleExecutor) Create(id string, spec specs.Spec, stdout, stderr io.WriteCloser) error {
|
||||
return errors.New("Create failed")
|
||||
}
|
||||
|
||||
func (e *simpleExecutor) Restore(id string, stdout, stderr io.WriteCloser) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *simpleExecutor) IsRunning(id string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (e *simpleExecutor) Signal(id string, signal int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestCreateFailed(t *testing.T) {
|
||||
root, err := ioutil.TempDir("", "test-create-failed")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer system.EnsureRemoveAll(root)
|
||||
|
||||
s := NewStore()
|
||||
managerRoot := filepath.Join(root, "manager")
|
||||
p := newTestPlugin(t, "create", "testcreate", managerRoot)
|
||||
|
||||
m, err := NewManager(
|
||||
ManagerConfig{
|
||||
Store: s,
|
||||
Root: managerRoot,
|
||||
ExecRoot: filepath.Join(root, "exec"),
|
||||
CreateExecutor: func(*Manager) (Executor, error) { return &simpleExecutor{}, nil },
|
||||
LogPluginEvent: func(_, _, _ string) {},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := s.Add(p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := m.enable(p, &controller{}, false); err == nil {
|
||||
t.Fatalf("expected Create failed error, got %v", err)
|
||||
}
|
||||
|
||||
if err := m.Remove(p.Name(), &types.PluginRmConfig{ForceRemove: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user