Merge "Fix bug on container with empty 'command'"
This commit is contained in:
commit
6704d49cd8
@ -396,9 +396,10 @@ class DockerDriver(driver.ContainerDriver):
|
|||||||
|
|
||||||
def _populate_command(self, container, config):
|
def _populate_command(self, container, config):
|
||||||
command_list = config.get('Cmd')
|
command_list = config.get('Cmd')
|
||||||
command_str = ' '.join(command_list)
|
command_str = None
|
||||||
if command_str:
|
if command_list:
|
||||||
container.command = command_str
|
command_str = ' '.join(command_list)
|
||||||
|
container.command = command_str
|
||||||
|
|
||||||
def _populate_hostname_and_ports(self, container, config):
|
def _populate_hostname_and_ports(self, container, config):
|
||||||
# populate hostname only when container.hostname wasn't set
|
# populate hostname only when container.hostname wasn't set
|
||||||
|
@ -189,6 +189,16 @@ class TestDockerDriver(base.DriverTestCase):
|
|||||||
mock_container.container_id)
|
mock_container.container_id)
|
||||||
self.assertEqual('fake_command', mock_container.command)
|
self.assertEqual('fake_command', mock_container.command)
|
||||||
|
|
||||||
|
def test_show_without_command(self):
|
||||||
|
self.mock_docker.inspect_container = mock.Mock(
|
||||||
|
return_value={'State': 'running',
|
||||||
|
'Config': {'Cmd': None}})
|
||||||
|
mock_container = mock.MagicMock()
|
||||||
|
self.driver.show(self.context, mock_container)
|
||||||
|
self.mock_docker.inspect_container.assert_called_once_with(
|
||||||
|
mock_container.container_id)
|
||||||
|
self.assertIsNone(mock_container.command)
|
||||||
|
|
||||||
def test_show_fail_container_id_is_none(self):
|
def test_show_fail_container_id_is_none(self):
|
||||||
mock_container = mock.MagicMock()
|
mock_container = mock.MagicMock()
|
||||||
mock_container.container_id = None
|
mock_container.container_id = None
|
||||||
|
Loading…
Reference in New Issue
Block a user