Skip to content

Commit 2454e81

Browse files
committed
Total timeout should be HTTP timeout + operation timeout
Signed-off-by: Joffrey F <[email protected]>
1 parent 1848d2c commit 2454e81

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

docker/api/container.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,10 +1018,9 @@ def restart(self, container, timeout=10):
10181018
"""
10191019
params = {'t': timeout}
10201020
url = self._url("/containers/{0}/restart", container)
1021-
conn_timeout = self.timeout
1022-
if conn_timeout:
1023-
conn_timeout = max(conn_timeout, timeout+15)
1024-
res = self._post(url, params=params, timeout=conn_timeout)
1021+
res = self._post(
1022+
url, params=params, timeout=timeout + (self.timeout or 0)
1023+
)
10251024
self._raise_for_status(res)
10261025

10271026
@utils.check_resource('container')
@@ -1113,8 +1112,9 @@ def stop(self, container, timeout=None):
11131112
conn_timeout = self.timeout
11141113
if conn_timeout:
11151114
conn_timeout = max(conn_timeout, timeout + 15)
1116-
res = self._post(url, params=params,
1117-
timeout=conn_timeout)
1115+
res = self._post(
1116+
url, params=params, timeout=timeout + (self.timeout or 0)
1117+
)
11181118
self._raise_for_status(res)
11191119

11201120
@utils.check_resource('container')

tests/integration/api_container_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ def test_restart(self):
11651165
assert info2['State']['Running'] is True
11661166
self.client.kill(id)
11671167

1168-
def test_restart_with_hight_timeout(self):
1168+
def test_restart_with_high_timeout(self):
11691169
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
11701170
id = container['Id']
11711171
self.client.start(id)

tests/unit/api_container_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def test_stop_container(self):
12641264
'POST',
12651265
url_prefix + 'containers/3cc2351ab11b/stop',
12661266
params={'t': timeout},
1267-
timeout=(DEFAULT_TIMEOUT_SECONDS)
1267+
timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
12681268
)
12691269

12701270
def test_stop_container_with_dict_instead_of_id(self):
@@ -1277,7 +1277,7 @@ def test_stop_container_with_dict_instead_of_id(self):
12771277
'POST',
12781278
url_prefix + 'containers/3cc2351ab11b/stop',
12791279
params={'t': timeout},
1280-
timeout=(DEFAULT_TIMEOUT_SECONDS)
1280+
timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
12811281
)
12821282

12831283
def test_pause_container(self):
@@ -1335,7 +1335,7 @@ def test_restart_container(self):
13351335
'POST',
13361336
url_prefix + 'containers/3cc2351ab11b/restart',
13371337
params={'t': 2},
1338-
timeout=DEFAULT_TIMEOUT_SECONDS
1338+
timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
13391339
)
13401340

13411341
def test_restart_container_with_dict_instead_of_id(self):
@@ -1345,7 +1345,7 @@ def test_restart_container_with_dict_instead_of_id(self):
13451345
'POST',
13461346
url_prefix + 'containers/3cc2351ab11b/restart',
13471347
params={'t': 2},
1348-
timeout=DEFAULT_TIMEOUT_SECONDS
1348+
timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
13491349
)
13501350

13511351
def test_remove_container(self):

0 commit comments

Comments
 (0)