Fix unsafe container cleanup in delete_image#56
Merged
Conversation
Previously, delete_image stopped ALL containers on the system before removing test images, which could disrupt unrelated containers. Changes: - Only stop and remove containers created from the specific test image - Match containers using substring comparison to handle sha256: prefix - Check container state before stopping to avoid unnecessary operations - Handle NotModifiedError for already-stopped containers This makes the test suite safe to run on development machines where other Docker containers may be running. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
550b002 to
6ff56c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
delete_imagehelper method was stopping ALL Docker containers on the system before removing test images. This is dangerous because it could interrupt unrelated containers that developers have running.Solution
Updated the cleanup logic to only stop and remove containers that were specifically created from the test image being cleaned up. This is done by:
Impact
This makes the test suite safer to run on development machines where other Docker containers may be running.