fix(starter): route /api/models to report-worker instead of orchestrator WS#37
Open
borisnieuwenhuis wants to merge 4 commits into
Open
fix(starter): route /api/models to report-worker instead of orchestrator WS#37borisnieuwenhuis wants to merge 4 commits into
borisnieuwenhuis wants to merge 4 commits into
Conversation
…tor WS The /api/models rewrite pointed to MODEL_ORCHESTRATOR_URL which is a WebSocket endpoint, causing 'Upgrade Required' errors on REST requests. Route to the report-worker's /reports/models REST API instead.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
The Next.js container doesn't have Docker access. Proxy SSE log
streams to the report-worker's /logs/{container} endpoint instead.
The model orchestrator serves the full model list (with builder_log_uri and runner_log_uri) as well as the log proxy endpoints. The report-worker's model list is still accessible via /reports/models through the catch-all API rewrite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
/api/modelsrewrite innext.config.tspointed toMODEL_ORCHESTRATOR_URLwhich is a WebSocket endpoint, causingUpgrade Requirederrors on REST requests from the frontend.Routes to the report-worker's
/reports/modelsREST API instead.Analysis
Here's what I found after reading both the PR and the full codebase:
Architecture
The model-orchestrator runs two separate servers:
┌────────────────────┬───────────────────────┬──────────┬────────────────────────────────────────┐
│ Server │ Port │ Protocol │ Purpose │
├────────────────────┼───────────────────────┼──────────┼────────────────────────────────────────┤
│ WebSocket server │ configurable (e.g. │ WS │ Streams model state changes in │
│ │ 8000) │ │ real-time │
├────────────────────┼───────────────────────┼──────────┼────────────────────────────────────────┤
│ Local Deploy REST │ 8001 (hardcoded) │ HTTP │ CRUD for models — only started in │
│ API │ │ │ local/dev mode │
└────────────────────┴───────────────────────┴──────────┴────────────────────────────────────────┘
The next.config.ts rewrite /api/models → MODEL_ORCHESTRATOR_URL/models currently hits the WS
server, which explicitly rejects non-upgrade requests with 426 Upgrade Required.
What the WS server provides
Connect to ws://:/<crunch_id> and you get:
What the models table needs
The ModelsTable currently renders: ID, model_name, cruncher_name, status, desired_state (with a
toggle switch), plus log URIs for the logs dialog.
The WS messages are missing several fields the table depends on:
BUILDER_FAILED, etc.)
The crunch_id problem
The WS requires /<crunch_id> in the connection path. The starter app currently has no concept of
which crunch it belongs to — it just calls GET /models and gets everything back.
My recommendation
A pure WS replacement won't work today without backend changes, because the WS messages don't
carry enough data for the table. There are two realistic paths:
Option A — Hybrid (best UX, more work)
statusMessage, and log URIs (same shape as the REST GET /models response)
ws://<MODEL_ORCHESTRATOR_URL>/<crunch_id>, populates state from init, and merges update events
the Next.js rewrite
crunch to subscribe to
This gives you instant real-time updates instead of the current 30-second polling, and the table
stays fully functional.
Option B — Accept PR #37 (quick fix, no real-time)
Route /api/models to the report-worker's REST endpoint. The table keeps polling every 30 seconds
like it does now. Simple, works, but no streaming.
My suggestion
Option A is the right direction, but it requires a small backend change first: enrich the WS
_create_model_state_message in websocket_server.py to include the missing fields (desired_state,
status, statusMessage, log URIs). That's ~15 lines of Python. After that, the frontend hook is
straightforward.