-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Add flag --host to service create and --host-add/rm to service update
#28031
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
Conversation
02dc164 to
47b063a
Compare
aluzzardi
left a comment
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.
api/types/swarm/container.go
Outdated
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.
This should be Hosts like in SwarmKit
cli/command/service/create.go
Outdated
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.
To follow convention, this should be:
--host
Then, docker service update should expose:
--host-add--host-rm
@dnephin Thoughts?
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.
ya, I agree
47b063a to
1716020
Compare
--add-host to docker service create--host to service create and --host-add/rm to service update
|
Thanks @aluzzardi @dnephin @icecrime @aanand for the review. The PR has been updated. Now Please take a look and let me know for any issues. |
1716020 to
5e42d49
Compare
|
Desgin LGTM 🐸 |
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 don't think we should have multiple integration tests for every flag.
Really we only need a couple unit tests for the update function.
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.
Thanks @dnephin. The PR has been updated with this integration test removed. The code change is covered by unit tests now.
|
Design LGTM |
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.
Needs to be --host
Needs service update docs as well
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.
Thanks @aluzzardi the PR has been updated with docs issue addressed.
|
Code LGTM Need reference docs update: missing |
|
After some thought, the new The current format does not correctly represent the concept of aliases, which means we are losing information in transmission. I think we can match this syntax is the swarmkit/services API by insisting on the above syntax. The approach of keying by hostname should still work here, but ordering control is going to be hard with taking a hosts file as input. |
|
@stevvooe Do we also want to change the cli input? For example, we might use: (Currently it is `docker run --add-host "myhost:1.2.3.4") The advantage is that it is possible for The drawback is that it is not consistent with |
|
@yongtang IMO changing the CLI is a good idea. It might not be consistant with |
|
I'm not so sure we should change. Changing this to match the format IMO is leaking the underlying implementation, instead of the intent of the user. Now the user has to read the Linux man page for learning the format that What if we want to change to a different implementation in future (e.g. add entries to the embedded DNS, instead of updating
@stevvooe is there a difference between and Both seem to do the same |
|
Why does docker need to modify the hosts file in swarm mode? Can't we return it to the user to control and stop bind mounting it at all? Docker needs it for |
|
@yongtang Do not change the CLI input. I am only advocating that the API adopt the model that represents the problem. Again, the main problem with the docker API today is that we made it reflect too much of CLI behavior. While they should complement each other, it is more important that the API reflect a realistic data model. The CLI can then bolster that data model with sugar! |
|
@yongtang Looking good! |
api/types/swarm/container.go
Outdated
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.
👌
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.
This needs to use strings.Fields so it splits on arbitrary whitespace.
|
LGTM after |
7da6695 to
6ad36d0
Compare
|
Thanks @stevvooe for the review. The PR has been updated. |
This fix is a followup for `Hosts` field in `ContainerSpec`, from the comment in: moby#1729 (review) and from docker PR: moby/moby#28031 In the docker PR, it has been specified that `Hosts` in `ContainerSpec` should only follow the standard format: ``` IP_address canonical_hostname [aliases...] ``` The docker PR 28031 already takes the above into consideration so no implementation updates needed. This fix corrects the comment in the specification of `Hosts`. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
…service update` This fix tries to address 27902 by adding a flag `--host` to `docker service create` and `--host-add/--host-rm` to `docker service update`, so that it is possible to specify extra `host:ip` settings in `/etc/hosts`. This fix adds `Hosts` in swarmkit's `ContainerSpec` so that it is possible to specify extra hosts during service creation. Related docs has been updated. An integration test has been added. This fix fixes 27902. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
6ad36d0 to
ea9a23c
Compare
This fix is a followup for `Hosts` field in `ContainerSpec`, from the comment in: moby#1729 (review) and from docker PR: moby/moby#28031 In the docker PR, it has been specified that `Hosts` in `ContainerSpec` should only follow the standard format: ``` IP_address canonical_hostname [aliases...] ``` The docker PR 28031 already takes the above into consideration so no implementation updates needed. This fix corrects the comment in the specification of `Hosts`. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
|
LGTM |
Pull request moby#27745 added support for the client to talk to older versions of the daemon. Various flags were added to docker 1.13 that are not compatible with older daemons. This PR adds annotations to those flags, so that they are automatically hidden if the daemon is older than docker 1.13 (API 1.25). Not all new flags affect the API (some are client-side only). The following PR's added new flags to docker 1.13 that affect the API; - moby#23430 added `--cpu-rt-period`and `--cpu-rt-runtime` - moby#27800 / moby#25317 added `--group` / `--group-add` / `--group-rm` - moby#27702 added `--network` to `docker build` - moby#25962 added `--attachable` to `docker network create` - moby#27998 added `--compose-file` to `docker stack deploy` - moby#22566 added `--stop-timeout` to `docker run` and `docker create` - moby#26061 added `--init` to `docker run` and `docker create` - moby#26941 added `--init-path` to `docker run` and `docker create` - moby#27958 added `--cpus` on `docker run` / `docker create` - moby#27567 added `--dns`, `--dns-opt`, and `--dns-search` to `docker service create` - moby#27596 added `--force` to `docker service update` - moby#27857 added `--hostname` to `docker service create` - moby#28031 added `--hosts`, `--host-add` / `--host-rm` to `docker service create` and `docker service update` - moby#28076 added `--tty` on `docker service create` / `docker service update` - moby#26421 added `--update-max-failure-ratio`, `--update-monitor` and `--rollback` on `docker service update` - moby#27369 added `--health-cmd`, `--health-interval`, `--health-retries`, `--health-timeout` and `--no-healthcheck` options to `docker service create` and `docker service update` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Add flag `--host` to `service create` and `--host-add/rm` to `service update`
Pull request moby/moby#27745 added support for the client to talk to older versions of the daemon. Various flags were added to docker 1.13 that are not compatible with older daemons. This PR adds annotations to those flags, so that they are automatically hidden if the daemon is older than docker 1.13 (API 1.25). Not all new flags affect the API (some are client-side only). The following PR's added new flags to docker 1.13 that affect the API; - moby/moby#23430 added `--cpu-rt-period`and `--cpu-rt-runtime` - moby/moby#27800 / moby/moby#25317 added `--group` / `--group-add` / `--group-rm` - moby/moby#27702 added `--network` to `docker build` - moby/moby#25962 added `--attachable` to `docker network create` - moby/moby#27998 added `--compose-file` to `docker stack deploy` - moby/moby#22566 added `--stop-timeout` to `docker run` and `docker create` - moby/moby#26061 added `--init` to `docker run` and `docker create` - moby/moby#26941 added `--init-path` to `docker run` and `docker create` - moby/moby#27958 added `--cpus` on `docker run` / `docker create` - moby/moby#27567 added `--dns`, `--dns-opt`, and `--dns-search` to `docker service create` - moby/moby#27596 added `--force` to `docker service update` - moby/moby#27857 added `--hostname` to `docker service create` - moby/moby#28031 added `--hosts`, `--host-add` / `--host-rm` to `docker service create` and `docker service update` - moby/moby#28076 added `--tty` on `docker service create` / `docker service update` - moby/moby#26421 added `--update-max-failure-ratio`, `--update-monitor` and `--rollback` on `docker service update` - moby/moby#27369 added `--health-cmd`, `--health-interval`, `--health-retries`, `--health-timeout` and `--no-healthcheck` options to `docker service create` and `docker service update` Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 5d2722f83db9e301c6dcbe1c562c2051a52905db Component: cli
- What I did
This fix tries to address #27902 by adding a flag
--hosttodocker service createand--host-add/--host-rmtodocker service update, so that it is possible to specify extrahost:ipsettings in/etc/hosts.NOTE:
The flag
--add-hostis to conform todocker runbut other suggestions are welcomed.No flag has been added to
docker service updateyet, as I am not sure about what flag should be added foradd/rmcase.- How I did it
This fix adds
Hostsin swarmkit'sContainerSpecso that it is possible to specify extra hosts during service creation.Related docs has been updated.
- How to verify it
An integration test has been added.
- Description for the changelog
Add flag
--add-hosttodocker service createso that extra host to ip mappings could be added to/etc/hosts.- A picture of a cute animal (not mandatory but encouraged)
This fix fixes #27902.