3.2 KiB
Modular Hub Migration Playbook
This playbook describes how to cut a hub over from the shared legacy adapter to a dedicated module using the new rollout flags, diagnostics endpoint, and structured logs delivered in feature 004-modular-proxy-cache.
Prerequisites
- Target module must be registered via
hubmodule.MustRegisterand expose a proxy handler throughproxy.RegisterModuleHandler. config.tomlmust already map the hub to its target module through[[Hub]].Module.- Operators must have access to the running binary port (default
:5000) to query/-/modules.
Rollout Workflow
-
Snapshot current state
Runcurl -s http://localhost:5000/-/modules | jq '.hubs[] | select(.hub_name=="<hub>")'to capture the currentmodule_keyandrollout_flag. Legacy hubs reportmodule_key=legacyandrollout_flag=legacy-only. -
Prepare config for dual traffic
Edit the hub block to target the new module while keeping rollback safety:[[Hub]] Name = "npm-prod" Domain = "npm.example.com" Upstream = "https://registry.npmjs.org" Module = "npm" Rollout = "dual"Dual mode keeps routing on the new module but keeps observability tagged as a partial rollout.
-
Deploy and monitor
Restart the service and tail logs filtered bymodule_key:jq 'select(.module_key=="npm" and .rollout_flag=="dual")' /var/log/any-hub.jsonEvery request now carries
module_key/rollout_flag, allowing dashboards orgrep-based analyses without extra parsing. -
Verify diagnostics
Query/-/modules/npmto inspect the registered metadata and confirm cache strategy, or/-/modulesto ensure the hub binding reflectsrollout_flag=dual. -
Promote to modular
Once metrics are healthy, changeRollout = "modular"in config and redeploy. Continue monitoring logs to make sure bothmodule_keyandrollout_flagshow the fully promoted state. -
Rollback procedure
To rollback, setRollout = "legacy-only"(without touchingModule). The runtime forces traffic through the legacy module while keeping the desired module declaration for later reattempts. Confirm via diagnostics (module_keyreverts tolegacy) before announcing rollback complete.
Observability Checklist
- Logs: Every proxy log line now contains
hub,module_key,rollout_flag, upstream status, andrequest_id. Capture at least five minutes of traffic per flag change. - Diagnostics: Store JSON snapshots from
/-/modulesbefore and after each rollout stage for incident timelines. - Config History: Keep the
config.tomldiff (especiallyRolloutchanges) attached to change records for auditability.
Troubleshooting
- Error:
module_not_foundduring diagnostics → module key not registered; ensure the module package’sinit()callshubmodule.MustRegister. - Requests still tagged with
legacy-onlyafter promotion → double-check the running process uses the updated config path (ANY_HUB_CONFIGvs--config) and restart the service. - Diagnostics 404 → confirm you are hitting the correct port and that the CLI user/network path allows HTTP access; the endpoint ignores Host headers, so
curl http://127.0.0.1:<port>/-/modulesshould succeed locally.