feat(projects): preserve managed volumes on project rename#2919
feat(projects): preserve managed volumes on project rename#2919NeurekaSoftware wants to merge 12 commits into
Conversation
Project rename now migrates implicit Docker Compose managed volumes to the new project-scoped names while leaving explicit volume names alone. The migration copies data safely, aborts on target conflicts, and rolls back if the project update fails.
Use the repository's existing containerd errdefs dependency for Docker not-found checks so the backend build does not require an undeclared moby errdefs module.
Treat existing new-name Compose volumes as recoverable only when they already carry the expected Compose project and volume labels. Stale partial targets are cleaned up before copying again, completed migrations no longer block saving, and rollback cleanup errors are surfaced with focused coverage.
Make project rename volume migration preflight target-name conflicts, copy with disk-space checks, and remove source volumes only after the project update is staged. Add a short-lived KV journal for interrupted rename recovery and focused coverage for recovery and safety helpers. AI-Assisted: Implemented with ChatGPT/Codex under user direction.
Remove the awk dependency from the volume copy disk-space check so the helper works with minimal images, force-remove newly created target volumes during rollback, and refresh the project editor draft after failed saves. Go tests were skipped per request. AI-assisted change.
Use BusyBox for project volume copy operations so the pre-copy disk-space check can run against the actual target volume filesystem. Keep copy helpers long enough to read failure logs, then remove them through the existing cleanup path. Go tests were skipped per request. AI-assisted change.
Resolve unknown project status from live compose services before planning a rename so stopped projects do not need a start-stop cycle and volume migration planning sees the stopped state. Keep running projects blocked and add regressions for stale stopped and stale running runtime states. Go tests skipped per request. AI-assisted change by Codex.
Plan project volume renames from the post-save compose preview, verify live stopped state before any rename, block attached source volumes, and clean copy helpers with an uncancelled timeout context.
Remove the managed volume rename note from the Unreleased section so the changelog does not include the unintended entry.
Remove the extra UpdateProject arguments from the rename-status test and apply the Internal suffix to unexported project update and compose volume helpers.
Treat missing committed target volumes as recoverable during rename journal completion so stale journals can clear. Also refactor project update and volume rename helpers to satisfy the current backend lint rules.
…s-managed-volumes
|
Ill have to look into this more, but doesnt just recreating the project do this? Alos note: the name field in arcane ui is pretty much just the name for the folder and for internal refernce of it it doesnt get passed to docker (i dont think :O) anymore or at least it shouldnt |
Just an example, my "media-server" stack has 13 volumes. Renaming the project / renaming the folder is the same as changing the stack name. Managed volumes are named So renaming my "media-server" stack to "media-services" will result in brand new volumes being created when I bring it up again, unless I manually rename all previous volumes. The exception to the stack name changing when the folder name changes is when you have a |
|
I just confirmed, having the stack name in the compose file should make the volumes stable but arcane doesn't respect that value for some reason. When using docker via the CLI, you can have a This is why this change is needed. It adds complexity to renaming projects but it ensures nothing ever breaks when managing projects via arcane. |
Reproduction StepsScenario 1: No
|
|
Arcane doesn't seem to respect scenario 2 either, which probably needs its own separate bug report. Once the bug with arcane not respecting scenario 2 is fixed, this PR should be modified to exclude migrating volumes when a project is renamed if |
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can stay up-to-date and reviewed. |
Checklist
mainbranchWhat This PR Implements
When an Arcane project is renamed, Arcane now keeps its automatically managed Compose volumes aligned with the new project name.
For example, renaming a project from
nginxtowebwill move the data fromnginx_datainto the newweb_datavolume so the project continues using the same application data after the rename.Volumes with an explicit fixed
name:in the Compose file are left alone. External volumes are also left alone.Fixes: #2898
Changes Made
What Happens During A Rename
When a stopped project is renamed, Arcane checks the Compose volume definitions and finds volumes whose names were generated from the old project name.
For each matching managed volume, Arcane creates the new target volume, copies the data from the old volume into it, and then updates the project rename. After the project update succeeds, Arcane removes the old project-scoped volume.
If anything fails before the rename is completed, Arcane rolls the change back. It removes any newly created target volumes, restores the original project directory state when project files were edited, and keeps the project using the original volume names.
Arcane also writes a short rename journal while the rename is in progress. If Arcane restarts or is interrupted during the operation, startup recovery uses that journal to either finish cleanup after a completed rename or roll the rename back if the project update did not finish.
Testing Done
AI Tool Used (if applicable)
Codex / GPT 5.5 xhigh assisted with the implementation, design, and tests.
Additional Context
This change is intended to make project renames safer and less surprising. Without it, Docker Compose can create a new empty project-scoped volume after a rename, which can look like data loss even though the old volume still exists.
Disclaimer Greptiles Reviews use AI, make sure to check over its work.
To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike
To have Greptile Re-Review the changes, mention
greptileai.Greptile Summary
This PR adds project-managed Compose volume migration during project rename: when a stopped project is renamed, Arcane creates new volumes with the updated name prefix, copies data from the old volumes, then removes the old volumes after the project record is committed. A KV-backed rename journal enables crash recovery and rollback, and the frontend refreshes project state after a failed save.
project_volume_rename.goimplements the full copy-rename-commit cycle using abusyboxhelper container, with pre-flight checks for target-volume conflicts and in-use sources.project_rename_journal.gopersists rename progress and drives startup recovery, rolling back or completing partial renames automatically.project_service.gowires the new checks (ensureProjectStoppedForRenameInternal, live-status verification) and the backup/restore mechanism for compose-file edits that coincide with a rename.Confidence Score: 5/5
Safe to merge; the core rename, recovery, and rollback paths are well-structured and covered by tests.
No logic defects in the rename or recovery flow were found. The backup-and-restore path correctly tracks the physical directory location across withProjectRenameRollback, journal recovery handles the directory and volume states consistently, and the DB transaction boundaries around Commit() are sound. The two findings are style and SQL-wildcard correctness nits with no impact on the happy path.
No files require special attention beyond the two inline suggestions.
Reviews (3): Last reviewed commit: "fix(projects): recover missing rename ta..." | Re-trigger Greptile
Context used: