fix(ops): reclaim disk at deploy-start to prevent ENOSPC (#368)#369
Merged
Conversation
Every deploy's `pull` orphans the previous :latest images and `up --build` adds BuildKit cache layers, with no cleanup step — this exhausted the 30 GB root volume and broke a deploy on ENOSPC. Add a self-healing reclaim block (step 1.5) that runs before secret-fetch and before all docker consumers: `docker image prune -f` removes dangling images; `docker builder prune -f --keep-storage 5GB` bounds build cache to ~5 GB warm. Placed before step 2 so disk is freed before mktemp too (a near-full volume could fail at secret-fetch before any later cleanup). Skipped in --post-db-restart mode. Warn-and-continue on prune failure so a broken flag is visible in CloudWatch without blocking an otherwise-healthy deploy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SAwscVmeHmEgU457HJzjNY
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
pullre-publishing:latest) and BuildKit cache (fromup --build) with no cleanup, which exhausted the 30 GB root volume and broke a deploy on ENOSPCdocker image prune -fremoves dangling images;docker builder prune -f --keep-storage 5GBbounds build cache to ~5 GB warm; warn-and-continue on failure so a broken flag is visible in CloudWatch without blocking a deployRelated issue
Closes #368
Type of change
Checklist
docs/decisions.mdset -x, no secret references in new lines; prune commands touch only dangling images and build cache, never named volumes (HAPI H2, Postgres, Caddy) or running containersTest plan
pytest --ignore=tests/integration) — passedset -xgrep) — cleanbash -n scripts/deploy-prod.sh) — clean./scripts/run-integration-tests.sh --ignore=...) — passed/leonard/deployCloudWatch log group for[+] Reclaiming disk before deploy...line, confirm no[!] WARNING: docker ... prune failedline, and verifydf -h /output shows freed space vs pre-deploy baseline. Deploy success alone is not sufficient — the reclaim must have actually run. (AWS_PROFILE=leonard)