-
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
up: fix race condition on network connect #10756
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
milas
requested review from
nicksieger,
ndeloof,
StefanScherer,
ulyssessouza,
glours and
laurazard
and removed request for
a team
June 29, 2023 19:54
Engine API only allows at most one network to be connected as part of the ContainerCreate API request. Compose will pick the highest priority network. Afterwards, the remaining networks (if any) are connected before the container is actually started. The big change here is that, previously, the highest-priority network was connected in the create, and then disconnected and immediately reconnected along with all the others. This was racy because evidently connecting the container to the network as part of the create isn't synchronous, so sometimes when Compose tried to disconnect it, the API would return an error like: ``` container <id> is not connected to the network <network> ``` To avoid needing to disconnect and immediately reconnect, the network config logic has been refactored to ensure that it sets up the network config correctly the first time. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
nicksieger
approved these changes
Jun 29, 2023
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.
Nice fix and cleanup!
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## v2 #10756 +/- ##
==========================================
+ Coverage 58.91% 58.98% +0.06%
==========================================
Files 113 113
Lines 9795 9774 -21
==========================================
- Hits 5771 5765 -6
+ Misses 3433 3423 -10
+ Partials 591 586 -5
☔ View full report in Codecov by Sentry. |
ndeloof
approved these changes
Jun 29, 2023
Nice! 🎉 |
glours
approved these changes
Jun 29, 2023
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
Fix race conditions with network setup during
up
.Engine API only allows at most one network to be connected as part of the
ContainerCreate
API request. Compose will pick the highest priority network.Afterwards, the remaining networks (if any) are connected before the container is actually started.
The big change here is that, previously, the highest-priority network was connected in the create, and then disconnected and immediately reconnected along with all the others. This was racy because evidently connecting the container to the network as part of the create isn't synchronous, so sometimes when Compose tried to disconnect it, the API would return an error like:
To avoid needing to disconnect and immediately reconnect, the network config logic has been refactored to ensure that it sets up the network config correctly the first time.
Related issue
https://docker.atlassian.net/browse/ENV-241
(not mandatory) A picture of a cute animal, if possible in relation to what you did