feat: move vscode-server GC into the template as a mounted script - #869
Merged
Conversation
~/.vscode-server grows without bound on any workspace VS Code connects to, whether or not the operator's dotfiles have ever been applied to it (confirmed on the `test` workspace, which reached ~11 GB with dotfiles never applied). The GC for it was previously scoped to the dotfiles repo, invoked from here via `[ -x $HOME/.local/bin/vscode-server-gc ] && ... || true` - a guard that makes "the script isn't there" indistinguishable from "the script ran and had nothing to do", so the weekly cron reported success on every workspace dotfiles hadn't reached. Adds script-vscode-server-gc.sh as a template-owned script alongside script-agent-startup.sh and script-memory-watchdog.sh: mounted into the ConfigMap (configmap.tf), mounted into the workspace container at /vscode-server-gc.sh (deployment.tf), and invoked directly by the existing coder_script.vscode_server_gc cron (scripts.tf) with no existence-check guard, so an actual failure now surfaces as a failed run in the Coder UI. The script's own logic is unchanged from what was verified against the dotfiles version: same deletion signals (cli/servers/*.staging, cli/servers/lru.json, orphaned code-<hash> binaries, extensions/.obsolete cross-checked against extensions.json), same pgrep-based in-use safety net, same decision to leave ~/.vscode-server/data/logs alone. Re-verified on the disposable `test` workspace via the new invocation path (/bin/bash /vscode-server-gc.sh): idempotent, zero items to remove on a second run. Ref: ppat/dotfiles#771
ppat
force-pushed
the
feat/vscode-server-gc-template
branch
from
August 18, 2026 02:41
ddef024 to
acdfa24
Compare
Contributor
|
🎉 This PR is included in version 2.27.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
~/.vscode-servergrows without bound (interrupted Remote-SSHdownloads, server versions VS Code no longer considers live, their
orphaned
code-<hash>binaries, superseded extension versions) onany workspace VS Code connects to. This was originally scoped to the
operator's dotfiles repo as a script installed to
$HOME/.local/bin/vscode-server-gc, with this template's existingcoder_script.vscode_server_gcweekly cron invoking it via[ -x $HOME/.local/bin/vscode-server-gc ] && ... || true.~/.vscode-serveris created by VSCode the moment it connects to a workspace, independent of whether
dotfiles have ever been applied there. Confirmed directly — the
disposable
testCoder workspace reached ~11 GB of~/.vscode-serverwith dotfiles never applied to it. A script whosepresence depends on a component that may be absent can't own cleanup
of something that appears regardless of that component.
[ -x ... ] || truemakes "the script isn't installed" indistinguishable from "the
script ran and had nothing to do" — both report success on the
weekly cron, on every workspace dotfiles hasn't reached.
script-vscode-server-gc.shbecomes a template-owned script,same as
script-agent-startup.sh/script-memory-watchdog.sh—mounted into the ConfigMap (
configmap.tf), mounted into theworkspace container at
/vscode-server-gc.sh(deployment.tf), andinvoked directly by the existing cron (
scripts.tf) with noexistence-check guard, so an actual failure now surfaces as a failed
run in the Coder UI instead of vanishing into
|| true.CLAUDE.mdabout this specificanti-pattern (a template-scheduled
coder_scriptdepending on apayload from outside the template with absence swallowed by
|| true) — deliberately not a general rule about who owns stateunder
$HOME, since the template's own watchdog, dotfiles-installedtooling, and the image all generate state there too; "who generated
it" doesn't determine "who owns its lifecycle" in general, only in
this specific coupling.
What the script does (unchanged from the dotfiles version)
Every deletion is driven by a signal VS Code itself writes to disk,
plus a
pgrep-based safety net, never a guess at "newest N":cli/servers/*.stagingcli/servers/Stable-<hash>cli/servers/lru.jsoncode-<hash>CLI binariescli/servers/Stable-<hash>directory remainsextensions/<name>extensions/.obsoleteand not referenced byextensions/extensions.jsondata/logs/is deliberately left alone — no on-disk signal marks adated log directory as safe to remove.
Testing
pre-commit run --all-filespasses, includingterraform validate/tflint.testworkspace via the new invocationpath (
/bin/bash /vscode-server-gc.sh --dry-run): idempotent, zeroitems to remove on a second run (this workspace was already cleaned
by the earlier, dotfiles-hosted version of the same script during
investigation — this PR only changes where the script lives and how
it's invoked, not its logic).
Ref: ppat/dotfiles#771