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

Total timeout should be HTTP timeout + operation timeout

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 1848d2c9
...@@ -1018,10 +1018,9 @@ class ContainerApiMixin(object): ...@@ -1018,10 +1018,9 @@ class ContainerApiMixin(object):
""" """
params = {'t': timeout} params = {'t': timeout}
url = self._url("/containers/{0}/restart", container) url = self._url("/containers/{0}/restart", container)
conn_timeout = self.timeout res = self._post(
if conn_timeout: url, params=params, timeout=timeout + (self.timeout or 0)
conn_timeout = max(conn_timeout, timeout+15) )
res = self._post(url, params=params, timeout=conn_timeout)
self._raise_for_status(res) self._raise_for_status(res)
@utils.check_resource('container') @utils.check_resource('container')
...@@ -1113,8 +1112,9 @@ class ContainerApiMixin(object): ...@@ -1113,8 +1112,9 @@ class ContainerApiMixin(object):
conn_timeout = self.timeout conn_timeout = self.timeout
if conn_timeout: if conn_timeout:
conn_timeout = max(conn_timeout, timeout + 15) conn_timeout = max(conn_timeout, timeout + 15)
res = self._post(url, params=params, res = self._post(
timeout=conn_timeout) url, params=params, timeout=timeout + (self.timeout or 0)
)
self._raise_for_status(res) self._raise_for_status(res)
@utils.check_resource('container') @utils.check_resource('container')
......
...@@ -1165,7 +1165,7 @@ class RestartContainerTest(BaseAPIIntegrationTest): ...@@ -1165,7 +1165,7 @@ class RestartContainerTest(BaseAPIIntegrationTest):
assert info2['State']['Running'] is True assert info2['State']['Running'] is True
self.client.kill(id) self.client.kill(id)
def test_restart_with_hight_timeout(self): def test_restart_with_high_timeout(self):
container = self.client.create_container(BUSYBOX, ['sleep', '9999']) container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
id = container['Id'] id = container['Id']
self.client.start(id) self.client.start(id)
......
...@@ -1264,7 +1264,7 @@ class ContainerTest(BaseAPIClientTest): ...@@ -1264,7 +1264,7 @@ class ContainerTest(BaseAPIClientTest):
'POST', 'POST',
url_prefix + 'containers/3cc2351ab11b/stop', url_prefix + 'containers/3cc2351ab11b/stop',
params={'t': timeout}, params={'t': timeout},
timeout=(DEFAULT_TIMEOUT_SECONDS) timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
) )
def test_stop_container_with_dict_instead_of_id(self): def test_stop_container_with_dict_instead_of_id(self):
...@@ -1277,7 +1277,7 @@ class ContainerTest(BaseAPIClientTest): ...@@ -1277,7 +1277,7 @@ class ContainerTest(BaseAPIClientTest):
'POST', 'POST',
url_prefix + 'containers/3cc2351ab11b/stop', url_prefix + 'containers/3cc2351ab11b/stop',
params={'t': timeout}, params={'t': timeout},
timeout=(DEFAULT_TIMEOUT_SECONDS) timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
) )
def test_pause_container(self): def test_pause_container(self):
...@@ -1335,7 +1335,7 @@ class ContainerTest(BaseAPIClientTest): ...@@ -1335,7 +1335,7 @@ class ContainerTest(BaseAPIClientTest):
'POST', 'POST',
url_prefix + 'containers/3cc2351ab11b/restart', url_prefix + 'containers/3cc2351ab11b/restart',
params={'t': 2}, params={'t': 2},
timeout=DEFAULT_TIMEOUT_SECONDS timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
) )
def test_restart_container_with_dict_instead_of_id(self): def test_restart_container_with_dict_instead_of_id(self):
...@@ -1345,7 +1345,7 @@ class ContainerTest(BaseAPIClientTest): ...@@ -1345,7 +1345,7 @@ class ContainerTest(BaseAPIClientTest):
'POST', 'POST',
url_prefix + 'containers/3cc2351ab11b/restart', url_prefix + 'containers/3cc2351ab11b/restart',
params={'t': 2}, params={'t': 2},
timeout=DEFAULT_TIMEOUT_SECONDS timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
) )
def test_remove_container(self): def test_remove_container(self):
......
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