Add force option to service update

Currently, there's no way to restart the tasks of a service without
making an actual change to the service. This leads to us giving awkward
workarounds as in
https://github.com/docker/docker.github.io/pull/178/files, where we tell
people to scale a service up and down to restore balance, or make
unnecessary changes to trigger a restart.

This change adds a --force option to "docker service update", which
forces the service to be updated even if no changes require that.

Since rolling update parameters are respected, the user can use
"docker service --force" to do a rolling restart. For example, the
following is supported:

   docker service update --force --update-parallelism 2 \
   --update-delay 5s myservice

Since the default value of --update-parallelism is 1, the default
behavior is to restart the service one task at a time.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: c9fdf9abf8d6443598808809b900d96e04adfcb1
Component: engine
This commit is contained in:
Aaron Lehmann
2016-10-20 12:04:01 -07:00
parent accc5bf3d7
commit 39b84d5fbe
8 changed files with 50 additions and 6 deletions

View File

@ -139,6 +139,7 @@ This section lists each version from latest to oldest. Each listing includes a
containers that are tasks (part of a service in swarm mode).
* `POST /containers/create` now takes `StopTimeout` field.
* `POST /services/create` and `POST /services/(id or name)/update` now accept `Monitor` and `MaxFailureRatio` parameters, which control the response to failures during service updates.
* `POST /services/(id or name)/update` now accepts a `ForceUpdate` parameter inside the `TaskTemplate`, which causes the service to be updated even if there are no changes which would ordinarily trigger an update.
* `GET /networks/(name)` now returns field `Created` in response to show network created time.
* `POST /containers/(id or name)/exec` now accepts an `Env` field, which holds a list of environment variables to be set in the context of the command execution.
* `GET /volumes`, `GET /volumes/(name)`, and `POST /volumes/create` now return the `Options` field which holds the driver specific options to use for when creating the volume.

View File

@ -4915,7 +4915,8 @@ List services
"Condition": "any",
"MaxAttempts": 0
},
"Placement": {}
"Placement": {},
"ForceUpdate": 0
},
"Mode": {
"Replicated": {
@ -5038,7 +5039,8 @@ image](#create-an-image) section for more details.
"Condition": "on-failure",
"Delay": 10000000000.0,
"MaxAttempts": 10
}
},
"ForceUpdate": 0
},
"Mode": {
"Replicated": {
@ -5132,6 +5134,7 @@ image](#create-an-image) section for more details.
- **Window** Windows is the time window used to evaluate the restart policy (default value is
0, which is unbounded).
- **Placement** An array of constraints.
- **ForceUpdate**: A counter that triggers an update even if no relevant parameters have been changed.
- **Mode** Scheduling mode for the service (`replicated` or `global`, defaults to `replicated`).
- **UpdateConfig** Specification for the update strategy of the service.
- **Parallelism** Maximum number of tasks to be updated in one iteration (0 means unlimited
@ -5303,7 +5306,8 @@ image](#create-an-image) section for more details.
"Condition": "any",
"MaxAttempts": 0
},
"Placement": {}
"Placement": {},
"ForceUpdate": 0
},
"Mode": {
"Replicated": {
@ -5374,6 +5378,7 @@ image](#create-an-image) section for more details.
- **Window** Windows is the time window used to evaluate the restart policy (default value is
0, which is unbounded).
- **Placement** An array of constraints.
- **ForceUpdate**: A counter that triggers an update even if no relevant parameters have been changed.
- **Mode** Scheduling mode for the service (`replicated` or `global`, defaults to `replicated`).
- **UpdateConfig** Specification for the update strategy of the service.
- **Parallelism** Maximum number of tasks to be updated in one iteration (0 means unlimited