Skip to content

fix(ai): a saved gateway route table keeps only failover state, so a changed default route reaches every machine - #2364

Merged
dan-petty merged 1 commit into
mainfrom
fix/2045-gateway-routes-defaults
Oct 27, 2026
Merged

dan-petty merged 1 commit into
mainfrom
fix/2045-gateway-routes-defaults

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The gateway router loaded a saved route table from <data dir>/agent/gateway_state.json in place of DEFAULT_GATEWAY_ROUTES. No command refreshed that table when default routes changed in the code. A change to default routes never reached a machine that already held a saved state file.

  • Make _save_gateway_state write only failover routes (routes whose backend_type starts with failover:) to gateway_state.json.
  • Make _load_gateway_state start with _build_default_routes() and overlay only saved failover routes. Ignore any non-failover route present in an existing saved state file.
  • Update test_failover_reset_restores_the_default_routes, _write_routes_with_a_small_coder, and _default_route_file to expect an empty failover route list when no routes are in failover.
  • Add tests in tests/test_ai_gateway.py to confirm that saved old default routes do not override current defaults and that saved failover routes persist on restart.

Closes #2045

Change: openspec/changes/archive/2026-10-27-2045-gateway-routes-defaults/

@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass check run

devops ci fail-to-pass --base origin/main:

5 failed on base (5 failed and 26 passed in tests/test_ai_gateway.py; 0 errored).
  failed on base: tests.test_ai_gateway.TestGatewayRouter::test_saved_file_with_old_default_route_uses_current_defaults (AssertionError: assert ('qwen2.5-coder:7b', 'ollama') == ('qwen3.8:27b', 'ollama'))
  failed on base: tests.test_ai_gateway.TestGatewayRouter::test_saved_failover_route_persists_after_restart (StopIteration)
  failed on base: tests.test_ai_gateway.TestGatewayRouter::test_failover_reset_restores_the_default_routes
  failed on base: tests.test_ai_gateway.TestFastMCPGatewayTools::test_fastmcp_gateway_failover_resets_the_routes
  failed on base: tests.test_ai_gateway.TestAIGatewayCLI::test_failover_reset_command

…changed default route reaches every machine

The gateway router loaded a saved route table from `<data dir>/agent/gateway_state.json` in place of `DEFAULT_GATEWAY_ROUTES`. No command refreshed that table when default routes changed in the code. A change to default routes never reached a machine that already held a saved state file.

- Make `_save_gateway_state` write only failover routes (routes whose `backend_type` starts with `failover:`) to `gateway_state.json`.
- Make `_load_gateway_state` start with `_build_default_routes()` and overlay only saved failover routes. Ignore any non-failover route present in an existing saved state file.
- Update `test_failover_reset_restores_the_default_routes`, `_write_routes_with_a_small_coder`, and `_default_route_file` to expect an empty failover route list when no routes are in failover.
- Add tests in `tests/test_ai_gateway.py` to confirm that saved old default routes do not override current defaults and that saved failover routes persist on restart.

Closes #2045

Change: `openspec/changes/archive/2026-10-27-2045-gateway-routes-defaults/`
@dan-petty
dan-petty force-pushed the fix/2045-gateway-routes-defaults branch from 69d63df to 4795a61 Compare October 27, 2026 18:35
@dan-petty
dan-petty marked this pull request as ready for review October 27, 2026 18:42
@dan-petty
dan-petty merged commit 8317526 into main Oct 27, 2026
16 checks passed
@dan-petty
dan-petty deleted the fix/2045-gateway-routes-defaults branch October 27, 2026 18:43
dan-petty pushed a commit that referenced this pull request Oct 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.7.3](v0.7.2...v0.7.3)
(2026-10-27)


### Bug Fixes

* **ai:** a saved gateway route table keeps only failover state, so a
changed default route reaches every machine
([#2364](#2364))
([8317526](8317526))
* **k8s:** delete unused portkey routing configmap
([#2363](#2363))
([15bd601](15bd601))
* **telemetry:** export created timestamps for cluster job counters
([#2039](#2039))
([#2366](#2366))
([cc34caa](cc34caa))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.

fix(ai): a saved gateway route table keeps only failover state, so a changed default route reaches every machine

1 participant