-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Adding network specific options to service create/update #33130
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
Conversation
d290f63 to
4b199c5
Compare
aaronlehmann
left a comment
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.
Can you please rebase your swarmkit branch? It appears to be older than what's currently vendored, so it's effectively reverting a bunch of changes. This makes it hard to review the changes to swarmkit.
opts/network.go
Outdated
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 code doesn't seem to be used anywhere in moby. I think it belongs in the docker/cli repo, not here.
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.
We will need to move the opts/* to docker/cli. I believe that should be a seperate PR. I am going to park this here until then.
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.
Yes. I agree. There are multiple other CLIs with their CSV options all part of the opts package and are currently used only in docker/cli. I guess moving opts out to docker/cli is its own independent work.
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.
@vdemeester opened a pull request here to move the options; docker/cli#82
opts/network.go
Outdated
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 import should be separated from the standard library imports by a blank line.
api/types/network/network.go
Outdated
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.
What is this method used for? I don't see it called anywhere.
api/types/network/network.go
Outdated
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.
There should be a space between // and the start of the comment.
daemon/cluster/convert/service.go
Outdated
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.
strings should not be moved down here.
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.
logrus should not be moved here.
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.
An extra tab was inserted on this line.
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.
As a protobuf field name, this should be driver_opts.
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.
What is this for?
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.
I will be making the swarmkit changes and update it.
7ce5e1c to
3840111
Compare
api/types/network/network.go
Outdated
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.
The use of Options is confusing in this context. Isnt a better name for this is EndpointNetworkConfig ?
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.
not really i guess. Since this is part of the network type package it would be evident. Not particular about it. I can change if required.
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.
Options in a network api package can easily indicate options of the network object. In the context of the UX/API, I can see an argument to be made for ServiceOption under the network package. If you are okay, pls consider renaming it as ServiceOption.
opts/network.go
Outdated
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.
Yes. I agree. There are multiple other CLIs with their CSV options all part of the opts package and are currently used only in docker/cli. I guess moving opts out to docker/cli is its own independent work.
opts/network.go
Outdated
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.
Can you instead use the common pattern used in other similar options such as opts/port.go.
longSyntax, err := regexp.MatchString(`\w+=\w+(,\w+=\w+)*`, value)
opts/network.go
Outdated
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.
Minor eye-sore... we can follow similar pattern as in opts/port.go.
|
ping @thaJeztah |
|
@mavenugo addressed the comments. |
241e4e5 to
1e55f65
Compare
api/types/network/network.go
Outdated
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.
Is this structure used at all in the API?
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 seems to be used, but was not part of the swarmkit PR.
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.
its used in cli and opts. I read the readme regarding consumers of the api and cli was one of them. So I parked it here.
However since cli and opts is moved to docker/cli repo I will be moving it there and will only be used in the cli.
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.
I think this should be part of opts rather than api.
b57d340 to
8463f78
Compare
|
@aaronlehmann I have addressed the comments. PTAL |
|
This is still vendoring your fork of swarmkit. Does it need commits that are not on master? |
|
@aaronlehmann just updated the vendoring. I was waiting for a PR to be merged in swarmkit. Its merged now. |
|
Let's merge #32981 first - that will handle the vendoring update |
|
@aaronlehmann I think #32981 might take more time and based on the comments, I think it might require some more code changes. I think we should take the vendoring via this PR and let the other one rebase. wdyt ? -- edit -- @aaronlehmann @abhinandanpb yes. Based on the CI failures I think it is better to wait for #32981. It has multiple dependencies on swarmkit and libnetwork. and it is better to have it via #32981. |
|
Sure. To get CI to pass, this will have to take the changes to |
|
changes itself LGTM |
|
@abhinandanpb can you pls rebase this PR on top of d618b56 from https://github.com/aboch/docker ? |
5cfee8e to
92ad957
Compare
The commit adds capability to accept csv parameters for network option in service create/update commands.The change includes name,alias driver options specific to the network. With this the following will be supported docker service create --name web --network name=docknet,alias=web1,driver-opt=field1=value1 nginx docker service create --name web --network docknet nginx docker service update web --network-add name=docknet,alias=web1,driver-opt=field1=value1 docker service update web --network-rm docknet Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
aaronlehmann
left a comment
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
mavenugo
left a comment
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
If a service alias is copied to task, then the DNS resolution on the service name will resolve to service VIP and all of Task-IPs and that will break the concept of vip based load-balancing resulting in all the dns-rr caching issues. This is a regression introduced in moby#33130 Signed-off-by: Madhu Venugopal <madhu@docker.com>
- What I did
Added capability to service create/update to accept network option in csv format and add test case to verify the same.The change includes name, alias and driver options specific to the network. The options are passed to the driver on create and join of endpoint. The corresponding changes are in swarmkit and cli.
- How I did it
Changed
--network,--network-addoptions to accept csv format key/value by creating a new network option type.- How to verify it
Relevant PRs:
moby/swarmkit#2176 and moby/swarmkit#2183 (merged)
docker/cli#62
The cli change in docker/cli#62 will allow users to pass driver options, alias and network name as a part of service create and service update. The driver options information will eventually trickle down as a part of endpoint create and join which will allow the drivers to use this information for any additional processing for the endpoint.
Alias information is already part of docker run as --net-alias. However since service can be created and updated with multiple networks there is a need to pass network specific aliases which can also be done with this change.
The change in this PR ties this information to backend structs to pass the driver options, alias as generic options to libnetwork