providers/docker: stop_timeout [GH-4504]
This commit is contained in:
parent
e749eaa039
commit
9d4ab18f42
|
@ -1,5 +1,10 @@
|
|||
## 1.7.0 (unreleased)
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
- providers/docker: `stop_timeout` can be used to modify the `docker stop`
|
||||
timeout. [GH-4504]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- core: Fix cases where sometimes SSH connection would hang.
|
||||
|
|
|
@ -11,7 +11,7 @@ module VagrantPlugins
|
|||
driver = machine.provider.driver
|
||||
if driver.running?(machine.id)
|
||||
env[:ui].info I18n.t("docker_provider.messages.stopping")
|
||||
driver.stop(machine.id)
|
||||
driver.stop(machine.id, machine.provider_config.stop_timeout)
|
||||
end
|
||||
@app.call(env)
|
||||
end
|
||||
|
|
|
@ -61,6 +61,12 @@ module VagrantPlugins
|
|||
# @return [Boolean]
|
||||
attr_accessor :remains_running
|
||||
|
||||
# The time to wait before sending a SIGTERM to the container
|
||||
# when it is stopped.
|
||||
#
|
||||
# @return [Integer]
|
||||
attr_accessor :stop_timeout
|
||||
|
||||
# The name of the machine in the Vagrantfile set with
|
||||
# "vagrant_vagrantfile" that will be the docker host. Defaults
|
||||
# to "default"
|
||||
|
@ -99,6 +105,7 @@ module VagrantPlugins
|
|||
@ports = UNSET_VALUE
|
||||
@privileged = UNSET_VALUE
|
||||
@remains_running = UNSET_VALUE
|
||||
@stop_timeout = UNSET_VALUE
|
||||
@volumes = []
|
||||
@vagrant_machine = UNSET_VALUE
|
||||
@vagrant_vagrantfile = UNSET_VALUE
|
||||
|
@ -151,6 +158,7 @@ module VagrantPlugins
|
|||
@ports = [] if @ports == UNSET_VALUE
|
||||
@privileged = false if @privileged == UNSET_VALUE
|
||||
@remains_running = true if @remains_running == UNSET_VALUE
|
||||
@stop_timeout = 1 if @stop_timeout == UNSET_VALUE
|
||||
@vagrant_machine = nil if @vagrant_machine == UNSET_VALUE
|
||||
@vagrant_vagrantfile = nil if @vagrant_vagrantfile == UNSET_VALUE
|
||||
|
||||
|
|
|
@ -95,9 +95,9 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
def stop(cid)
|
||||
def stop(cid, timeout)
|
||||
if running?(cid)
|
||||
execute('docker', 'stop', '-t', '1', cid)
|
||||
execute('docker', 'stop', '-t', timeout.to_s, cid)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ describe VagrantPlugins::DockerProvider::Config do
|
|||
its(:image) { should be_nil }
|
||||
its(:name) { should be_nil }
|
||||
its(:privileged) { should be_false }
|
||||
its(:stop_timeout) { should eq(1) }
|
||||
its(:vagrant_machine) { should be_nil }
|
||||
its(:vagrant_vagrantfile) { should be_nil }
|
||||
end
|
||||
|
|
|
@ -62,6 +62,9 @@ you may set. A complete reference is shown below.
|
|||
of time. If false, then Vagrant expects that this container will
|
||||
automatically stop at some point, and won't error if it sees it do that.
|
||||
|
||||
* `stop_timeout` (integer) - The amount of time to wait when stopping
|
||||
a container before sending a SIGTERM to the process.
|
||||
|
||||
* `vagrant_machine` (string) - The name of the Vagrant machine in the
|
||||
`vagrant_vagrantfile` to use as the host machine. This defaults to
|
||||
"default".
|
||||
|
|
Loading…
Reference in New Issue