Volume ownership reset on first deploy after migration #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
After migrating an app to a new server with migrabrator, services that write files directly in their volume root fail on the first deploy. Ran into this with Prometheus from monitoring-ng:
Fatal error: opening storage failed: lock DB directory: open /prometheus/lock: permission deniedServices that only write inside subdirectories (e.g. Loki) start fine, so this issue can go partially unnoticed.
Migrabrator rsyncs volume data to
/var/lib/docker/volumes/<new_name>/before the volume exists in Docker's volume database. The rsync itself preserves ownership correctly. But on the firstabra app deploy, Docker registers the unknown volume and chowns the_datadir toroot:root 0755, even though it already exists and has data. Contents keep their ownership; only the volume root is reset. Any container user can't create files directly in the volume root.Fix
In
copy_volumes(), register the volume on the target withdocker volume create <volume_name>before rsyncing into it. Once the volume is known to Docker, the rsynced ownership survives deploys. The same-server rename path (-dwithout-s) probably has the same issue.When I need this again, I can write the fix and test.
If of any use:
abra app movearrived in the meantime.Yes, saw that. But
abra app renamehasn't arrived yet.