Skip to content

Overlay per-deployment config instead of editing the tracked copies - #16

Merged
danielplohmann merged 2 commits into
familiary:mainfrom
r0ny123:fix/config-overlay
Sep 23, 2026
Merged

danielplohmann merged 2 commits into
familiary:mainfrom
r0ny123:fix/config-overlay

Conversation

@r0ny123

@r0ny123 r0ny123 commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

This is stacked on #13 and will be rebased once that merges; 388e014 is the commit to read, everything before it belongs to that pull request. Both MCRIT containers mounted the tracked config/ directory read-only over the installed package's mcrit/config/, which meant that setting anything a deployment actually needs - an AUTH_TOKEN, an external MongoDB, a different cache budget - was an edit to files this repository tracks. Every subsequent pull then either conflicted with those edits or silently reverted them, and config/ stopped being a default anyone could review, because in practice no deployment was running it unmodified.

The containers now assemble their configuration rather than mounting it. config/ is mounted at /opt/mcrit/config.default and an untracked config.local/ at /opt/mcrit/config.local, and entry_common.sh, sourced by all three entry scripts, copies the defaults into the package's config directory and then copies the overlay on top. Whole modules are copied rather than merged, which is the honest granularity for Python configuration: a file in config.local/ is a copy of the shipped module with some values changed, so the mechanism has no way to be subtly wrong about what won. .gitignore keeps everything in that directory out of commits except a README explaining it. The development compose file keeps the old read-only mount, because /opt/mcrit is a host checkout there and assembling would write into the developer's own working tree. Assembling makes a second problem visible, and the same script reports it: the image keeps the stock configuration the installed MCRIT ships at /opt/config.stock, and at startup each container compares the module-level and class-level upper-case names of every stock module against the assembled one and prints a warning for each module that has fallen behind. It warns rather than fails, since a missing setting means running on something other than an upstream default, not a reason to refuse to start.

Verified on a stack built from this branch: all five services come up healthy, the assembled mcrit/config/ holds the eight shipped modules, the test entrypoint passes 191 unit tests with 91 mongo tests deselected, and no drift warning appears for the configuration as shipped, which is the case that matters. The warning was exercised by putting a copy of StorageConfig.py into config.local/ with STORAGE_MONGODB_FLAGS deleted, which produced exactly that name in the warning; adding a second, deliberately unparsable override showed it reported by name while the first module's warning still printed, so one broken file does not hide the rest. The development compose file was run end to end as well: the API answers on 8000, MCRITweb on 5000, and no assembly happens there. shellcheck and hadolint are clean.

The check reads names, not values, so a setting present with a stale value is not drift it can see, and it does not look for settings the deployment defines that MCRIT has dropped. It parses rather than imports, which is why it cannot be fooled by a module that has side effects but also why it only sees assignments and not anything computed. Names bound inside function bodies are ignored, since an upper-case name there is a local. The overlay itself has no merge and no templating; a deployment that wants one value changed still copies a whole module and carries the rest of it, which is a deliberate trade against a configuration format this repository would then own.

Closes #8

Both MCRIT containers mounted the tracked config/ read-only over the installed
package's mcrit/config/, so the only way to set a deployment's own values -
an AUTH_TOKEN, an external MongoDB - was to edit files this repository tracks.
Every pull then either conflicted with those edits or quietly reverted them,
and config/ stopped being a reviewable default.

The containers now assemble their configuration instead of mounting it:
config/ is mounted at /opt/mcrit/config.default and the untracked config.local/
at /opt/mcrit/config.local, and entry_common.sh, sourced by all three entry
scripts, copies the defaults into the package's config directory and then
copies the overlay on top. A file in config.local/ replaces the shipped module
of the same name, so it is copied whole rather than merged; .gitignore keeps
everything there out of commits except the README explaining it. The
development compose file keeps the old read-only mount, because /opt/mcrit is
a host checkout there and assembling would write into the developer's tree.

Assembling makes a second problem visible: an MCRIT upgrade can define
settings that config/ has not caught up with, and the assembled module then
silently lacks them. The image keeps the stock configuration at
/opt/config.stock, and the startup check compares the module-level and
class-level upper-case names of each stock module against the assembled one,
printing a warning per module that has fallen behind. It does not descend into
function bodies, where an upper-case name is a local, and a module that fails
to parse is reported and skipped so one broken override does not hide the
rest. It warns rather than fails: a missing setting means running on something
other than an upstream default, which is not a reason to refuse to start.

Verified on a built stack: all services come up healthy, the assembled
mcrit/config/ holds the eight shipped modules, /entry_test.sh passes 191 tests
with 91 deselected, and no warning appears for the configuration as shipped.
Dropping STORAGE_MONGODB_FLAGS from a config.local/StorageConfig.py produced
the expected warning, and an unparsable second override was reported by name
while the first warning still printed. The development compose file was run
end to end: the API answers on 8000, MCRITweb on 5000, and no assembly
happens. shellcheck and hadolint are clean.

Closes #8
danielplohmann
danielplohmann previously approved these changes Sep 23, 2026

@danielplohmann danielplohmann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — CI green (build-test, lint, changelog gate, TUNING.md mirror). Reviewed in detail on #13; the increments here are small and sit on that base.

@r0ny123
r0ny123 dismissed danielplohmann’s stale review September 23, 2026 14:34

The merge-base changed after approval.

@danielplohmann
danielplohmann merged commit 0af1c79 into familiary:main Sep 23, 2026
4 checks passed
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.

Tracked config/ collides with per-deployment tuning: every pull conflicts, and 'git checkout -- config/' silently disables optimisations

2 participants