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

Adding csv format parameters to network option in service create/update #32975

Closed
wants to merge 2 commits into from

Conversation

abhi
Copy link
Contributor

@abhi abhi commented May 2, 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.

- How I did it
Changed --network , --network-add options to accept csv format key/value by create a new network option type.

- How to verify it

docker service create --name web --network name=docknet,alias=web1,alias=web2 nginx
docker service create --name web --network docknet nginx
docker service update web --network-add name=docknet,alias=web1
docker service update web --network-rm docknet

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

polar-bear

@mavenugo
Copy link
Contributor

mavenugo commented May 4, 2017

ping @thaJeztah

@thaJeztah
Copy link
Member

Thanks! Should we have the same format added to docker container create/run to keep parity?

@thaJeztah
Copy link
Member

Also this relates to #31964 (although not all of the options are implemented yet)

@thaJeztah
Copy link
Member

Hm, is this by design, or overlooked?

docker network create -d overlay docknet

docker service create \
  --name web \
  --network name=docknet,alias=web1,alias=web2 \
  --network name=docknet,alias=web3,alias=web4 \
  nginx:alpine

@thaJeztah
Copy link
Member

Hm, looks like that's already possible in 17.05 (attach twice to the same network), gonna check 17.03/17.04

@abhi
Copy link
Contributor Author

abhi commented May 4, 2017

@thaJeztah : you beat me to it. Yes its possible in the current code as well. I can add a sanity check .
As Far as #31964 I am in the process of extending the network options to have driver options as well. So the plan is to support network name , alias, driver specific option for the network.

@mavenugo
Copy link
Contributor

mavenugo commented May 4, 2017

@thaJeztah we should get this for docker run as well... but we can address it using another PR as these are fairly independent and also there is more work involved for docker run to support multiple networks.

And yes, this is related to #31964 the only 2 networks options that we support today for docker service are network name and alias. As we support other options, we can start to add to this CSV format.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

design LGTM - the validation for duplicate networks can be separate from this, but is probably something that needs to be fixed.

moving to code review (left some initial comments)

case networkOptAlias:
netAttach.Aliases = append(netAttach.Aliases, value)
default:
return fmt.Errorf("invalid field key %s", key)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should make the error messages consistent with what we have for --mount, e.g.

return fmt.Errorf("unexpected key '%s' in '%s'", key, field)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above

}

if len(parts) != 2 {
return fmt.Errorf("invalid field %s", field)
Copy link
Member

Choose a reason for hiding this comment

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

Same here for consistent error messages

return fmt.Errorf("invalid field '%s' must be a key=value pair", field)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return fmt.Errorf("invalid field key %s", key)
}
}
n.networkAttachments = append(n.networkAttachments, netAttach)
Copy link
Member

Choose a reason for hiding this comment

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

Should we validate here if netAttach.name (or ID?) is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

both work. So shouldn't be a problem

@abhi
Copy link
Contributor Author

abhi commented May 8, 2017

@thaJeztah thanks for taking a quick look. I will split this pr in docker/cli and here to continue the discussion further.

abhi added 2 commits May 8, 2017 14:49
The commit adds capability to accept csv parameters
for network option in service create/update commands.
With this the following will be supported

docker service create --name web --network name=docknet,alias=web1,alias=web2 nginx
docker service create --name web --network docknet nginx
docker service update web --network-add name=docknet,alias=web1
docker service update web --network-rm docknet

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
@abhi
Copy link
Contributor Author

abhi commented May 11, 2017

closing this in favor of #33130

@abhi abhi closed this May 11, 2017
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.

None yet

4 participants