Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify container.remove() behaviour #2235

Merged
merged 1 commit into from
Feb 22, 2025
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
5 changes: 2 additions & 3 deletions tagging/utils/docker_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def __exit__(
) -> None:
assert self.container is not None
LOGGER.info(f"Removing container {self.container.name} ...")
if self.container:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert above means that this if is always true

self.container.remove(force=True)
LOGGER.info(f"Container {self.container.name} removed")
self.container.remove(force=True)
LOGGER.info(f"Container {self.container.name} removed")

@staticmethod
def run_simple_command(
Expand Down
6 changes: 5 additions & 1 deletion tests/utils/tracked_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,9 @@ def _lines_starting_with(logs: str, pattern: str) -> list[str]:

def remove(self) -> None:
"""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)
LOGGER.info(f"Container {self.container.name} removed")
Comment on lines +95 to +100
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just better logs.

There is some sort of code duplication between DockerRunner and TrackedContainer, but for now let's keep tagging/ and tests dir completely independent of each other.