fix(config): host-conditional infobase_server override for ol-home0#13182
fix(config): host-conditional infobase_server override for ol-home0#13182mekarpeles wants to merge 3 commits into
Conversation
Containers running on ol-home0 itself (solr-updater, import-bot, cron-jobs, affiliate-server) resolve infobase_server to the shared ol-home:7000 value, which proxies back to ol-home0 and loops on the host it started from. Only override on ol-home0; every other host is unaffected. See #5143. Pre-commit exception: mypy fails on host (needs Docker; confirmed clean via `docker compose run --rm home python -m mypy`) and generate-pot fails structurally in a git worktree (.git file points to an absolute host path not mounted in the container) -- no new translatable strings added, so this is the documented worktree limitation, not skipped verification.
for more information, see https://pre-commit.ci
|
Note (Ada): No Copilot review ever appeared on this PR (0 review threads, 0 reviews of any kind ~16 min after PR open), and explicitly requesting it ( |
Closes the code-side portion of #5143 (see scope note — the box/nginx decommission itself is a separate, later step).
What this does
Adds a host-conditional override for
infobase_server, applied once at config-load time inopenlibrary/config.py::load_config()— the single chokepoint every consumer (main app'sOLConnection,solr_updater.py,affiliate_server.py,manage-imports.py/import-bot) already goes through.If the container's own hostname is
ol-home0(orol-home0.*), it always talks to Infobase via the docker-compose service nameinfobase:7000— a same-network hop, no external host, no loop. Every other host is unaffected and keeps readinginfobase_serverfromolsystem/etc/openlibrary.ymlexactly as it does today (ol-home:7000).No new env vars, no
olsystemchanges, nocompose.production.yaml/deploy.shchanges — it reuses hostname propagation that already works today (hostname: "$HOSTNAME"on every prod service +deploy.sh's per-host$HOSTNAMEthreading).Plan: #5143 (comment)
Approved by @mekarpeles: #5143 (comment)
Verified locally
openlibrary/tests/test_config.py, 7 cases): short hostname, FQDN form, non-ol-home0 host, arbitrary dev/CI hostname, no-infobase_server-configured no-op.docker compose run --rm -e HOSTNAME=ol-home0 home python3 -c "..."→ override applies, resolves toinfobase:7000. Same withHOSTNAME=ol-web1→ staysol-home:7000.--doctest-modulesviamake test), JS 457/457, i18n validation passed.HTTP 200onlocalhost:8080before and after the change (Python-only change,docker compose restart web).mypyclean viadocker compose run --rm home python -m mypy openlibrary/config.py openlibrary/tests/test_config.py.git diff origin/master..HEAD | grep -iE "(password|secret|token|api_key)\s*="— no matches).Pre-commit: all hooks pass except
mypy(host-side; confirmed clean in Docker above) andgenerate-pot(fails structurally for any worktree checkout —.gitfile points to an absolute host path not mounted in the container; no new translatable strings added). Committed with--no-verifyfor those two only, noted in the commit message.Not applicable: browser/a11y verification — this is a backend config-loading change with no frontend/template surface.
NOT verifiable locally — required before merge
This entire fix rests on one assumption I cannot test without real host access: that
infobase:7000actually resolves correctly from cron-jobs/solr-updater/importbot/affiliate-server's network namespace on the realol-home0box. I have no access tool-home,ol-home0, or any other prod/staging host and have not attempted to SSH there.Per the issue's own step 2, this needs a patch-deploy test on real infra — restart the affected containers one by one on
ol-home0and confirm cron/solr-updater/import-bot/affiliate-server can still reach Infobase, then test borrowing/editing end-to-end — before this can be considered proven, not just "should work."Out of scope for this PR
ol-home's nginx proxy or decommissioning the box itself (issue checklist item 3) — only after the override above is verified on real infra.olsystemchanges — not needed for this approach.ol-home:7000from the trusted-host allowlists (olsystem/etc/openlibrary.yml:339,etc/coverstore.yml:65) — leave untilol-homeis actually gone.