Skip to content
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

Host and Bridge network support in docker stack deploy #132

Merged
merged 3 commits into from May 31, 2017

Conversation

mavenugo
Copy link
Contributor

@mavenugo mavenugo commented May 26, 2017

With the introduction of node-local network support, docker services can
be attached to special networks such as host and bridge. This fix brings
in the required changes to make sure the stack file accepts these
networks as well.

Fixes #131

Signed-off-by: Madhu Venugopal madhu@docker.com

be attached to special networks such as host and bridge. This fix brings
in the required changes to make sure the stack file accepts these
networks as well.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

SGTM 👼

@codecov-io
Copy link

codecov-io commented May 26, 2017

Codecov Report

Merging #132 into master will increase coverage by 0.1%.
The diff coverage is 80%.

@@            Coverage Diff            @@
##           master     #132     +/-   ##
=========================================
+ Coverage   46.12%   46.23%   +0.1%     
=========================================
  Files         161      161             
  Lines       11006    11008      +2     
=========================================
+ Hits         5077     5089     +12     
+ Misses       5639     5629     -10     
  Partials      290      290

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

generally looks good, just one question

netAttachConfig := swarm.NetworkAttachmentConfig{
Target: target,
}
if container.NetworkMode(target).IsUserDefined() {
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen with the old logic when using a not user defined network?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prior to 17.06, the only networks that are supported in swarm-mode (especially via stack) are user-defined networks.

Its the node-local feature in 17.06 that brings in the support for host and bridge.

Hence, the older versions were never impacted by this lack of support.

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if I try to attach to the host or bridge network with a network alias?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we either need to warn that the aliases are being ignored, or we should add them as we would for other networks and let it fail on the server (assuming that's the behaviour).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnephin Service Discovery is not supported in host and bridge networks. This is known already and is same for compose already.

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 personally dont think it is required, because, there is no Service Discovery to begin with in these networks and hence the concept of alias doesnt even arise.

The users of such host mode understands that (as this is not unique to stack... the same thing is applicable to compose already)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you would expect this behaviour because you're familiar with it :)

A user has no idea of the limitations of host, and silently ignoring the aliases will lead to lots of confusion. Here's what I get with the latest docker-compose release:

ERROR: for examples_web_1  network-scoped alias is supported only for containers in user defined networks

We should keep the same behaviour and let the server error out for us. So I think we should revert this part of the diff.

If you agree, I can take care of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnephin sorry am confused. If we remove this, then stack cannot support --network=host ? or are you proposing another way for user to disable the alias functionality ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed another commit. It only sets the default alias if the network is user defined. That way if a user tries to use host/bridge with aliases, they will get an appropriate error, instead of silent failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay. now I understand your above points. SGTM

@dnephin
Copy link
Contributor

dnephin commented May 26, 2017

@mavenugo @vdemeester I pushed a commit which adds unit tests for validateExternalNetworks() and cleans it up a bit. There were a few functions which had unused arguments.

We should add another test case for convertServiceNetworks() when we agree on the behaviour with non-user defined networks.

@vdemeester vdemeester mentioned this pull request May 26, 2017
20 tasks
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
@mavenugo
Copy link
Contributor Author

@dnephin changes LGTM

Copy link
Collaborator

@vdemeester vdemeester 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
Copy link
Contributor Author

@vdemeester @thaJeztah can this be merged and picked for 17.06 RC2 ?

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.

[17.06] Support --network=host and --network=bridge in stack deploy
6 participants