Repository navigation
Conversation
First switchboard module (roadmap 2.3). GET /v1/models and
GET /v1/models/{id} list only the models the calling key may use. The list
is derived from the gateway's own config, so it cannot drift from what
Higress enforces: per-model Ingresses matched on the model-router header
(higress.io/exact-match-header-x-higress-llm-model) plus the key-auth
WasmPlugin, watched through informers with read-only access. Enforcement
stays in Higress; switchboard only lists.
Derivation mirrors Higress source in two stages: the controller turning the
WasmPlugin CR into the plugin's JSON (convertIstioWasmPlugin: pluginConfig
verbatim, configDisable, defaultConfigDisable), and the plugin parsing and
matching it (route_rule_matcher.h, key_auth parsePluginConfig and
checkAllowSet). First matching rule wins; a rule without allow admits
nobody; rule-local consumers replace the global set and ignore allow;
unmatched routes are only authenticated under global_auth: true; configs the
plugin rejects list nothing. Ingress class, route names, host and wildcard
matching follow Higress/Envoy. Routes key-auth does not authenticate are
listed for nobody and logged; service-scoped rules and prefix/regex model
routes are skipped with a warning.
The API uses the OpenAI shape, reads the consumer from X-Mse-Consumer (401
without it), and answers 404 alike for missing and disallowed models.
Also: CI (gofmt, vet, tests, LICENSE/credential gate), per-platform image
check, tag-driven release to 4pdosc/switchboard, Dockerfile with mirrorable
base images, design doc and deployment doc (RBAC, Service, NetworkPolicy,
the /v1/models route, and the key-auth requirement on that route).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@zoboth please review, thanks. |
zoboth
left a comment
There was a problem hiding this comment.
No blockers. The diff is tightly scoped to what the description promises: a read-only, informer-backed catalog, a key-auth/Ingress derivation that mirrors the stated Higress semantics, and an OpenAI-shaped /v1/models + /v1/models/{id} handler. CI (gofmt/vet/test), the image-arch check, the release workflow and the Dockerfile all look correct and appropriately scoped (pinned actions, minimal permissions:, no secrets exposed). go.mod deps are the expected k8s client-go set.
Walked internal/gateway/{route,keyauth,catalog,watch}.go and internal/api/models.go line by line against docs/models-api-design.md's derivation table, including the trickier ones (rule-local consumers under global_auth: false, pluginConfig verbatim override, ingress vs. domain category precedence, wildcard host suffix matching). Everything checked out, and the tests exercise the documented edge cases (401/404/503, / in model ids, live allow edits, several/zero key-auth plugins).
Non-blocking notes:
keyauth.go'scategory()gives a rule that sets bothingressandserviceits own bucket (catRouteAndService), whichAllowed()then treats the same as a pureservicerule: never matching. The design doc's stated priority rule ("a lower category on the same rule is ignored") is demonstrated foringress+domaininTestKeyAuthMirror("ingress and domain on one rule: route category, domain ignored"), but there's no equivalent case foringress+service, so it's not clear from the diff alone whether folding it into "never matching" is intentional (a conservative stand-in for the already-declared "service rules are never treated as matching" limit) or an oversight relative to the general precedence rule. Worth a one-line comment or a test pinning the intent, since it's a real behavior choice rather than an obviously-safe default (it does fail closed either way — the model just gets listed for nobody — so it's not a correctness blocker).- Matches the PR's own disclosure: the kind test against a real Higress controller hasn't run yet, so the three gateway-side assumptions (header re-matching order,
Hostpassthrough, Envoy wildcard semantics) are still unverified end-to-end. That's explicitly called out as not done rather than claimed, so it doesn't block this PR, just flagging that roadmap item 2.3 isn't closed by this alone (the PR says as much).
🤖 Generated with Claude Code
What type of PR is this?
What this PR does and why
First switchboard module (roadmap 2.3):
GET /v1/modelsandGET /v1/models/{id}, listing only the models the calling key may use.The list is derived from the gateway's own config, never hand-maintained, so it cannot drift from what Higress enforces. Enforcement stays in Higress, unchanged: model-router copies the body
modelintox-higress-llm-model, per-model Ingresses match on that header, and key-authallowlists gate each route. switchboard only lists.Source: per-model Ingresses (
higress.io/exact-match-header-x-higress-llm-model: <model>) plus the key-auth WasmPlugin. Both are watched through informers with read-only RBAC, so changes apply without a restart.Derivation mirrors Higress source in two stages:
convertIstioWasmPlugin:pluginConfigused verbatim,configDisable,defaultConfigDisable);route_rule_matcher.h, key_authparsePluginConfig/checkAllowSet).Semantics worth knowing:
allowadmits nobody. This differs from the earlier design note, which assumed everyone.consumersreplace the global set and ignoreallow.global_auth: true.nameinhigress-system, otherwisens/name) and host/wildcard matching follow Higress and Envoy.API: OpenAI shape. The consumer comes from
X-Mse-Consumer; a request without it gets401.404 model_not_foundis the same for missing and disallowed models, so callers can't probe which models exist.Also included:
X.Y.Ztag pushes4pdosc/switchboard.Deployment requirement the chart cannot own: key-auth must authenticate the
/v1/modelsroute. OtherwiseX-Mse-Consumercan be forged.docs/deploy.mdgives both ways to set it up and a curl check.Known limits, logged as warnings:
serviceare treated as never matching.Which issue(s) this PR fixes
Refs modelsphere/higress#5. This PR doesn't close it: the helm-charts chart and the kind test below are still to come.
How it was tested
/.allowedit and Ingress add/delete without restart.pluginConfig, local-config size count, duplicate credential,in_query/in_header,defaultConfigDisable, route prefix, class precedence, wildcard, exact+prefix, and the update handler.docker build --build-arg VERSION=0.0.0-localworks, andswitchboard --versionprints0.0.0-local. The local build used a cached Debian runtime base because gcr.io is unreachable from the build host; CI uses distroless.Not yet run: the kind test with a real Higress controller. It covers:
allowchange showing up without restart;Hostreaching switchboard unchanged;Checks
Release note
🤖 Generated with Claude Code