Fix misleading default for `--replicas`

This fix tries to address the issue raised in 29291 where
the output of `--replicas` in `service create/update`:
```
      --replicas uint                    Number of tasks (default none)
```
is misleading. User might incorrectly assume the number of replicas
would be `0` (`none`) by default, while the actual default is `1`.

The issue comes from the fact that some of the default values are
from daemon and it is not possible for client to find out the default
value.

In this case, it might be better to just simply not displaying `(default none)`.

This fix returns "" for `Uint64Opt` so that `(default none)` is hidden.

In addition to `--replicas`, this fix also changes
`--restart-delay`, `--restart-max-attempts`, `--stop-grace-period`,
`--health-interval`, `--health-timeout`, and `--restart-window`
in a similiar fashion.

New Output:
```
      --health-interval duration         Time between running the check (ns|us|ms|s|m|h)
      --health-timeout duration          Maximum time to allow one check to run (ns|us|ms|s|m|h)
...
      --replicas uint                    Number of tasks
...
      --restart-delay duration           Delay between restart attempts (ns|us|ms|s|m|h)
      --restart-max-attempts uint        Maximum number of restarts before giving up
      --restart-window duration          Window used to evaluate the restart policy (ns|us|ms|s|m|h)
...
      --stop-grace-period duration       Time to wait before force killing a container (ns|us|ms|s|m|h)
```

The docs has been updated. Note the docs for help output of `service create/update`
is out of sync with the current master. This fix replace with the update-to-date
help output.

This fix fixes 29291.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2016-12-15 06:12:33 -08:00 committed by Tibor Vass
parent 1b85eea07d
commit 87b4281f62
2 changed files with 19 additions and 19 deletions

View File

@ -31,9 +31,9 @@ Options:
--env-file list Read in a file of environment variables (default []) --env-file list Read in a file of environment variables (default [])
--group list Set one or more supplementary user groups for the container (default []) --group list Set one or more supplementary user groups for the container (default [])
--health-cmd string Command to run to check health --health-cmd string Command to run to check health
--health-interval duration Time between running the check (ns|us|ms|s|m|h) (default none) --health-interval duration Time between running the check (ns|us|ms|s|m|h)
--health-retries int Consecutive failures needed to report unhealthy --health-retries int Consecutive failures needed to report unhealthy
--health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default none) --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h)
--help Print usage --help Print usage
--host list Set one or more custom host-to-IP mappings (host:ip) (default []) --host list Set one or more custom host-to-IP mappings (host:ip) (default [])
--hostname string Container hostname --hostname string Container hostname
@ -47,16 +47,16 @@ Options:
--name string Service name --name string Service name
--network list Network attachments (default []) --network list Network attachments (default [])
--no-healthcheck Disable any container-specified HEALTHCHECK --no-healthcheck Disable any container-specified HEALTHCHECK
-p, --publish list Publish a port as a node port (default []) -p, --publish port Publish a port as a node port
--replicas uint Number of tasks (default none) --replicas uint Number of tasks
--reserve-cpu decimal Reserve CPUs (default 0.000) --reserve-cpu decimal Reserve CPUs (default 0.000)
--reserve-memory bytes Reserve Memory (default 0 B) --reserve-memory bytes Reserve Memory (default 0 B)
--restart-condition string Restart when condition is met (none, on-failure, or any) --restart-condition string Restart when condition is met (none, on-failure, or any)
--restart-delay duration Delay between restart attempts (ns|us|ms|s|m|h) (default none) --restart-delay duration Delay between restart attempts (ns|us|ms|s|m|h)
--restart-max-attempts uint Maximum number of restarts before giving up (default none) --restart-max-attempts uint Maximum number of restarts before giving up
--restart-window duration Window used to evaluate the restart policy (ns|us|ms|s|m|h) (default none) --restart-window duration Window used to evaluate the restart policy (ns|us|ms|s|m|h)
--secret value Specify secrets to expose to the service (default []) --secret secret Specify secrets to expose to the service
--stop-grace-period duration Time to wait before force killing a container (ns|us|ms|s|m|h) (default none) --stop-grace-period duration Time to wait before force killing a container (ns|us|ms|s|m|h)
-t, --tty Allocate a pseudo-TTY -t, --tty Allocate a pseudo-TTY
--update-delay duration Delay between updates (ns|us|ms|s|m|h) (default 0s) --update-delay duration Delay between updates (ns|us|ms|s|m|h) (default 0s)
--update-failure-action string Action on update failure (pause|continue) (default "pause") --update-failure-action string Action on update failure (pause|continue) (default "pause")

View File

@ -39,9 +39,9 @@ Options:
--group-add list Add an additional supplementary user group to the container (default []) --group-add list Add an additional supplementary user group to the container (default [])
--group-rm list Remove a previously added supplementary user group from the container (default []) --group-rm list Remove a previously added supplementary user group from the container (default [])
--health-cmd string Command to run to check health --health-cmd string Command to run to check health
--health-interval duration Time between running the check (ns|us|ms|s|m|h) (default none) --health-interval duration Time between running the check (ns|us|ms|s|m|h)
--health-retries int Consecutive failures needed to report unhealthy --health-retries int Consecutive failures needed to report unhealthy
--health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default none) --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h)
--help Print usage --help Print usage
--host-add list Add or update a custom host-to-IP mapping (host:ip) (default []) --host-add list Add or update a custom host-to-IP mapping (host:ip) (default [])
--host-rm list Remove a custom host-to-IP mapping (host:ip) (default []) --host-rm list Remove a custom host-to-IP mapping (host:ip) (default [])
@ -56,19 +56,19 @@ Options:
--mount-add mount Add or update a mount on a service --mount-add mount Add or update a mount on a service
--mount-rm list Remove a mount by its target path (default []) --mount-rm list Remove a mount by its target path (default [])
--no-healthcheck Disable any container-specified HEALTHCHECK --no-healthcheck Disable any container-specified HEALTHCHECK
--publish-add list Add or update a published port (default []) --publish-add port Add or update a published port
--publish-rm list Remove a published port by its target port (default []) --publish-rm port Remove a published port by its target port
--replicas uint Number of tasks (default none) --replicas uint Number of tasks
--reserve-cpu decimal Reserve CPUs (default 0.000) --reserve-cpu decimal Reserve CPUs (default 0.000)
--reserve-memory bytes Reserve Memory (default 0 B) --reserve-memory bytes Reserve Memory (default 0 B)
--restart-condition string Restart when condition is met (none, on-failure, or any) --restart-condition string Restart when condition is met (none, on-failure, or any)
--restart-delay duration Delay between restart attempts (ns|us|ms|s|m|h) (default none) --restart-delay duration Delay between restart attempts (ns|us|ms|s|m|h)
--restart-max-attempts uint Maximum number of restarts before giving up (default none) --restart-max-attempts uint Maximum number of restarts before giving up
--restart-window duration Window used to evaluate the restart policy (ns|us|ms|s|m|h) (default none) --restart-window duration Window used to evaluate the restart policy (ns|us|ms|s|m|h)
--rollback Rollback to previous specification --rollback Rollback to previous specification
--secret-add list Add a secret (default []) --secret-add secret Add or update a secret on a service
--secret-rm list Remove a secret (default []) --secret-rm list Remove a secret (default [])
--stop-grace-period duration Time to wait before force killing a container (ns|us|ms|s|m|h) (default none) --stop-grace-period duration Time to wait before force killing a container (ns|us|ms|s|m|h)
-t, --tty Allocate a pseudo-TTY -t, --tty Allocate a pseudo-TTY
--update-delay duration Delay between updates (ns|us|ms|s|m|h) (default 0s) --update-delay duration Delay between updates (ns|us|ms|s|m|h) (default 0s)
--update-failure-action string Action on update failure (pause|continue) (default "pause") --update-failure-action string Action on update failure (pause|continue) (default "pause")