Remove unnecessary check on container init
The container_start and container_stop are idempotent. It is safe to run them again on startup if it was unfinished. Change-Id: I0615493431dd882895d12ecf67c72fc3d7a200ec
This commit is contained in:
parent
87a3370ca0
commit
dfdc8e1b1b
@ -98,21 +98,11 @@ class Manager(periodic_task.PeriodicTasks):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if container.task_state == consts.CONTAINER_STOPPING:
|
if container.task_state == consts.CONTAINER_STOPPING:
|
||||||
if container.status == consts.STOPPED:
|
|
||||||
LOG.info("Container %s is already stop when stop is called.",
|
|
||||||
container.uuid)
|
|
||||||
self._update_task_state(context, container, None)
|
|
||||||
else:
|
|
||||||
self.container_stop(context, container,
|
self.container_stop(context, container,
|
||||||
CONF.docker.default_timeout)
|
CONF.docker.default_timeout)
|
||||||
return
|
return
|
||||||
|
|
||||||
if container.task_state == consts.CONTAINER_STARTING:
|
if container.task_state == consts.CONTAINER_STARTING:
|
||||||
if container.status == consts.RUNNING:
|
|
||||||
LOG.info("Container %s is already start when start is called.",
|
|
||||||
container.uuid)
|
|
||||||
self._update_task_state(context, container, None)
|
|
||||||
else:
|
|
||||||
self.container_start(context, container)
|
self.container_start(context, container)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -126,15 +126,6 @@ class TestManager(base.TestCase):
|
|||||||
container_1,
|
container_1,
|
||||||
10)
|
10)
|
||||||
|
|
||||||
@mock.patch.object(Container, 'save')
|
|
||||||
def test_init_container_retries_start_already(self, mock_save):
|
|
||||||
container = Container(self.context, **utils.get_test_container())
|
|
||||||
container.task_state = consts.CONTAINER_STARTING
|
|
||||||
container.status = consts.RUNNING
|
|
||||||
self.compute_manager._init_container(self.context, container)
|
|
||||||
self.assertEqual(container.status, consts.RUNNING)
|
|
||||||
self.assertIsNone(container.task_state)
|
|
||||||
|
|
||||||
@mock.patch.object(manager.Manager, 'container_stop')
|
@mock.patch.object(manager.Manager, 'container_stop')
|
||||||
@mock.patch.object(Container, 'save')
|
@mock.patch.object(Container, 'save')
|
||||||
def test_init_container_retries_stop(self, mock_save,
|
def test_init_container_retries_stop(self, mock_save,
|
||||||
@ -145,15 +136,6 @@ class TestManager(base.TestCase):
|
|||||||
mock_container_stop.assert_called_once_with(self.context,
|
mock_container_stop.assert_called_once_with(self.context,
|
||||||
container, 60)
|
container, 60)
|
||||||
|
|
||||||
@mock.patch.object(Container, 'save')
|
|
||||||
def test_init_container_retries_stop_already(self, mock_save):
|
|
||||||
container = Container(self.context, **utils.get_test_container())
|
|
||||||
container.task_state = consts.CONTAINER_STOPPING
|
|
||||||
container.status = consts.STOPPED
|
|
||||||
self.compute_manager._init_container(self.context, container)
|
|
||||||
self.assertEqual(container.status, consts.STOPPED)
|
|
||||||
self.assertIsNone(container.task_state)
|
|
||||||
|
|
||||||
@mock.patch.object(manager.Manager, 'container_delete')
|
@mock.patch.object(manager.Manager, 'container_delete')
|
||||||
@mock.patch.object(Container, 'save')
|
@mock.patch.object(Container, 'save')
|
||||||
def test_init_container_retries_deleting(self, mock_save,
|
def test_init_container_retries_deleting(self, mock_save,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user