chore: opportunistically clean up containers for completed tasks#598
Merged
chore: opportunistically clean up containers for completed tasks#598
Conversation
Contributor
Angelmmiguel
left a comment
There was a problem hiding this comment.
LGTM! Added a comment before approving.
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.
Adds opportunistic container cleanup across the CLI so that containers for tasks in terminal states are automatically removed, freeing up resources without requiring an explicit user action.
Task output is already persisted via mounted volumes, so removing the container is safe.
FAILEDtasks are intentionally kept so users can still debug the container.Changes
tryRemoveTaskContainer()helper inpackages/cli/src/lib/sandbox/index.ts— a best-effort function that stops and removes a task's container and clears its container metadataisTerminalStatus()andisActiveStatus()utilities inpackages/cli/src/utils/task-status.tsto classify task stateslistcommand: opportunistically removes containers when a task reaches a terminal status (COMPLETED,MERGED,PUSHED)iteratecommand: removes the previous iteration's container before starting a new onerestartcommand: removes the previous container before starting a new onecleanupcommand: bulk-removes containers for all non-active tasks during cleanupNotes
The cleanup in the
listcommand is fire-and-forget (.catch(() => {})), whileiterateandrestartawaitthe removal since they need the container gone before starting a new one. Thecleanupcommand also awaits removal but wraps each attempt in a try/catch for best-effort semantics.