Skip to content

Conversation

@realrajaryan
Copy link
Contributor

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Adds automatic cleanup of anonymous volumes when containers started with the --rm flag exit, preventing orphaned volumes from accumulating and consuming disk space.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@realrajaryan realrajaryan force-pushed the users/realrajaryan/rm-cleanup-anonvolumes branch from ef8edc7 to b1d37b9 Compare November 3, 2025 22:49
@realrajaryan realrajaryan added the storage issues and features associated with storage. label Nov 4, 2025

private func handleContainerExit(id: String, code: ExitStatus? = nil) async throws {
try await self.lock.withLock { [self] context in
let shouldCleanupVolumes = try await self.lock.withLock { [self] context in
Copy link
Member

Choose a reason for hiding this comment

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

Curious why we don't just do the cleanup in handleContainerExit itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the lock is released if autoRemove was true, the container bundle has already been deleted by cleanup(), so we can't call getContainerCreationOptions() again to check the flag, the file is gone. So we need to capture the decision while the container still exists (inside the lock) then act on it outside the lock

Copy link
Member

Choose a reason for hiding this comment

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

What I mean is if cleanup() is called we know that autoRemove was supplied, so why not just do it in there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage issues and features associated with storage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants