Repository navigation
Read the volume mapping from the panel's own container - #338
Merged
Merged
Conversation
CARBONPANEL_HOST_DATA_PATH and CARBONPANEL_DATA_DIR restated the compose volume mapping by hand, so they could silently disagree with it. The panel now reads its own container's mounts at startup: /app/data maps to whatever the compose file mounted it from, and the daemon is asked for that path. Startup validates the mapping before anything writes to it: - a data directory that is not on a persistent mount is refused from the container mount table, before the database exists; - a read-only mount, a tmpfs data directory and a directory the process cannot write are refused, the last with a probe file rather than a mode bit; - a relative legacy override is refused as 'mount path should be absolute'; - backups and scratch space that are not mounted are warned about, not refused, because an S3-only deployment keeps a local scratch dir. The compose files, OIDC examples and deployment docs drop both variables. The override is still read when the mount table is unavailable (a Docker socket proxy that forbids container reads) and is reported as deprecated; when it disagrees with the detected mount the mount wins and the log says so. Verified in disposable containers against the WSL daemon: mounted data dir starts and logs the detected mapping; no data mount, read-only mount and a relative override each stop with the expected message; an unmounted backup dir starts with a warning.
The filesystem type is only used to exclude virtual mounts while parsing, so keeping it on the struct tripped the unused linter.
errcheck holds new code to the full standard; the read-only open is best-effort but the close still has to be acknowledged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the two deployment asks: the variables are no longer needed, and the mapping is validated as the stack comes up.
The variables are gone
CARBONPANEL_HOST_DATA_PATHandCARBONPANEL_DATA_DIRrestated the compose volume mapping by hand, so they could silently disagree with the mount they described. At startup the panel now inspects its own container (docker inspect $HOSTNAME) and reads the host source of/app/data.docker.TranslateToHostPathuses that mapping, so a server directory seen at/app/data/servers/xis requested as<host source>/servers/x.Removed from
docker-compose.yml, all four OIDC examples, the manual-review harness,README.md,DESIGN.mdand the four getting-started pages.Validity is checked as compose spins up
no write permission on the mount dirCARBONPANEL_HOST_DATA_PATHmount path should be absoluteThe mount-presence check reads
/proc/self/mountinfoand runs before storage initialisation, so a missing volume fails without writing anything into the container layer. The daemon-backed check still runs afterwards and covers platforms without mountinfo.Compatibility
The override is still read when the mount table cannot be read — a Docker socket proxy that forbids
GET /containers/**would otherwise break a working deployment — and is logged as deprecated.CARBONPANEL_DATA_DIRis only consulted in that same fallback;storage.data_diris the source of truth.Verification
Disposable containers against the WSL daemon (29.3.0), with a freshly cross-built Linux binary:
Server data directory /app/data maps to /tmp/cpm/data on the Docker host (container mount), then starts;no write permission on the mount dir;CARBONPANEL_HOST_DATA_PATH=opt/carbon-panel/data→ refuses withmount path should be absolutebefore migrations run;CARBONPANEL_HOST_DATA_PATH=/srv/stalewith a mounted data dir → detects/tmp/cpm/data, warns that the variable disagrees;go build ./...,go vet ./...,go test ./...and knowledge-lint (10/10) pass. New tests cover the mountinfo parser, the covering-mount rule, each refusal, the override precedence, andSelfMountsagainst a fake daemon.