Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions chi/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def delete(self):
None
"""
if self.id:
destroy_container(self.id)
destroy_container(self.id, force=True)
self.id = None
self._status = None

Expand Down Expand Up @@ -478,7 +478,7 @@ def snapshot_container(
return zun().containers.commit(container_ref, repository, tag=tag)["uuid"]


def destroy_container(container_ref: "str"):
def destroy_container(container_ref: "str", stop=False, force=False):
"""
.. deprecated:: 1.0

Expand All @@ -489,7 +489,7 @@ def destroy_container(container_ref: "str"):
Args:
container_ref (str): The name or ID of the container.
"""
return zun().containers.delete(container_ref, stop=True)
return zun().containers.delete(container_ref, stop=stop, force=force)


def get_logs(container_ref: "str", stdout=True, stderr=True):
Expand Down
12 changes: 12 additions & 0 deletions tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ def test_download_extracts_tar_and_writes_file(mocker):
assert f.read() == file_content


def test_delete_calls_force(mocker):
destroy_mock = mocker.patch("chi.container.destroy_container")
container = Container(name="test", image_ref="img")
container.id = "fake-id"

container.delete()

destroy_mock.assert_called_once_with("fake-id", force=True)
assert container.id is None
assert container._status is None


def test_submit_idempotent_returns_existing_without_create(mocker):
# idempotent=true, wait=true
chi_container = Container(name="dup-name", image_ref="img")
Expand Down