Skip to content

Conversation

@abhi
Copy link
Contributor

@abhi abhi commented May 10, 2017

- 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-add options to accept csv format key/value by creating a new network option type.

- How to verify it

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

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

@abhi abhi force-pushed the network-opt branch 3 times, most recently from d290f63 to 4b199c5 Compare May 10, 2017 18:03
Copy link

@aaronlehmann aaronlehmann left a 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

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

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

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.

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.

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.

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.

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.

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.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Contributor Author

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.

Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

@mavenugo
Copy link
Contributor

ping @thaJeztah

@abhi
Copy link
Contributor Author

abhi commented May 12, 2017

@mavenugo addressed the comments.

@abhi abhi force-pushed the network-opt branch 2 times, most recently from 241e4e5 to 1e55f65 Compare May 15, 2017 17:50

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

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.

@abhi
Copy link
Contributor Author

abhi commented May 17, 2017

@aaronlehmann I have addressed the comments. PTAL

@aaronlehmann
Copy link

This is still vendoring your fork of swarmkit. Does it need commits that are not on master?

@abhi
Copy link
Contributor Author

abhi commented May 17, 2017

@aaronlehmann just updated the vendoring. I was waiting for a PR to be merged in swarmkit. Its merged now.

@aaronlehmann
Copy link

Let's merge #32981 first - that will handle the vendoring update

@mavenugo
Copy link
Contributor

mavenugo commented May 17, 2017

@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.

@aaronlehmann
Copy link

Sure. To get CI to pass, this will have to take the changes to vendor.conf from #32981.

@aaronlehmann aaronlehmann added status/failing-ci Indicates that the PR in its current state fails the test suite and removed status/needs-vendoring labels May 17, 2017
@thaJeztah
Copy link
Member

changes itself LGTM

@mavenugo
Copy link
Contributor

mavenugo commented May 18, 2017

@abhinandanpb can you pls rebase this PR on top of d618b56 from https://github.com/aboch/docker ?
That will get the CI moving in parallel to #32981 instead of serializing it one after another.

@abhi abhi force-pushed the network-opt branch 2 times, most recently from 5cfee8e to 92ad957 Compare May 18, 2017 01:28
abhi added 2 commits May 17, 2017 18:46
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>
@thaJeztah thaJeztah removed the status/failing-ci Indicates that the PR in its current state fails the test suite label May 18, 2017
Copy link

@aaronlehmann aaronlehmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@mavenugo mavenugo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mavenugo mavenugo merged commit 45c6f42 into moby:master May 18, 2017
mavenugo added a commit to mavenugo/docker that referenced this pull request Jun 7, 2017
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants