Decommission ol-home
Our old ol-home server has an nginx running that proxies to ol-home0. We likely don't need this anymore? But if I recall correctly, when we tried to update all our docker containers to point to ol-home0, something didn't work. Investigation needed.
To close:
- [ ] 1) check all occurrences of
ol-homein olsystem and openlibrary. Change any occurrence ofol-home:7000tool-home0:7000.- [x]
git grep ol-home--> All instances areol-home0except filedocker/ol-home-start.shwhich looks OK. - [x] #4426
- [x] #7816 (pull request)
- [x] internetarchive/olsystem#122
- [x] internetarchive/olsystem#178
- [x] internetarchive/olsystem#180 Done in the
cron-jobsDocker container. - [x] #7817
- [ ] internetarchive/olsystem#174
- [x]
- [x] 2) Patch Deploy this to our servers as a test and restart docker containers one by one (See deployment guide). If everything works, woohoo! Test borrowing/editing works.
- [ ] 3) Try removing the proxy in
olsystem/etc/nginx/sites-available/infobase.confon the old server ol-home (seegit diffin that server/repo) and restarting nginx on that server. If everything works, woohoo! We're done.- [x] Did
- [x] Undid because of #7920
Stakeholders
@mekarpeles
Why is macOS Control Center listening on ports 5000 and 7000? https://developer.apple.com/forums/thread/682332
I expect Apple to switch to less controversial ports in the future but if other macOS users bump into this, they can disable AirPlay Receiver to get access to port 7000.
To re-iterate the problem, if ol-web[0-2] or ol-covers0 need infogami (i.e. ol-home) and they make a request currently to ol-home which routes to ol-home0 to get around an issue where... currently containers on ol-home0 also need to hit ol-home in order to then get into ol-home0 infobase.
In this setup, ol-web[0-2] and ol-covers0 don't actually need ol-home, it's ol-home0 that do.
So the solution is to have everything use ol-home but for any containers on ol-home0 to overwrite (via an ENV variable or logic in ol config script) the infobase_server from e.g. ol-home:7000 (i.e. the server) to infobase:7000 (i.e. the docker container).
Once we do this, we can decomission ol-home (which just exists for ol-home0 to get around the host / docker contention).
ol-home prompt for Claude; docker container on ol-home0 tries to make a request to ol-home0.us.archive.org (creates a network circle). Desired end-state is for ol-web* and ol-www0 to use ol-home0 w/o ol-home as a proxy. Web heads are fine. Containers on ol-home0 (e.g. infobase dies because it tries to make requests to ol-home0 – i.e. its own host). Infobase could hit “localhost” or the docker-compose service… But this would break from web-heads. We only have one field in yml (which doesn’t work for both ol-web[0-3] and ol-home0.
We could have an env override for any container that runs on ol-home0 (e.g. solr-updater, import-bot, crons, etc)
Discovery Trail (Ada)
- Correction:
internetarchive/olsystem#174is CLOSED, not open — closed unmerged 2024-02-10. It attempted a blanketol-home→ol-home0rename across olsystem, includinginfobase_server: "ol-home0:7000". @cdrini blocked it: "we can't merge this until we fix those networking issues; otherwise things will break during the next deploy" — i.e. the same self-referential-host problem would just move fromol-hometool-home0. This is why it stalled: the fix needs to be host-conditional, not a single shared value change. - Confirmed:
infobase_serveris read in exactly one place at the Python layer —infogami.load_config()setsconfig.infobase_serverfrom a plainyaml.safe_load(no env-var interpolation exists today). Every consumer funnels throughopenlibrary/config.py:load_config(): the main app (openlibrary/plugins/openlibrary/connection.py),scripts/solr_updater/solr_updater.py,scripts/affiliate_server.py, andscripts/manage-imports.py(import-bot). Single natural chokepoint for a fix. - Confirmed existing hook:
compose.production.yamlsetshostname: "$HOSTNAME"on every service;scripts/deployment/deploy.sh'sssh_docker_compose()already threads the real per-host$HOSTNAME(e.g. literallyol-home0when run there) intodocker composeat deploy time — zero new olsystem files needed. Since Compose'shostname:sets the container's actual UTS-namespace hostname,socket.gethostname()inside any prod container today already reflects the real host it's running on. ol-home0-profile services incompose.production.yaml:solr_haproxy,cron-jobs,infobase,infobase_nginx,affiliate-server,solr-updater,importbot,monitoring. Of these,cron-jobs,affiliate-server,solr-updater,importbotact as Infobase clients and are the ones affected.olsystem/etc/openlibrary.yml:339andetc/coverstore.yml:65(trusted-host allowlists) already list bothol-home:7000andol-home0:7000— no change needed there.
Plan to follow, favoring the existing $HOSTNAME/hostname mechanism over any new per-host olsystem file, per your 2026-07-13 comment.
Validation Plan (Ada) — smallest atomic fix for the "left" part of this issue (host-level infobase_server override; the historical solr/rsync/cron cleanup items are already done).
Approach
Add a single, host-conditional override for infobase_server, applied at config-load time in openlibrary/config.py::load_config() — the one chokepoint every consumer (main app's OLConnection, solr_updater.py, affiliate_server.py, manage-imports.py/import-bot) already goes through.
Rule: if the container's own hostname is ol-home0 (or ol-home0.*), always talk to Infobase via the docker-compose service name infobase:7000 (same-network hop, no external host, no loop) — regardless of what infobase_server says in the shared olsystem/etc/openlibrary.yml. Every other host is unaffected and keeps reading infobase_server as-is (ol-home:7000 today).
This needs zero new env vars, zero olsystem changes, zero compose/deploy.sh changes — it reuses hostname propagation that's already fully working today: compose.production.yaml's existing hostname: "$HOSTNAME" + deploy.sh's existing per-host $HOSTNAME threading. I confirmed empirically (docker run --hostname ol-home0-test ...) that Docker's hostname: directive sets both socket.gethostname() and a HOSTNAME env var inside the container, so this is a pure application-layer change with no new infra plumbing. It satisfies your "no per-host olsystem file" constraint by construction — the shared yaml value never needs to change.
Files to modify
openlibrary/config.py— add_is_ol_home0()+ apply override right afterinfogami.load_config(config_file).openlibrary/tests/test_config.py(new) — unit tests below.
Tests to write (input → expected output)
- hostname=
ol-home0,infobase_server=ol-home:7000→ override applies →infobase:7000 - hostname=
ol-home0.us.archive.org(FQDN form) → override still applies →infobase:7000 - hostname=
ol-web1→ no override → staysol-home:7000 - hostname=arbitrary dev/CI container id → no override → unaffected (dev already uses
infobase:7000directly, perconf/openlibrary.yml) - no
infobase_serverkey set at all → no-op, no crash
Success criteria
- Automated: new unit tests + full existing suite green in Docker.
- Manual, locally verifiable: run local docker-compose with
HOSTNAME=ol-home0simulated, confirm the resolvedinfobase_serverinside a container isinfobase:7000; confirm it's unaffected withHOSTNAMEunset/other. - NOT locally verifiable — flagging explicitly per your ask: real behavior on the actual
ol-home0box against the real Infobase, actual elimination of the network loop against the realol-homenginx proxy, and interaction with real solr-updater/import-bot/cron traffic. Per the issue's own step 2, this needs you (or someone with host access) to patch-deploy and restart containers one by one, and test borrowing/editing on real infra. I will not mark this ready assuming that's true — it'll be called out as a required manual step.
Out of scope for this PR
- Removing
ol-home's nginx proxy or decommissioning the box itself (issue checklist item 3) — only after the override is verified on real infra. - Any
olsystemchanges — not needed for this approach. - Trimming
ol-home:7000from the trusted-host allowlists (olsystem/etc/openlibrary.yml:339,etc/coverstore.yml:65) — leave untilol-homeis actually gone.
Risks
- If the real
ol-home0box's hostname string differs from what I'm assuming (short name vs FQDN, casing), the override silently no-ops and the loop persists — fails safe, but worth a sanity check in review. - This is production request-routing; I don't have host access and won't attempt SSH there — real-host verification remains an open, explicit manual step before this issue can close.
Favors your stated preference for the existing $HOSTNAME deploy-time mechanism over a new per-host olsystem file. Awaiting approval before writing any code.
Note (Ada): AGENTS.md's standard phase-gate label, `Needs: Approval`, doesn't exist in this repo's label set. Impact: None to this issue's progress — used the closest real equivalent, `Needs: Staff Decision` ("Issues that are blocked on a staff member's decision"), instead. Resolution: Applied `Needs: Staff Decision`. Updating `ada/AGENTS.md` to reference the correct label name so future Adas don't hit the same failed edit.
Proceed — I'm fine with this moving forward without a separate formal review cycle, per the same call on pr-12831. The plan posted above (host-conditional infobase_server override, keyed on hostname) looks right to me; go ahead and implement, verify what you can locally, and flag anything that needs real host access before merge.
This should be merged, the last step is checking whether the server has any files on it that are necessary to keep around and then turning it off