Skip to content

Stop the media rsync clamping the upload ACL mask - #224

Merged
ssavutu merged 1 commit into
mainfrom
fix/media-rsync-acl-mask
Sep 1, 2026
Merged

Stop the media rsync clamping the upload ACL mask#224
ssavutu merged 1 commit into
mainfrom
fix/media-rsync-acl-mask

Conversation

@ssavutu

@ssavutu ssavutu commented Sep 1, 2026

Copy link
Copy Markdown
Member

Follow-up to the 2026-09-01 outage where POST /v1/media returned 500 on every upload. triangle-infrastructure#2 makes Ansible repair the damage; this fixes the command that causes it.

The cause

docs/HANDOVER.md documented the media sync as:

rsync -a --no-owner --no-group --chmod=D755,F644 ...

A chmod on an ACL'd directory sets the ACL mask from the mode's group bits, and the mask caps every named entry. So D755 clamped the backend's user:10001:rwx grant to #effective:r-x on every directory the sync touched.

getfacl still prints user:10001:rwx and ls shows only a +, so it reads as correct. Uploads then keep working until the 1st of the next month — the first time the handler has to create a new YYYY/MM directory:

"media upload: create directory" dir=.../uploads/2026/09  error="mkdir ...: permission denied"

The fix

D775 instead of D755. The group write bit is load-bearing: it keeps the mask at rwx, and it matches the 0775 the CMS itself creates month directories with (media.go MkdirAll).

Verified on CephFS

Against a scratch fixture reproducing the live uploads ACL, then removed:

D755 (old) D775 (new)
year dir mask after sync mask::r-xclamped mask::rwx
new month dir clamped, #effective:r-x inherits user:10001:rwx
uid 10001 can create next month no yes
synced file readable by nginx yes yes (0664)

The old command reproduced the outage exactly, including that default:mask::rwx survives while the access mask drops — which is what makes the ACL look healthy.

Also corrected

deploy/README.md claimed the default ACL entry meant this "does not need repeating every month". That holds until something chmods the tree, and believing it is a large part of why the bug hid for a month. It now documents the mask and how to check it. docs/ETL-REBUILD.md gains the check in post-load verification.

Docs only — no code changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Tx3ywgRQLzzrZWNcSdtTpr

The documented media sync used --chmod=D755, which is what caused the
2026-09-01 outage where POST /v1/media returned 500 on every upload.

A chmod on an ACL'd directory sets the ACL mask from the mode's group bits, and
the mask caps every named entry. D755 therefore clamped the backend's
user:10001:rwx grant to #effective:r-x on every directory the sync touched.
getfacl still prints user:10001:rwx and ls shows only a +, so it reads as
correct, and uploads keep working until the 1st of the next month -- the first
time the handler has to create a new YYYY/MM directory.

D775 keeps the mask at rwx and matches the 0775 the CMS itself creates month
directories with. Verified on CephFS against a fixture reproducing the live ACL:
D755 reproduces the clamp exactly, D775 leaves the mask rwx, the new month
directory inherits the grant, uid 10001 can create the next month, and the
synced files stay world-readable for nginx.

deploy/README.md claimed the default ACL entry meant this "does not need
repeating every month". That is true until something chmods the tree, and
believing it is what let the bug hide for a month; it now documents the mask.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tx3ywgRQLzzrZWNcSdtTpr
@ssavutu
ssavutu merged commit 09c99ad into main Sep 1, 2026
7 checks passed
@ssavutu
ssavutu deleted the fix/media-rsync-acl-mask branch September 1, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant