-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Fix 'failed to get network during CreateEndpoint' #41011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package service // import "github.com/docker/docker/integration/service" | |
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/docker/docker/api/types" | ||
"github.com/docker/docker/api/types/network" | ||
|
@@ -115,3 +116,35 @@ func TestDockerNetworkReConnect(t *testing.T) { | |
assert.NilError(t, err) | ||
assert.Check(t, is.DeepEqual(n1, n2)) | ||
} | ||
|
||
func TestDockerRestartWithAttachbleNetwork(t *testing.T) { | ||
skip.If(t, testEnv.DaemonInfo.OSType == "windows") | ||
defer setupTest(t)() | ||
d := swarm.NewSwarm(t, testEnv) | ||
defer d.Stop(t) | ||
client := d.NewClientT(t) | ||
defer client.Close() | ||
ctx := context.Background() | ||
|
||
name := t.Name() + "dummyNet" | ||
net.CreateNoError(ctx, t, client, name, | ||
net.WithDriver("overlay"), | ||
net.WithAttachable(), | ||
) | ||
|
||
c1 := container.Create(ctx, t, client, func(c *container.TestContainerConfig) { | ||
c.NetworkingConfig = &network.NetworkingConfig{ | ||
EndpointsConfig: map[string]*network.EndpointSettings{ | ||
name: {}, | ||
}, | ||
} | ||
}) | ||
|
||
err := client.ContainerStart(ctx, c1, types.ContainerStartOptions{}) | ||
assert.NilError(t, err) | ||
|
||
var timeout time.Duration = 20 * time.Second | ||
err = client.ContainerRestart(ctx, c1, &timeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this work with a smaller restart value , default in compose and cli is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arkodg Stopping busybox container need at least 10 seconds since busybox does not have signal handler for SIGTERM. So I feel the timeout here needs to be longer than 10 seconds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah how about 11 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid setting timeout to 11s will cause CI flaky. |
||
assert.NilError(t, err) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks scary; shouldn't these be removed, or is the code in
tryDetachContainerFromClusterNetwork
meant to replace this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the code
tryDetachContainerFromClusterNetwork
meant to replace this. IfremoveNetworks
is in controller's method, then it is asynchronized with container-start, and will cause test case in docker/for-linux#888 (comment) to fail.Another way may be adding a delay in controller's
Start()
, but it is not reliable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing this, what are your thoughts on applying a retry logic below in
Start
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arkodg I'm afraid we are not able to do retry logic in
Start
,nc.adapter.networkAttach(ctx)
inStart
just sends a message to trigger container starting to continue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to understand why
moby/daemon/container_operations.go
Line 428 in a23ca16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arkodg
See:
moby/daemon/container_operations.go
Lines 748 to 784 in a23ca16
The original problem occurs at L784, the retry logic inside L748 does not help.