Ignore containers that don't have a name
If a container is in the process of being removed, or removal has failed, it can sometimes appear in the output of GET /containers/json but not have a 'Name' key. In that case, rather than crashing, we can ignore it. Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
6cb8e512f2
commit
dfa4bf4452
6 changed files with 64 additions and 11 deletions
|
|
@ -76,6 +76,18 @@ class ServiceTest(unittest.TestCase):
|
|||
all=False,
|
||||
filters={'label': expected_labels})
|
||||
|
||||
def test_container_without_name(self):
|
||||
self.mock_client.containers.return_value = [
|
||||
{'Image': 'foo', 'Id': '1', 'Name': '1'},
|
||||
{'Image': 'foo', 'Id': '2', 'Name': None},
|
||||
{'Image': 'foo', 'Id': '3'},
|
||||
]
|
||||
service = Service('db', self.mock_client, 'myproject', image='foo')
|
||||
|
||||
self.assertEqual([c.id for c in service.containers()], ['1'])
|
||||
self.assertEqual(service._next_container_number(), 2)
|
||||
self.assertEqual(service.get_container(1).id, '1')
|
||||
|
||||
def test_get_volumes_from_container(self):
|
||||
container_id = 'aabbccddee'
|
||||
service = Service(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue