Skip to content

fix(webserver): don't let a failing global-cache chown kill the container - #8659

Merged
rfay merged 2 commits into
ddev:mainfrom
rfay:20260802_rfay_global_cache_chown_non_fatal
Aug 4, 2026
Merged

rfay merged 2 commits into
ddev:mainfrom
rfay:20260802_rfay_global_cache_chown_non_fatal

Conversation

@rfay

@rfay rfay commented Aug 3, 2026

Copy link
Copy Markdown
Member

The Issue

start.sh chowns /mnt/ddev-global-cache/ and /var/lib/php in one
chown -R call under set -e. The global cache is already chowned by a
privileged utility container earlier in app.Start(), so this is normally
a no-op — but on some bind-mounted filesystems (observed with virtiofs on
Apple Container/socktainer) chown fails even when ownership already
matches, which kills the whole container on start since the combined
command is one set -e unit with the unrelated (and required) /var/lib/php
chown.

This is a real DDEV bug: start.sh treats a redundant, best-effort chown
as fatal alongside one that genuinely must succeed, on a filesystem type
that isn't unique to Apple Container.

How This PR Solves The Issue

Split the combined chown into two: the /var/lib/php chown stays fatal,
and the global-cache chown (already redundant in the common case) is now
|| true so a spurious failure on this filesystem no longer takes the
container down.

Manual Testing Instructions

  • Reproduced independently of DDEV/socktainer using the native container
    CLI directly, confirming the chown failure and container death without
    this fix.
  • ddev start on affected filesystems now succeeds; unaffected filesystems
    (normal Docker/OrbStack) are unchanged since the chown there just
    succeeds as before.

Automated Testing Overview

No new automated test — this is a shell-script change in the webserver
image whose failure mode only reproduces on affected bind-mount
filesystems; covered by manual reproduction described above.

Release/Deployment Notes

Changes containers/ddev-webserver/ddev-webserver-base-scripts/start.sh,
so WebTag in pkg/versionconstants/versionconstants.go is bumped to this
branch name. The corresponding ddev-webserver image has been built and
pushed under that tag.

@github-actions github-actions Bot added bugfix dependencies Pull requests that update a dependency file labels Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

rfay and others added 2 commits August 4, 2026 08:36
…iner

start.sh runs under `set -o errexit`, and its `chown -R ... /mnt/ddev-global-cache/
/var/lib/php` combined both paths into one command. Investigating ddev#7372
(Apple Container/socktainer, which bind-mounts the global cache over
virtiofs there) turned up that chown on a virtiofs bind mount can fail
with "Operation not permitted" even when ownership already matches -
reproduced directly with the native `container` CLI, no DDEV or socktainer
involved:

    $ container run --rm -v ~/tmp/x:/mnt/ddev-global-cache alpine \
        sh -c 'chown -R 1000:1000 /mnt/ddev-global-cache'
    chown: /mnt/ddev-global-cache: Operation not permitted

Under `set -e` that one failure took the whole container down before it
ever reached supervisord.

The chown is close to a no-op in the first place: app.Start() already runs
a privileged utility container that chowns the global cache (and the db
data dir) to the host uid/gid before any project container starts
(chownCmd in ddevapp.go) - the production start script already skips its
own copy of this chown for exactly that reason, per the comment left there
("chown of ddev-global-cache must be done with privileged container in
app.Start()"). The base (dev) script kept a redundant in-container chown of
its own, folded into the same command as the unrelated /var/lib/php chown
(which is local storage, always safe, and worth keeping fatal).

Split the two so /var/lib/php still fails the container if something is
genuinely wrong there, while the global-cache chown degrades to a no-op
warning on filesystems that reject it despite already having the right
owner. Confirmed the mechanism with the same repro: `|| true` lets the
script continue past the failing chown instead of `set -e` killing it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Any change under containers/ddev-webserver/ needs a matching WebTag bump
in versionconstants.go so ddev actually pulls an image built from this
branch instead of the one WebTag previously pointed at, matching the
convention used by prior webserver-only fixes (e.g. ddev#8635).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@rfay
rfay force-pushed the 20260802_rfay_global_cache_chown_non_fatal branch from 7d8cfab to 8699fef Compare August 4, 2026 14:37
@rfay
rfay marked this pull request as ready for review August 4, 2026 14:46
@rfay
rfay requested a review from a team as a code owner August 4, 2026 14:46
@rfay
rfay merged commit f012a7a into ddev:main Aug 4, 2026
12 checks passed
@rfay
rfay deleted the 20260802_rfay_global_cache_chown_non_fatal branch August 4, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant