From ad9011ed96dc35ef6880badd1068276a4493da37 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 5 Jan 2016 17:30:27 -0500 Subject: [PATCH] Don't warn when the container volume is specified as a compose option. Signed-off-by: Daniel Nephin --- compose/service.py | 1 + tests/unit/service_test.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/compose/service.py b/compose/service.py index d15098710..5540d7348 100644 --- a/compose/service.py +++ b/compose/service.py @@ -880,6 +880,7 @@ def warn_on_masked_volume(volumes_option, container_volumes, service): for volume in volumes_option: if ( + volume.external and volume.internal in container_volumes and container_volumes.get(volume.internal) != volume.external ): diff --git a/tests/unit/service_test.py b/tests/unit/service_test.py index 1c8b441f3..637bf3bae 100644 --- a/tests/unit/service_test.py +++ b/tests/unit/service_test.py @@ -742,6 +742,18 @@ class ServiceVolumesTest(unittest.TestCase): assert not mock_log.warn.called + def test_warn_on_masked_no_warning_with_container_only_option(self): + volumes_option = [VolumeSpec(None, '/path', 'rw')] + container_volumes = [ + VolumeSpec('/var/lib/docker/volume/path', '/path', 'rw') + ] + service = 'service_name' + + with mock.patch('compose.service.log', autospec=True) as mock_log: + warn_on_masked_volume(volumes_option, container_volumes, service) + + assert not mock_log.warn.called + def test_create_with_special_volume_mode(self): self.mock_client.inspect_image.return_value = {'Id': 'imageid'}