-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[carry 317] Cli change to pass driver specific options to docker run #1767
[carry 317] Cli change to pass driver specific options to docker run #1767
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1767 +/- ##
==========================================
- Coverage 56.32% 56.17% -0.16%
==========================================
Files 307 307
Lines 21177 21210 +33
==========================================
- Hits 11928 11914 -14
- Misses 8382 8425 +43
- Partials 867 871 +4 |
Codecov Report
@@ Coverage Diff @@
## master #1767 +/- ##
==========================================
+ Coverage 56.28% 56.39% +0.11%
==========================================
Files 308 308
Lines 21299 21360 +61
==========================================
+ Hits 11988 12047 +59
+ Misses 8436 8434 -2
- Partials 875 879 +4 |
600ce6a
to
375ba2b
Compare
@vdemeester @silvin-lubecki I marked this as "WIP", but perhaps it's already ready for review (possibly tests will have to be added still); I'm on PTO until Monday, but if you think this would be good to have for this release; I can add tests in a follow-up |
To support multiple networks; this part will have to be removed from the engine, but otherwise (I think) that all works; https://github.com/moby/moby/blob/c7105e3c99286c88855c8d35079f957281dbf581/daemon/create.go#L308-L314 |
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.
LGTM 🐯
375ba2b
to
0c146eb
Compare
🤔
|
0c146eb
to
e447b6d
Compare
ping @vdemeester @silvin-lubecki I think this should be ok now; I added tests. Will need follow-ups for the completion-scripts (@albers) and for documentation 🤗 |
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.
Still LGTM 💃
e447b6d
to
0935350
Compare
opts/network_test.go
Outdated
} | ||
} | ||
|
||
func TestNetworkOptInvalidSyntax(t *testing.T) { | ||
func TestNetworkOptdvancedSyntaxInvalid(t *testing.T) { |
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.
oh, typo; fixing
The commit contains cli changes to support driver options for a network in docker run and docker network connect cli's. The driver-opt, aliases is now supported in the form of csv as per network option in service commands in swarm mode since docker#62 . This commit extends this support to docker run command as well. For docker connect command `--driver-opt` is added to pass driver specific options for the network the container is connecting to. Signed-off-by: Abhinandan Prativadi <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
0935350
to
a7ee071
Compare
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.
LGTM
This refactors the way networking options are parsed, and makes the client able to pass options for multiple networks. Currently, the daemon does not yet accept multiple networks when creating a container, and will produce an error. For backward-compatibility, the following global networking-related options are associated with the first network (in case multiple networks are set); - `--ip` - `--ip6` - `--link` - `--link-local-ip` - `--network-alias` Not all of these options are supported yet in the advanced notation, but for options that are supported, setting both the per-network option and the global option will produce a "conflicting options" error. Signed-off-by: Sebastiaan van Stijn <[email protected]>
a7ee071
to
5bc0963
Compare
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.
Still LGTM 🕺
For backward compatibility: if no custom options are provided for the network, and only a single network is specified, omit the endpoint-configuration on the client (the daemon will still create it when creating the container) This fixes an issue on older versions of legacy Swarm, which did not support `NetworkingConfig.EndpointConfig`. This was introduced in 5bc0963 (docker#1767) Signed-off-by: Sebastiaan van Stijn <[email protected]>
For backward compatibility: if no custom options are provided for the network, and only a single network is specified, omit the endpoint-configuration on the client (the daemon will still create it when creating the container) This fixes an issue on older versions of legacy Swarm, which did not support `NetworkingConfig.EndpointConfig`. This was introduced in 5bc0963 (docker#1767) Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 393c4f3) Signed-off-by: Sebastiaan van Stijn <[email protected]>
For backward compatibility: if no custom options are provided for the network, and only a single network is specified, omit the endpoint-configuration on the client (the daemon will still create it when creating the container) This fixes an issue on older versions of legacy Swarm, which did not support `NetworkingConfig.EndpointConfig`. This was introduced in 5bc0963 (docker#1767) Signed-off-by: Sebastiaan van Stijn <[email protected]>
For backward compatibility: if no custom options are provided for the network, and only a single network is specified, omit the endpoint-configuration on the client (the daemon will still create it when creating the container) This fixes an issue on older versions of legacy Swarm, which did not support `NetworkingConfig.EndpointConfig`. This was introduced in 5bc0963 (docker#1767) Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 4d7e6bf) Signed-off-by: Sebastiaan van Stijn <[email protected]>
return nil, err | ||
} | ||
if _, ok := endpoints[n.Target]; ok { | ||
return nil, errdefs.InvalidParameter(errors.Errorf("network %q is specified multiple times", n.Target)) |
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.
Any particular reason this was added?
We have a test in integration-cli in moby/moby that tests that this exact case is successful.
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.
Opened moby/moby#42163 to discuss removing the test case that this validation breaks.
@thaJeztah The csv syntax is a big problem in bash completion because it does not treat |
Is there a reason this isn't done yet? I'm happy to file a PR to make this, but given how simple it seems I just want to make sure there's not a deeper reason it hasn't been done. Seems like an arbitrary check for something the engine should be able to do just fine? Does an API spec need to be updated? |
No specific reason, other than that nobody has come round to it yet. When making that change, it should probably be gated by API version (i.e., keep the old behavior for existing API versions), and tests will be needed; the network code is known to be "tricky" at times (lots of corner-cases and due to complexity on setting up the network, there's various potential race-conditions). That said; at least having a (draft) pull request that removes the check, and verifies it works never hurts. And once it's in a release, we can possibly update docker-compose as well to consume it (connecting multiple networks instead of connecting them one at a time) |
That's a perfectly good reason. :-) Just wanted to make sure it wasn't a "this turned out to be unexpectedly hard" thing.
I think I can make that happen.
This is basically adjacent to my motivation; attaching multiple networks to a container is easy in |
100% agreed! If it all works, it's a lot cleaner (create this container attached to these networks, with these options) all in a single API call 🎉 |
The new advanced --network syntax has been introduced in docker#1767 but without support for link-local-ip and mac-address fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
The new advanced --network syntax has been introduced in docker#1767 but without support for link-local-ip and mac-address fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
The new advanced --network syntax introduced in docker#1767 is lacking support for `link-local-ip` and `mac-address` fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
The new advanced --network syntax introduced in docker#1767 is lacking support for `link-local-ip` and `mac-address` fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
The new advanced --network syntax introduced in docker#1767 is lacking support for `link-local-ip` and `mac-address` fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
The new advanced --network syntax introduced in docker#1767 is lacking support for `link-local-ip` and `mac-address` fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
The new advanced --network syntax introduced in docker#1767 is lacking support for `link-local-ip` and `mac-address` fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
The new advanced --network syntax introduced in docker#1767 is lacking support for `link-local-ip` and `mac-address` fields. This commit adds both. Signed-off-by: Albin Kerouanton <[email protected]>
carries #317
closes #317
closes #156
Adds preliminary support for multiple networks on
docker run
now that this syntax would allow this; the daemon does not yet support this, so specifying multiple networks will still produce an errorOpened this PR since #156 was closed.
The commit contains cli changes to support driver options for a network in docker run and docker network connect cli's.
The driver-opt, aliases is now supported in the form of csv as per network option in service commands in swarm mode since #62 . This commit extends this support to docker run command as well.
For docker connect command --driver-opt is added to pass driver specific options for the network the container is connecting to.
Following is supported:
Signed-off-by: Abhinandan Prativadi [email protected]