-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Conversation
ping @thaJeztah |
Thanks! Should we have the same format added to |
Also this relates to #31964 (although not all of the options are implemented yet) |
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 |
Hm, looks like that's already possible in 17.05 (attach twice to the same network), gonna check 17.03/17.04 |
@thaJeztah : you beat me to it. Yes its possible in the current code as well. I can add a sanity check . |
@thaJeztah we should get this for And yes, this is related to #31964 the only 2 networks options that we support today for |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
Line 129 in 49376cd
return fmt.Errorf("unexpected key '%s' in '%s'", key, field) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
Line 82 in 49376cd
return fmt.Errorf("invalid field '%s' must be a key=value pair", field) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thaJeztah I was. following the error message https://github.com/moby/moby/blob/master/opts/port.go#L43
return fmt.Errorf("invalid field key %s", key) | ||
} | ||
} | ||
n.networkAttachments = append(n.networkAttachments, netAttach) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@thaJeztah thanks for taking a quick look. I will split this pr in docker/cli and here to continue the discussion further. |
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>
closing this in favor of #33130 |
- 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
- A picture of a cute animal (not mandatory but encouraged)