From bdb528ecfcc2ecd560bf6e623dc0797e43c50374 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Mon, 27 Jul 2026 05:13:42 -0600 Subject: [PATCH] fix(scripts): recognize linuxbrew volumes in the orphaned-volume cleanup sweep cleanup-deleted-workspaces.sh's orphan detection only matched coder---dind-cache. An upcoming change persists Homebrew across workspace restarts via a second per-workspace volume (coder---linuxbrew) -- without this fix, an orphaned one (from an interrupted destroy, state desync, etc. -- exactly the failure modes this script is a safety net for) would never be flagged or cleaned up. Match both known suffixes, and note in-line that any future persistent per-workspace volume needs to be added here too. Also tightens a comment in workspace-lifecycle-cleanup.sh that attributed volume cleanup to "the destroy provisioner" -- the null_resource destroy provisioner in each template only removes the host-bind-mounted directory; volumes are removed because Terraform destroys them along with the rest of the workspace's resource graph, which is a separate mechanism. Updated to mention the linuxbrew volume too. Co-Authored-By: Claude Sonnet 5 --- scripts/cleanup-deleted-workspaces.sh | 6 ++++-- scripts/workspace-lifecycle-cleanup.sh | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/cleanup-deleted-workspaces.sh b/scripts/cleanup-deleted-workspaces.sh index 852a13b..6b15cd5 100755 --- a/scripts/cleanup-deleted-workspaces.sh +++ b/scripts/cleanup-deleted-workspaces.sh @@ -88,8 +88,10 @@ echo # --- Docker volumes --- orphan_volumes=() while IFS= read -r vol; do - # Volume names look like: coder---dind-cache - if [[ "$vol" =~ ^coder-(.+)-dind-cache$ ]]; then + # Volume names look like: coder---dind-cache or + # coder---linuxbrew. Add any new persistent per-workspace + # volume suffix here too, or orphans of that type will go undetected. + if [[ "$vol" =~ ^coder-(.+)-(dind-cache|linuxbrew)$ ]]; then owner_workspace="${BASH_REMATCH[1]}" if [[ -z "${active_dirs[$owner_workspace]+_}" ]]; then orphan_volumes+=("$vol") diff --git a/scripts/workspace-lifecycle-cleanup.sh b/scripts/workspace-lifecycle-cleanup.sh index 273af37..1fc3d16 100755 --- a/scripts/workspace-lifecycle-cleanup.sh +++ b/scripts/workspace-lifecycle-cleanup.sh @@ -2,12 +2,14 @@ # Notify and delete idle workspaces on coder.ddev.com. # # Why this exists: -# Stopping a workspace does not free its Docker volume — each Sysbox -# workspace keeps a multi-GB dind-cache volume until the workspace is -# deleted (the destroy provisioner in each template removes it). With no -# lifecycle policy, stopped workspaces accumulate forever and slowly fill -# /data on the host. This janitor enforces: notify at N days idle, delete -# 7 days after the notice if the workspace is still untouched. +# Stopping a workspace does not free its Docker volumes — each Sysbox +# workspace keeps a multi-GB dind-cache volume and a linuxbrew volume until +# the workspace is deleted (Terraform destroys them, along with everything +# else in the workspace's resource graph, when the workspace itself is +# deleted). With no lifecycle policy, stopped workspaces accumulate forever +# and slowly fill /data on the host. This janitor enforces: notify at N +# days idle, delete 7 days after the notice if the workspace is still +# untouched. # # Policy (state machine per workspace, keyed by workspace id): # - Not yet notified, age(last_used_at) >= NOTIFY_DAYS