Clarify container.remove() behaviour (#2235)

This commit is contained in:
Ayaz Salikhov
2025-02-22 00:46:48 +00:00
committed by GitHub
parent 1bbab5c80d
commit 18e09a7872
2 changed files with 7 additions and 4 deletions

View File

@@ -39,7 +39,6 @@ class DockerRunner:
) -> None: ) -> None:
assert self.container is not None assert self.container is not None
LOGGER.info(f"Removing container {self.container.name} ...") LOGGER.info(f"Removing container {self.container.name} ...")
if self.container:
self.container.remove(force=True) self.container.remove(force=True)
LOGGER.info(f"Container {self.container.name} removed") LOGGER.info(f"Container {self.container.name} removed")

View File

@@ -92,5 +92,9 @@ class TrackedContainer:
def remove(self) -> None: def remove(self) -> None:
"""Kills and removes the tracked docker container.""" """Kills and removes the tracked docker container."""
if self.container: if self.container is None:
LOGGER.info("No container to remove")
else:
LOGGER.info(f"Removing container {self.container.name} ...")
self.container.remove(force=True) self.container.remove(force=True)
LOGGER.info(f"Container {self.container.name} removed")