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

Add `scope` filter in `GET /networks/(id or name)` #33630

Merged
merged 1 commit into from Jun 13, 2017

Conversation

Projects
None yet
5 participants
@yongtang
Member

yongtang commented Jun 11, 2017

- What I did
This fix tries to add a scope in the query of GET /networks/(id or name) (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.

- How I did it

This fix fixes the issue by allowing a scope query in GET /networks/(id or name).

- How to verify it

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

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)
cat-1796843_1280

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

This fix fixes docker/cli#167

Signed-off-by: Yong Tang yong.tang.github@outlook.com

@yongtang

This comment has been minimized.

Show comment
Hide comment
@yongtang
Member

yongtang commented Jun 11, 2017

/cc @dnephin

Show outdated Hide outdated api/server/router/network/network_routes.go Outdated
Show outdated Hide outdated client/interface.go Outdated
Show outdated Hide outdated client/network_inspect_test.go Outdated
Show outdated Hide outdated integration-cli/docker_api_swarm_test.go Outdated
Show outdated Hide outdated client/network_inspect_test.go Outdated
Add `scope` filter in `/networks/<id>`
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, #30897, #33561, #30242

This fix fixes docker/cli#167

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@yongtang

This comment has been minimized.

Show comment
Hide comment
@yongtang

yongtang Jun 12, 2017

Member

Thanks @dnephin for the review. The PR has been updated. Please take a look.

Member

yongtang commented Jun 12, 2017

Thanks @dnephin for the review. The PR has been updated. Please take a look.

@dnephin

LGTM

var n types.NetworkCreateResponse
networkCreateRequest.NetworkCreate.Driver = "overlay"
status, out, err := d.SockRequest("POST", "/networks/create", networkCreateRequest)

This comment has been minimized.

@dnephin

dnephin Jun 12, 2017

Member

You can also use the docker client/ here, which you can get from `integration-cli/request.NewClient(), but this is ok as well I guess.

@dnephin

dnephin Jun 12, 2017

Member

You can also use the docker client/ here, which you can get from `integration-cli/request.NewClient(), but this is ok as well I guess.

@aaronlehmann

This comment has been minimized.

Show comment
Hide comment
@aaronlehmann

aaronlehmann Jun 13, 2017

Contributor

LGTM

Contributor

aaronlehmann commented Jun 13, 2017

LGTM

@aaronlehmann aaronlehmann merged commit 4310f7d into moby:master Jun 13, 2017

6 checks passed

dco-signed All commits are signed
experimental Jenkins build Docker-PRs-experimental 34945 has succeeded
Details
janky Jenkins build Docker-PRs 43547 has succeeded
Details
powerpc Jenkins build Docker-PRs-powerpc 3923 has succeeded
Details
windowsRS1 Jenkins build Docker-PRs-WoW-RS1 14847 has succeeded
Details
z Jenkins build Docker-PRs-s390x 3658 has succeeded
Details

@GordonTheTurtle GordonTheTurtle added this to the 17.06.0 milestone Jun 13, 2017

@yongtang yongtang deleted the yongtang:167-cli-network-inspect-scope branch Jun 13, 2017

andrewhsu pushed a commit to docker/docker-ce that referenced this pull request Jun 24, 2017

Update docker/docker to 4310f7d
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/docker-ce that referenced this pull request Jun 24, 2017

Use `scope=swarm` for service related network inspect.
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

@thaJeztah thaJeztah removed this from the 17.06.0 milestone Jul 19, 2017

andrewhsu added a commit to andrewhsu/docker-ce that referenced this pull request Jul 26, 2017

Use `scope=swarm` for service related network inspect.
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>
(cherry picked from commit 657457ee2cc1b4ced804674ad1b3bfe19b849f31)
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment