diff --git a/compose/service.py b/compose/service.py index 14027a1cc..245d5f7c7 100644 --- a/compose/service.py +++ b/compose/service.py @@ -14,8 +14,8 @@ from docker.errors import APIError from docker.errors import ImageNotFound from docker.errors import NotFound from docker.types import LogConfig -from docker.utils import version_lt from docker.utils import version_gte +from docker.utils import version_lt from docker.utils.ports import build_port_bindings from docker.utils.ports import split_port from docker.utils.utils import convert_tmpfs_mounts @@ -763,8 +763,7 @@ class Service(object): if (version_gte(self.client.api_version, '1.25') and 'stop_grace_period' in self.options): - container_options['stop_timeout'] = parse_seconds_float( - self.options.pop('stop_grace_period')) + container_options['stop_timeout'] = self.stop_timeout(None) if 'ports' in container_options or 'expose' in self.options: container_options['ports'] = build_container_ports( diff --git a/tests/unit/service_test.py b/tests/unit/service_test.py index 02b4f6223..4c879cae7 100644 --- a/tests/unit/service_test.py +++ b/tests/unit/service_test.py @@ -228,6 +228,17 @@ class ServiceTest(unittest.TestCase): {'Type': 'syslog', 'Config': {'syslog-address': 'tcp://192.168.0.42:123'}} ) + def test_stop_grace_period(self): + self.mock_client.api_version = '1.25' + self.mock_client.create_host_config.return_value = {} + service = Service( + 'foo', + image='foo', + client=self.mock_client, + stop_grace_period="1m35s") + opts = service._get_container_create_options({'image': 'foo'}, 1) + self.assertEqual(opts['stop_timeout'], 95) + def test_split_domainname_none(self): service = Service( 'foo',