-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Add version annotation to various flags added in 1.13 #30186
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
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>
@@ -236,9 +236,12 @@ func addFlags(flags *pflag.FlagSet) *containerOptions { | |||
flags.Int64Var(&copts.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period") | |||
flags.Int64Var(&copts.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota") | |||
flags.Int64Var(&copts.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit CPU real-time period in microseconds") | |||
flags.SetAnnotation("cpu-rt-period", "version", []string{"1.25"}) |
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.
Wondering if we should add a utility for this, or to specify the version when adding flags (this does the job, but it's rather ugly to have these SetAnnotation()
everywhere.
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.
We could have a util and group the flags by version:
SetFlagVersion(flags, "1.25", "cpu-rt-period", "cpu-rt-runtime", "cpus", "init", "init-path")
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.
Yes I considered putting all the annotations at the end (looking a bit cleaner), but decided keeping them together with the flag also has it's advantages.
Ideally, something like this;
flags.Var(&copts.foo, "foo", "Set foo option", flagAnnotation{"version", "1.25"}, flagAnnotation{"platform", "windows"})
or
flags.Var(&copts.foo, "foo", "Set foo option").Annotate("version", "1.25").Annotate("platform", "windows")
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.
We'll have to fork pflag
to make that kind of change, but that's fine with me. Having the flag Vars return the object would be a good idea.
However many of these lines are already too long, so I don't know that adding more to the line is an improvement.
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.
LGTM
@@ -236,9 +236,12 @@ func addFlags(flags *pflag.FlagSet) *containerOptions { | |||
flags.Int64Var(&copts.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period") | |||
flags.Int64Var(&copts.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota") | |||
flags.Int64Var(&copts.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit CPU real-time period in microseconds") | |||
flags.SetAnnotation("cpu-rt-period", "version", []string{"1.25"}) |
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.
We could have a util and group the flags by version:
SetFlagVersion(flags, "1.25", "cpu-rt-period", "cpu-rt-runtime", "cpus", "init", "init-path")
LGTM |
…o-flags Add version annotation to various flags added in 1.13
Pull request #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;
--cpu-rt-period
and--cpu-rt-runtime
--group
indocker service create
#25317 added--group
/--group-add
/--group-rm
--network
todocker build
--attachable
todocker network create
docker stack deploy
from a Compose file #27998 added--compose-file
todocker stack deploy
--stop-timeout
todocker run
anddocker create
--init
todocker run
anddocker create
--init-path
todocker run
anddocker create
--cpus
flag to control cpu resources #27958 added--cpus
ondocker run
/docker create
--dns
,--dns-opt
, and--dns-search
todocker service create
--force
todocker service update
--hostname
todocker service create
--host
toservice create
and--host-add/rm
toservice update
#28031 added--hosts
,--host-add
/--host-rm
todocker service create
anddocker service update
--tty
todocker service create/update
#28076 added--tty
ondocker service create
/docker service update
--update-max-failure-ratio
,--update-monitor
and--rollback
ondocker service update
--health-cmd
,--health-interval
,--health-retries
,--health-timeout
and--no-healthcheck
options todocker service create
anddocker service update
- How to verify it
Verify that the correct flags are hidden when overriding the API version. For example;
Without
DOCKER_API_VERSION
;And with
DOCKER_API_VERSION
;- Description for the changelog
--help
output