Repository navigation
fix(compose): stop a crash filling the card with core dumps - #3418
Merged
Merged
Conversation
A process that crashes inside a container writes `core.<pid>` into its working directory. That is `WORKDIR /usr/src/app`: inside the container, on no mount, and reachable by no cleanup we have. The host's `core_pattern` is the kernel default `core`, a relative path, and `core_uses_pid=1` means every crash adds a file rather than replacing one. `ulimit -c` is `unlimited` in a container by default, so nothing bounds it. The result is invisible: `docker images` does not list it and `docker image prune` cannot touch a live container's writable layer, so the space goes missing with nothing to account for it. A device in the field reached 24.2 GB of dumps in anthias-celery before its card filled. - Set `ulimits: core: 0` on every service in all three compose templates, as one anchor aliased everywhere so the rule cannot drift between services or between deployments. - Add tests asserting every service in every template resolves to `core: 0`, since the real risk is a sixth service added later by someone who does not know this rule exists. Changing the service definition also recreates the containers on the next upgrade, which discards the layer holding any dumps already there. Measured on a Pi 4: before, three crashes left three files of 4,861,952 bytes each and grew the layer from 1.21 MB to 11.4 MB. After, six crashes across celery and server left none, and the worker stayed healthy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
|
vpetersson
approved these changes
Oct 24, 2026
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.



Issues Fixed
Fixes #3417.
Description
A process that crashes inside a container writes
core.<pid>into its working directory. That isWORKDIR /usr/src/app: inside the container, on no mount, and reachable by no cleanup we have. The host'score_patternis the kernel defaultcore, a relative path, andcore_uses_pid=1means every crash adds a file rather than replacing one.ulimit -cisunlimitedin a container by default, so nothing bounds it.The result is invisible.
docker imagesdoes not list it, anddocker image prunecannot touch a live container's writable layer, so the space goes missing with nothing to account for it. A device in the field reached 24.2 GB of dumps inanthias-celerybefore its card filled: https://forums.screenly.io/t/sd-card-completely-full/6778ulimits: core: 0on every service in all three compose templates, written as one anchor aliased everywhere else so the rule cannot drift between services or between the Debian and balena deployments.core: 0. The real risk is a sixth service added later by someone who does not know this rule exists, so the test also checks the three templates agree on which services exist.Changing the service definition also recreates the containers on the next upgrade, which discards the layer holding any dumps already accumulated. That is what repairs devices already affected.
Verification
Pi 4 testbed, Docker 29.6.1, containerd image store. Deployed through the real
envsubstpath rather than by hand editing the generated compose file.Before, crashing Python three times inside
anthias-celery:That size is what ties it to the field report: 4992 added paths under
/usr/src/appthere, and4992 x 4861952 = 24.3 GBagainst the 24.2 GB observed.After, with the patched template rendered and the stack brought up:
Six crashes across celery and server then produced zero core files, and every writable layer stayed at its normal size (467kB / 1.21MB / 1.24MB / 4.1kB). Stack healthy afterwards:
/api/v2/assets200, celery1 node online, viewer generating its asset list with both CEC adapters present. Testbed restored to baseline and its lock released.Also confirmed the new test fails if a service loses the alias, rather than passing vacuously.
Tradeoff
This gives up core dumps on devices. Sentry already reports crashes, and nobody debugs a core file on a field SD card, so the dumps bought nothing while costing the card.
docker-compose.dev.ymlanddocker-compose.test.ymlare deliberately untouched: those run on workstations with room to spare, where a dump is actually useful.Why the worker was crashing in the first place is a separate question and not addressed here. A crash should not cost the device its storage whatever the crash is.
Checklist
🤖 Generated with Claude Code