Don't preserve host volumes on container recreate.
Fixes a regression after the API changed to use Mounts. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
c64b7cbb10
commit
97fe2ee40c
3 changed files with 27 additions and 9 deletions
|
|
@ -312,7 +312,8 @@ class ServiceTest(DockerClientTestCase):
|
|||
ConvergencePlan('recreate', [old_container]))
|
||||
|
||||
self.assertEqual(
|
||||
[mount['Destination'] for mount in new_container.get('Mounts')], ['/data']
|
||||
[mount['Destination'] for mount in new_container.get('Mounts')],
|
||||
['/data']
|
||||
)
|
||||
self.assertEqual(new_container.get_mount('/data')['Source'], volume_path)
|
||||
|
||||
|
|
@ -323,8 +324,11 @@ class ServiceTest(DockerClientTestCase):
|
|||
)
|
||||
|
||||
old_container = create_and_start_container(service)
|
||||
self.assertEqual(list(old_container.get('Volumes').keys()), ['/data'])
|
||||
volume_path = old_container.get('Volumes')['/data']
|
||||
self.assertEqual(
|
||||
[mount['Destination'] for mount in old_container.get('Mounts')],
|
||||
['/data']
|
||||
)
|
||||
volume_path = old_container.get_mount('/data')['Source']
|
||||
|
||||
service.options['volumes'] = [VolumeSpec.parse('/tmp:/data')]
|
||||
|
||||
|
|
@ -338,8 +342,11 @@ class ServiceTest(DockerClientTestCase):
|
|||
"Service \"db\" is using volume \"/data\" from the previous container",
|
||||
args[0])
|
||||
|
||||
self.assertEqual(list(new_container.get('Volumes')), ['/data'])
|
||||
self.assertEqual(new_container.get('Volumes')['/data'], volume_path)
|
||||
self.assertEqual(
|
||||
[mount['Destination'] for mount in new_container.get('Mounts')],
|
||||
['/data']
|
||||
)
|
||||
self.assertEqual(new_container.get_mount('/data')['Source'], volume_path)
|
||||
|
||||
def test_execute_convergence_plan_without_start(self):
|
||||
service = self.create_service(
|
||||
|
|
|
|||
|
|
@ -234,6 +234,7 @@ class ServiceTest(unittest.TestCase):
|
|||
prev_container = mock.Mock(
|
||||
id='ababab',
|
||||
image_config={'ContainerConfig': {}})
|
||||
prev_container.get.return_value = None
|
||||
|
||||
opts = service._get_container_create_options(
|
||||
{},
|
||||
|
|
@ -575,6 +576,10 @@ class NetTestCase(unittest.TestCase):
|
|||
self.assertEqual(net.service_name, service_name)
|
||||
|
||||
|
||||
def build_mount(destination, source, mode='rw'):
|
||||
return {'Source': source, 'Destination': destination, 'Mode': mode}
|
||||
|
||||
|
||||
class ServiceVolumesTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue