preview: separate stop from purge, drop preview data after production deploy #11
Loading…
Reference in a new issue
No description provided.
Delete branch "pi-team/preview-purge-levels"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two commits:
pi-team: retry runs that die on a transient provider error— uncommitted work that was already sitting in the tree, committed as-is.preview: separate stopping a preview from purging its data— the actual change.preview-downkept volumes unconditionally and only tore down the stack owning the customer URL, whilepreview-upnever removes the previous stack. Result: solarcompany had 22 dead stacks, 92 volumes and 18 orphaned Caddy files (~13 GB).Now:
preview-down <slug> <pr>stops and keeps data,--purgealso drops volumes,--purge-all <slug>sweeps every stack of the customer. Post-deploy cleanup uses--purge-all.The script itself lives at /usr/local/bin/preview-down (out of repo); backup at preview-down.bak.20260801.
preview-down removed containers, images and routing but always kept the volumes, and only ever tore down the stack owning the customer URL. Since preview-up never removes the previous stack, every run left one behind: solarcompany had accumulated 22 dead stacks, 92 volumes and 18 orphaned Caddy files. Make the two intents explicit instead of implicit: preview-down <slug> <pr> stop — volumes kept, preview can come back up with its data preview-down --purge <slug> <pr> purge — volumes go too preview-down --purge-all <slug> purge every stack of the customer --purge-all collects stacks from containers, volumes and Caddy files, so stacks whose containers are already gone still get swept. Volumes are selected by the compose project label rather than by name matching, so no other customer's volume can be caught. Run the purge after a production deploy: the change is live, so the preview data is throwaway. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>