mirror of
https://github.com/docker/compose.git
synced 2025-07-21 20:54:32 +02:00
Merge pull request #5603 from docker/5591-mount-rename-recreate
Don't break during recreate when a mount target is updated
This commit is contained in:
commit
456906d7ad
@ -1322,7 +1322,6 @@ def get_container_data_volumes(container, volumes_option, tmpfs_option, mounts_o
|
|||||||
a mapping of volume bindings for those volumes.
|
a mapping of volume bindings for those volumes.
|
||||||
Anonymous volume mounts are updated in place instead.
|
Anonymous volume mounts are updated in place instead.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
volumes = []
|
volumes = []
|
||||||
volumes_option = volumes_option or []
|
volumes_option = volumes_option or []
|
||||||
|
|
||||||
@ -1366,7 +1365,7 @@ def get_container_data_volumes(container, volumes_option, tmpfs_option, mounts_o
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
ctnr_mount = container_mounts.get(mount.target)
|
ctnr_mount = container_mounts.get(mount.target)
|
||||||
if not ctnr_mount.get('Name'):
|
if not ctnr_mount or not ctnr_mount.get('Name'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
mount.source = ctnr_mount['Name']
|
mount.source = ctnr_mount['Name']
|
||||||
|
@ -487,6 +487,28 @@ class ServiceTest(DockerClientTestCase):
|
|||||||
with pytest.raises(APIError):
|
with pytest.raises(APIError):
|
||||||
self.client.inspect_container(old_container.id)
|
self.client.inspect_container(old_container.id)
|
||||||
|
|
||||||
|
def test_execute_convergence_plan_recreate_change_mount_target(self):
|
||||||
|
service = self.create_service(
|
||||||
|
'db',
|
||||||
|
volumes=[MountSpec(target='/app1', type='volume')],
|
||||||
|
entrypoint=['top'], command=['-d', '1']
|
||||||
|
)
|
||||||
|
old_container = create_and_start_container(service)
|
||||||
|
assert (
|
||||||
|
[mount['Destination'] for mount in old_container.get('Mounts')] ==
|
||||||
|
['/app1']
|
||||||
|
)
|
||||||
|
service.options['volumes'] = [MountSpec(target='/app2', type='volume')]
|
||||||
|
|
||||||
|
new_container, = service.execute_convergence_plan(
|
||||||
|
ConvergencePlan('recreate', [old_container])
|
||||||
|
)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
[mount['Destination'] for mount in new_container.get('Mounts')] ==
|
||||||
|
['/app2']
|
||||||
|
)
|
||||||
|
|
||||||
def test_execute_convergence_plan_recreate_twice(self):
|
def test_execute_convergence_plan_recreate_twice(self):
|
||||||
service = self.create_service(
|
service = self.create_service(
|
||||||
'db',
|
'db',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user