mirror of https://github.com/docker/compose.git
Merge pull request #5653 from docker/5651-config_hash_bug
Fix: Modified options dict leads to a mismatched config hash for API < 1.30
This commit is contained in:
commit
56fe57fd77
|
@ -849,10 +849,10 @@ class Service(object):
|
||||||
override_options['mounts'] = [build_mount(v) for v in container_mounts] or None
|
override_options['mounts'] = [build_mount(v) for v in container_mounts] or None
|
||||||
else:
|
else:
|
||||||
# Workaround for 3.2 format
|
# Workaround for 3.2 format
|
||||||
self.options['tmpfs'] = self.options.get('tmpfs') or []
|
override_options['tmpfs'] = self.options.get('tmpfs') or []
|
||||||
for m in container_mounts:
|
for m in container_mounts:
|
||||||
if m.is_tmpfs:
|
if m.is_tmpfs:
|
||||||
self.options['tmpfs'].append(m.target)
|
override_options['tmpfs'].append(m.target)
|
||||||
else:
|
else:
|
||||||
override_options['binds'].append(m.legacy_repr())
|
override_options['binds'].append(m.legacy_repr())
|
||||||
container_options['volumes'][m.target] = {}
|
container_options['volumes'][m.target] = {}
|
||||||
|
|
|
@ -13,6 +13,7 @@ from compose.config.types import ServicePort
|
||||||
from compose.config.types import ServiceSecret
|
from compose.config.types import ServiceSecret
|
||||||
from compose.config.types import VolumeFromSpec
|
from compose.config.types import VolumeFromSpec
|
||||||
from compose.config.types import VolumeSpec
|
from compose.config.types import VolumeSpec
|
||||||
|
from compose.const import API_VERSIONS
|
||||||
from compose.const import LABEL_CONFIG_HASH
|
from compose.const import LABEL_CONFIG_HASH
|
||||||
from compose.const import LABEL_ONE_OFF
|
from compose.const import LABEL_ONE_OFF
|
||||||
from compose.const import LABEL_PROJECT
|
from compose.const import LABEL_PROJECT
|
||||||
|
@ -599,6 +600,25 @@ class ServiceTest(unittest.TestCase):
|
||||||
}
|
}
|
||||||
assert config_dict == expected
|
assert config_dict == expected
|
||||||
|
|
||||||
|
def test_config_hash_matches_label(self):
|
||||||
|
self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
|
||||||
|
service = Service(
|
||||||
|
'foo',
|
||||||
|
image='example.com/foo',
|
||||||
|
client=self.mock_client,
|
||||||
|
network_mode=NetworkMode('bridge'),
|
||||||
|
networks={'bridge': {}},
|
||||||
|
links=[(Service('one', client=self.mock_client), 'one')],
|
||||||
|
volumes_from=[VolumeFromSpec(Service('two', client=self.mock_client), 'rw', 'service')]
|
||||||
|
)
|
||||||
|
config_hash = service.config_hash
|
||||||
|
|
||||||
|
for api_version in set(API_VERSIONS.values()):
|
||||||
|
self.mock_client.api_version = api_version
|
||||||
|
assert service._get_container_create_options({}, 1)['labels'][LABEL_CONFIG_HASH] == (
|
||||||
|
config_hash
|
||||||
|
)
|
||||||
|
|
||||||
def test_remove_image_none(self):
|
def test_remove_image_none(self):
|
||||||
web = Service('web', image='example', client=self.mock_client)
|
web = Service('web', image='example', client=self.mock_client)
|
||||||
assert not web.remove_image(ImageType.none)
|
assert not web.remove_image(ImageType.none)
|
||||||
|
|
Loading…
Reference in New Issue