-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
network: fix random missing network when service has more than one #10778
Conversation
As part of the fix for docker#10668, the logic was adjusted so that the default (highest-priority) network is used in the `ContainerCreate`, and then the remaining networks are connected via calls to `NetworkConnect` before starting the container. Unfortunately, `ServiceConfig::NetworksByPriority` is neither deterministic nor stable when networks have the same priority. It's non-deterministic because the order of networks from parsing YAML is random, since they are loaded into a Go map (which have random iteration order). Additionally, it's not using a `SortStable` in `compose-go`, so even if the load order was predictable, it still might produce different results. While I look at improving `compose-go` here to prevent this from tripping us up in the future, this fix looks at _all_ networks for a service and ignores the "default" one now. Before, it would always skip the first one in the slice since that _should_ have been the "default". Signed-off-by: Milas Bowman <milas.bowman@docker.com>
const projectName = "network-e2e" | ||
c := NewCLI(t, WithEnv( |
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.
fyi this test is functionally the same, I just removed the "subtests" since it's really one test, used WithEnv
to shorten the commands, and added a -t0
on the down
so that it's faster
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## v2 #10778 +/- ##
==========================================
+ Coverage 59.03% 59.16% +0.12%
==========================================
Files 113 115 +2
Lines 9774 9854 +80
==========================================
+ Hits 5770 5830 +60
- Misses 3419 3433 +14
- Partials 585 591 +6
☔ View full report in Codecov by Sentry. |
This issue cost me a lot of time. Thanks for fixing. |
What I did
As part of the fix for #10668, the logic was adjusted so that the default (highest-priority) network is used in the
ContainerCreate
, and then the remaining networks are connected via calls toNetworkConnect
before starting the container.Unfortunately,
ServiceConfig::NetworksByPriority
is neither deterministic nor stable when networks have the same priority.It's non-deterministic because the order of networks from parsing YAML is random, since they are loaded into a Go map (which have random iteration order). Additionally, it's not using a
SortStable
incompose-go
, so even if the load order was predictable, it still might produce different results.While I look at improving
compose-go
here to prevent this from tripping us up in the future, this fix looks at all networks for a service and ignores the "default" one now. Before, it would always skip the first one in the slice since that should have been the "default".Related issue
Host name lookup failure
or missing networks when using multiple networks #10777(not mandatory) A picture of a cute animal, if possible in relation to what you did