Merge "Always log if disconnect from docker swarm"
This commit is contained in:
@@ -30,12 +30,16 @@ def wrap_container_exception(f):
|
||||
try:
|
||||
return f(self, context, *args, **kwargs)
|
||||
except Exception as e:
|
||||
container_uuid = kwargs.get('container_uuid')
|
||||
if container_uuid is not None:
|
||||
LOG.exception(_LE("Error while connect to docker "
|
||||
"container %(name)s: %(error)s"),
|
||||
{'name': container_uuid,
|
||||
'error': str(e)})
|
||||
container_uuid = None
|
||||
if 'container_uuid' in kwargs:
|
||||
container_uuid = kwargs.get('container_uuid')
|
||||
elif 'container' in kwargs:
|
||||
container_uuid = kwargs.get('container').uuid
|
||||
|
||||
LOG.exception(_LE("Error while connect to docker "
|
||||
"container %(name)s: %(error)s"),
|
||||
{'name': container_uuid,
|
||||
'error': str(e)})
|
||||
raise exception.ContainerException(
|
||||
"Docker internal Error: %s" % str(e))
|
||||
return functools.wraps(f)(wrapped)
|
||||
|
||||
@@ -150,7 +150,7 @@ class TestDockerHandler(base.BaseTestCase):
|
||||
'test_image',
|
||||
tag='some_tag')
|
||||
self.assertFalse(self.mock_docker.create_container.called)
|
||||
mock_init.assert_called_once_with()
|
||||
mock_init.assert_called_with()
|
||||
self.assertEqual(fields.ContainerStatus.ERROR,
|
||||
mock_container.status)
|
||||
|
||||
@@ -204,7 +204,7 @@ class TestDockerHandler(base.BaseTestCase):
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(self.mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
mock_init.assert_called_with()
|
||||
|
||||
@mock.patch.object(objects.Container, 'get_by_uuid')
|
||||
@mock.patch.object(docker_conductor.Handler, '_find_container_by_name')
|
||||
@@ -249,7 +249,7 @@ class TestDockerHandler(base.BaseTestCase):
|
||||
docker_func.assert_called_once_with(mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(self.mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
mock_init.assert_called_with()
|
||||
|
||||
@mock.patch.object(objects.Container, 'get_by_uuid')
|
||||
@mock.patch.object(docker_conductor.Handler, '_find_container_by_name')
|
||||
@@ -487,7 +487,7 @@ class TestDockerHandler(base.BaseTestCase):
|
||||
mock_docker_id, 'ls', True, True, False)
|
||||
mock_find_container.assert_called_once_with(self.mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
mock_init.assert_called_with()
|
||||
|
||||
@mock.patch.object(docker_conductor.Handler, '_find_container_by_name')
|
||||
def test_container_exec_with_failure(self, mock_find_container):
|
||||
@@ -525,7 +525,7 @@ class TestDockerHandler(base.BaseTestCase):
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(self.mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
mock_init.assert_called_with()
|
||||
|
||||
def test_container_common_exception(self):
|
||||
self.dfc_context_manager.__enter__.side_effect = Exception("So bad")
|
||||
|
||||
Reference in New Issue
Block a user