Conversation
This branch has not been deployed
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.
What does this PR do?
Adds opt-in Ryuk cleanup to
DockerCompose:Each opted-in object receives a unique Compose project name and registers its
com.docker.compose.projectlabel with the process’s shared Reaper before starting services. If the Python process is abruptly terminated, Ryuk can remove the project’s containers, networks, and volumes.Existing behavior remains unchanged when
ryukis omitted.Why is it needed?
DockerComposestarts services through the Compose CLI, bypassing the Reaper registration used byDockerContainer. Context-manager cleanup handles normal exit, but an abruptly terminated test process can leave Compose resources behind.This connects Compose environments to the existing cleanup mechanism. Registering the project before
compose upalso covers resources left behind when startup fails partway through. A unique project name separates cleanup ownership between independent Compose objects using the same files.Addresses #1049.
Shape
Extends the existing
DockerComposedataclass and shared command builder. The generated project name is reused across all commands and restarts of the same object. Compose reuses an existing Reaper when available.Adds acknowledged label-filter registration to Reaper, including serialized socket exchanges, fragmented-response handling, and a bounded timeout. Initial session registration uses the same mechanism so its acknowledgement cannot be mistaken for a subsequent Compose registration. Registration failures prevent startup; a failed additional registration does not deliberately close the shared connection and trigger cleanup of other environments.
Added documentation and 22 test cases covering registration failures, project isolation, Reaper reuse, retained volumes, cleanup diagnostics, and actual subprocess termination. The Linux verification run passed all 22 new cases plus three existing Ryuk tests. The five live integration cases skip native macOS because of Docker Desktop Ryuk instability.
A few lifecycle details for reviewers:
COMPOSE_PROJECT_NAMEand top-level Composename; explicit resource names and host ports still require care.keep_volumes=Truepreserves resources during normal context exit, but they remain eligible for Ryuk cleanup after disconnection.