Kaydet (Commit) f2c1ae37 authored tarafından Joffrey F's avatar Joffrey F Kaydeden (comit) Joffrey F

Fix session timeout = None case

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 2454e810
......@@ -1018,9 +1018,10 @@ class ContainerApiMixin(object):
"""
params = {'t': timeout}
url = self._url("/containers/{0}/restart", container)
res = self._post(
url, params=params, timeout=timeout + (self.timeout or 0)
)
conn_timeout = self.timeout
if conn_timeout is not None:
conn_timeout += timeout
res = self._post(url, params=params, timeout=conn_timeout)
self._raise_for_status(res)
@utils.check_resource('container')
......@@ -1110,11 +1111,9 @@ class ContainerApiMixin(object):
params = {'t': timeout}
url = self._url("/containers/{0}/stop", container)
conn_timeout = self.timeout
if conn_timeout:
conn_timeout = max(conn_timeout, timeout + 15)
res = self._post(
url, params=params, timeout=timeout + (self.timeout or 0)
)
if conn_timeout is not None:
conn_timeout += timeout
res = self._post(url, params=params, timeout=conn_timeout)
self._raise_for_status(res)
@utils.check_resource('container')
......
......@@ -1165,16 +1165,14 @@ class RestartContainerTest(BaseAPIIntegrationTest):
assert info2['State']['Running'] is True
self.client.kill(id)
def test_restart_with_high_timeout(self):
def test_restart_with_low_timeout(self):
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
id = container['Id']
self.client.start(id)
self.client.start(container)
self.client.timeout = 1
self.client.restart(id, timeout=3)
self.client.restart(container, timeout=3)
self.client.timeout = None
self.client.restart(id, timeout=3)
self.client.timeout = 1
self.client.stop(id, timeout=3)
self.client.restart(container, timeout=3)
self.client.kill(container)
def test_restart_with_dict_instead_of_id(self):
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment