From cd441793052a4c216bf2942c3b8e4687f965c672 Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Wed, 15 Jul 2015 17:30:31 +0100 Subject: [PATCH 1/3] Merge pull request #1705 from aanand/fix-labels-null Handle case where /containers/json returns "Labels": null (cherry picked from commit 7b9664be8e82b03f316d88c928953c62e897c2cd) Signed-off-by: Aanand Prasad --- compose/legacy.py | 2 +- tests/integration/legacy_test.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/compose/legacy.py b/compose/legacy.py index c9ec658178..6fbf74d692 100644 --- a/compose/legacy.py +++ b/compose/legacy.py @@ -149,7 +149,7 @@ def _get_legacy_containers_iter( for service in services: for container in containers: - if LABEL_VERSION in container['Labels']: + if LABEL_VERSION in (container.get('Labels') or {}): continue name = get_container_name(container) diff --git a/tests/integration/legacy_test.py b/tests/integration/legacy_test.py index 806b9a457d..f79089b207 100644 --- a/tests/integration/legacy_test.py +++ b/tests/integration/legacy_test.py @@ -1,4 +1,5 @@ import unittest +from mock import Mock from docker.errors import APIError @@ -64,6 +65,22 @@ class UtilitiesTestCase(unittest.TestCase): legacy.is_valid_name("composetest_web_lol_1", one_off=True), ) + def test_get_legacy_containers_no_labels(self): + client = Mock() + client.containers.return_value = [ + { + "Id": "abc123", + "Image": "def456", + "Name": "composetest_web_1", + "Labels": None, + }, + ] + + containers = list(legacy.get_legacy_containers( + client, "composetest", ["web"])) + + self.assertEqual(len(containers), 1) + class LegacyTestCase(DockerClientTestCase): From e5f6ae767d78a2213eac2d52bade3dfdfe620730 Mon Sep 17 00:00:00 2001 From: Mazz Mosley Date: Thu, 16 Jul 2015 10:50:06 +0100 Subject: [PATCH 2/3] Merge pull request #1704 from aanand/fix-timeout-type Make sure up/restart/stop timeout is an int (cherry picked from commit c7dccccd1fa4dc2fe6f65d4a839a16567adbee9d) Signed-off-by: Aanand Prasad --- compose/cli/main.py | 6 +++--- tests/integration/state_test.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index d5d15177c0..ba44457350 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -403,7 +403,7 @@ class TopLevelCommand(Command): -t, --timeout TIMEOUT Specify a shutdown timeout in seconds. (default: 10) """ - timeout = float(options.get('--timeout') or DEFAULT_TIMEOUT) + timeout = int(options.get('--timeout') or DEFAULT_TIMEOUT) project.stop(service_names=options['SERVICE'], timeout=timeout) def restart(self, project, options): @@ -416,7 +416,7 @@ class TopLevelCommand(Command): -t, --timeout TIMEOUT Specify a shutdown timeout in seconds. (default: 10) """ - timeout = float(options.get('--timeout') or DEFAULT_TIMEOUT) + timeout = int(options.get('--timeout') or DEFAULT_TIMEOUT) project.restart(service_names=options['SERVICE'], timeout=timeout) def up(self, project, options): @@ -459,7 +459,7 @@ class TopLevelCommand(Command): allow_recreate = not options['--no-recreate'] smart_recreate = options['--x-smart-recreate'] service_names = options['SERVICE'] - timeout = float(options.get('--timeout') or DEFAULT_TIMEOUT) + timeout = int(options.get('--timeout') or DEFAULT_TIMEOUT) project.up( service_names=service_names, diff --git a/tests/integration/state_test.py b/tests/integration/state_test.py index 95fcc49de5..fb91bc2495 100644 --- a/tests/integration/state_test.py +++ b/tests/integration/state_test.py @@ -13,7 +13,7 @@ from .testcases import DockerClientTestCase class ProjectTestCase(DockerClientTestCase): def run_up(self, cfg, **kwargs): kwargs.setdefault('smart_recreate', True) - kwargs.setdefault('timeout', 0.1) + kwargs.setdefault('timeout', 1) project = self.make_project(cfg) project.up(**kwargs) @@ -171,7 +171,7 @@ def converge(service, plan, insecure_registry=insecure_registry, do_build=do_build, - timeout=0.1, + timeout=1, ) From 8cff440800a6098eba36cbce25bfef34e939b139 Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Wed, 15 Jul 2015 17:36:45 +0100 Subject: [PATCH 3/3] Bump 1.3.3 Signed-off-by: Aanand Prasad --- CHANGES.md | 8 ++++++++ compose/__init__.py | 2 +- docs/install.md | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b87a2e7dee..38a5432499 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,14 @@ Change log ========== +1.3.3 (2015-07-15) +------------------ + +Two regressions have been fixed: + +- When stopping containers gracefully, Compose was setting the timeout to 0, effectively forcing a SIGKILL every time. +- Compose would sometimes crash depending on the formatting of container data returned from the Docker API. + 1.3.2 (2015-07-14) ------------------ diff --git a/compose/__init__.py b/compose/__init__.py index 1f69574951..97d9c11d97 100644 --- a/compose/__init__.py +++ b/compose/__init__.py @@ -1,3 +1,3 @@ from __future__ import unicode_literals -__version__ = '1.3.2' +__version__ = '1.3.3' diff --git a/docs/install.md b/docs/install.md index cdaac34f36..c025469b6c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -27,7 +27,7 @@ First, install Docker version 1.6 or greater: To install Compose, run the following commands: - curl -L https://github.com/docker/compose/releases/download/1.3.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose > Note: If you get a "Permission denied" error, your `/usr/local/bin` directory probably isn't writable and you'll need to install Compose as the superuser. Run `sudo -i`, then the two commands above, then `exit`.