An upgrade repairs a root-owned media volume by itself (#1064) #1068
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/1064-media-volume-ownership"
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?
Closes #1064.
Summary
#914 made the image create
/app/mediaowned byappuser, which only helps a volume Docker initialises from that image. Amediavolume that already holds files and is root-owned stays that way, and the backend cannot write uploads into it.The
migrateservice already runs as root before the app starts, to prepare./backups(#414). It now also mountsmediaand repairs it:statof the top-level owner on every start. The recursive chown runs only when that is wrong, so a tree of thousands of map tiles is not walked each time.docker-compose.e2e.ymlreplacesmigrate's volumes wholesale (!override), which would have dropped the mount, so it gains the mount too.make migrate-saferuns the samemigratecommand, so it repairs the volume on that path as well./media/private/guard are untouched.Changelog
changelog.d/1064-media-volume-ownership.fixed.mdTest plan
Proved on docker-test in a throwaway compose project with no host ports; the dev stack was not touched.
up,migratelogged the repair line,/app/mediawas999:999, and a write asappuserin the backend succeeded.migrate-safepath (docker compose run --rm --no-deps -T migrate) repaired a root-owned tree.test_compose_migrate_media_ownership.py: the mount is present, thestatprecedes the chown and both precede Alembic, and the e2e overlay keeps the mount. 7 passed with the e2e bind-mount test.A correction to #1064's report. An empty root-owned volume does not reproduce the bug: Docker re-initialises an empty named volume from the image when it is mounted, so with an image that has #914 it comes back owned by
appuserunaided. The failure needs a volume that already holds files. Production'smediavolume is root-owned and empty, so the 4.5.0 image should initialise it correctly even without this change. This fix covers installs whose volume is not empty, and makes the outcome certain either way.🤖 Generated with Claude Code