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

Service creation with duplicate network name on different scopes (one in local and one in swarm) #167

Closed
yongtang opened this issue Jun 8, 2017 · 1 comment · Fixed by moby/moby#33630

Comments

@yongtang
Copy link
Contributor

yongtang commented Jun 8, 2017

Description

In command line docker service create, the network name is now converted to network ID then passed to daemon (vs. done in the daemon previously):

func convertNetworks(ctx context.Context, apiClient client.NetworkAPIClient, networks opts.NetworkOpt) ([]swarm.NetworkAttachmentConfig, error) {
var netAttach []swarm.NetworkAttachmentConfig
for _, net := range networks.Value() {
networkIDOrName := net.Target
_, err := apiClient.NetworkInspect(ctx, networkIDOrName, false)
if err != nil {
return nil, err
}
netAttach = append(netAttach, swarm.NetworkAttachmentConfig{Target: net.Target, Aliases: net.Aliases, DriverOpts: net.DriverOpts})
}
sort.Sort(byNetworkTarget(netAttach))
return netAttach, nil
}

However, as convertNetworks uses inspect to do the network name conversion, a duplication error would be returned in case there are multiple network IDs available for the same network name.

In certain situations, it might be possible that there are multiple networks with the same name but with different scope, e.g, one foo in local and one foo in swarm.

For that I think it makes sense to change the way convertNetworks is done so that only networks related to swarm scope are searched.

Additional information you deem important (e.g. issue happens only occasionally):

This issue may need to be resolved in order to eventually fix network duplication issue in moby/moby/pull/30897 , moby/moby/issues/33561, moby/moby/issues/30242

@dnephin
Copy link
Contributor

dnephin commented Jun 8, 2017

Are you proposing to add a parameter to service inspect that allows the user to specify which scope they are inspecting? I think that sounds good.

yongtang added a commit to yongtang/docker that referenced this issue Jun 12, 2017
This fix tries to add a `scope` in the query of `/networks/<id>`
(`NetworkInspect`) so that in case of duplicate network names,
it is possible to locate the network ID based on the network
scope (`local`, 'swarm', or `global`).

Multiple networks might exist in different scopes, which is a legitimate case.
For example, a network name `foo` might exists locally and in swarm network.

However, before this PR it was not possible to query a network name `foo`
in a specific scope like swarm.

This fix fixes the issue by allowing a `scope` query in `/networks/<id>`.

Additional test cases have been added to unit tests and integration tests.

This fix is related to docker/cli#167, moby#30897, moby#33561, moby#30242

This fix fixes docker/cli#167

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
andrewhsu pushed a commit to docker-archive/docker-ce that referenced this issue Jun 24, 2017
This fix updates docker/docker to 4310f7d

This fix is related to moby/moby#33630 and docker/cli#167

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 8c2f81892beb7634a97efeec053f7052c36b4039
Component: cli
andrewhsu pushed a commit to docker-archive/docker-ce that referenced this issue Jun 24, 2017
This fix use `scope=swarm` for service related network inspect.
The purpose is that, in case multiple networks with the same
name exist in different scopes, it is still possible to obtain
the network for services.

This fix is related to moby/moby#33630 and docker/cli#167

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 657457ee2cc1b4ced804674ad1b3bfe19b849f31
Component: cli
silvin-lubecki pushed a commit to silvin-lubecki/engine-extract that referenced this issue Mar 16, 2020
This fix tries to add a `scope` in the query of `/networks/<id>`
(`NetworkInspect`) so that in case of duplicate network names,
it is possible to locate the network ID based on the network
scope (`local`, 'swarm', or `global`).

Multiple networks might exist in different scopes, which is a legitimate case.
For example, a network name `foo` might exists locally and in swarm network.

However, before this PR it was not possible to query a network name `foo`
in a specific scope like swarm.

This fix fixes the issue by allowing a `scope` query in `/networks/<id>`.

Additional test cases have been added to unit tests and integration tests.

This fix is related to docker/cli#167, moby/moby#30897, moby/moby#33561, moby/moby#30242

This fix fixes docker/cli#167

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 158b2a1
Component: engine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants