Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Don't create containers on "halt" command (#102)
Browse files Browse the repository at this point in the history
When running `lxdock halt` after having only a subset if our containers
being created, we would end up in this annoying situation where missing
containers would be created and then halted. Not anymore.
  • Loading branch information
Virgil Dupras authored and ellmetha committed Oct 17, 2017
1 parent 64e15d0 commit aff1a92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lxdock/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def destroy(self):

def halt(self):
""" Stops the container. """
if not self.exists:
logger.info("The container doesn't exist.")
return

if self.is_stopped:
logger.info('The container is already stopped.')
return
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def test_can_destroy_a_container_and_run_this_action_for_a_container_that_does_n
container.destroy()
assert not container.exists

def test_halting_a_container_doesnt_create_it(self):
container_options = {
'name': self.containername('doesnotexist'), 'image': 'alpine/3.6', }
container = Container('myproject', THIS_DIR, self.client, **container_options)
container.halt()
assert not container.exists

def test_can_halt_a_container_that_is_running(self, persistent_container):
persistent_container.halt()
assert persistent_container._container.status_code == constants.CONTAINER_STOPPED
Expand Down

0 comments on commit aff1a92

Please sign in to comment.