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