-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Add config parameter to change per-container stop timeout during daemon shutdown #22566
Add config parameter to change per-container stop timeout during daemon shutdown #22566
Conversation
Will this option match the corresponding |
@pataquets Yes if the option is passed with |
I'm wondering if this should be a daemon level option, or something that should be specified per container (thinking of the I like the simplicity of this PR, just thinking out loud if the timeout should be applied to all containers, or only to specific ones. |
I think restarts without container stops(in 1.12) will deprecate this. |
@LK4D4 that was mentioned in the issue, but it likely won't help if the service has to be stopped, or a server rebooted |
@thaJeztah @LK4D4 Thanks for the review. In the existing docker code, the timeout of container stop before SIGKILL during the shutdown is controlled by two places:
When a shutdown of daemon is issued, the daemon will:
There are potentially two variables. One is the timeout (10s) for each container to stop (with SIGTERM) before send SIGKILL. The other is the timeout (15s) for daemon to exit. In this PR, there is only one variable I think the Any suggestions would be appreciated. |
I think this makes sense (regardless of the potential ability for 1.12 to restart the daemon without restarting containers). Every such PR makes me think we should really stop adding command line flags and support a configuration file only... |
d5e1c04
to
d8d49a3
Compare
@thaJeztah @LK4D4 @icecrime To implement a
I will move forward to implement the above items and update the PR. In the meantime, please let me know if you have any suggestions or feedbacks. |
Perhaps we can combine |
21b2fcd
to
0862031
Compare
@thaJeztah @LK4D4 @icecrime I updated the PR and now The Note: we cannot use One thing I am not so sure is about how to deal with If we want to respect the
Any suggestion suggestions or feedbacks on how to deal with |
It may be nice to combine this with --start-timeout, per #22226 |
|
||
// Test case for #22471 | ||
func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *check.C) { | ||
testRequires(c, SameHostDaemon, DaemonIsLinux) |
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.
Why Linux only?
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.
@jhowardmsft Thanks for point that out. I will update the PR to cover Windows as well.
We just discussed this; and there's more people that like having a separate flag for Also we'd like to have the per-container feature first, and a separate PR for the default (daemon) option. |
0862031
to
3276329
Compare
Thanks @thaJeztah @jhowardmsft I split the pull request into two. This pull request will cover the 'per-container' stop timeout case and the pull request #23036 will cover daemon timeout case. Please let me know if there are any issues. |
Thanks @yongtang! I'm moving this to code review |
Thanks @vdemeester. The pull request has been rebased. |
ch := make(chan struct{}) | ||
go func() { | ||
d.Shutdown() | ||
close(ch) | ||
}() | ||
if shutdownTimeout < 0 { |
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.
why would this be < 0
?
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.
@cpuguy83 If it is < 0
then we will wait until daemon is shutdown (no timeout).
@yongtang needs another rebase 😓 |
09abc2f
to
90aedbd
Compare
Thanks @vdemeester, rebased. |
90aedbd
to
45c5cf5
Compare
LGTM, but this PR needs yet another rebase for the docs 😅 |
…on shutdown This fix tries to add a flag `--stop-timeout` to specify the timeout value (in seconds) for the container to stop before SIGKILL is issued. If stop timeout is not specified then the default timeout (10s) is used. Additional test cases have been added to cover the change. This fix is related to moby#22471. Another pull request will add `--shutdown-timeout` to daemon for moby#22471. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
…eout and use the one specified at container creation time. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
45c5cf5
to
cc70378
Compare
Thanks @mlaventure for the review. The PR has been rebased and updated. Please let me know if there are any other issues 😅 . |
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.
docs LGTM, thanks!
ping @albers @sdurrheimer for completion scripts ❤️
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 🐸
🎉 yeah! Sorry it took so long @yongtang - thanks so much! |
Thanks all for the review and help! |
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>
…eout Add config parameter to change per-container stop timeout during daemon shutdown
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 add a flag
--stop-timeout
to specify the timeout value (in seconds) for the container to stop before SIGKILL is issued. If stop timeout is not specified then the default timeout (10s) is used.- How I did it
The
--stop-timeout
has been added todocker create
anddocker run
.- How to verify it
Additional test cases have been added to cover the change.
- Description for the changelog
Added a lag
--stop-timeout
to specify the timeout value (in seconds) for the container to stop.- A picture of a cute animal (not mandatory but encouraged)
This fix is related to #22471.
NOTE: Pull requests have been created in engine-api:
docker/engine-api#256
docker/engine-api#271
NOTE: Another pull request (#23036) has been opened to add
--shutdown-timeout
to daemonSigned-off-by: Yong Tang yong.tang.github@outlook.com