fix(admin): show aliases, guard the provider filter, tolerate failing upstreams (#23)

* fix(admin): attach model aliases to the model their target resolves to

The catalog grouped aliases by the raw target string and looked them up by
canonical provider/model id. A bare target never matched, so no model card
listed its aliases. Each alias now keys on the canonical id that the
registry resolves its target to. The alias view gains an additive
resolvedTarget field.

Model-id cells in the overview, usage and panels now show an alias badge
with the target, using the catalog alias list.

* fix(webui): omit the provider filter select until providers load

* fix(discovery): tolerate failing modelBaseUrls upstreams

A modelBaseUrls upstream that fails /v1/models must not fail the provider.
Discovery now fails only when baseUrl fails. The explicit models of the
failing upstream stay listed, and the other upstreams still merge.

The admin overview reports each failed upstream in the additive
upstreamErrors field. The registry logs it at most once per 10 minutes
per provider. The README states the new semantics.

* chore(webui): regenerate admin assets

Rebuilt with make admin-ui for the alias badge and the provider filter changes.

* style(auth): order authStore fields for fieldalignment

golangci-lint's fieldalignment check reported 240 leading pointer bytes on authStore where 232 is optimal. The bool anonymousAnyKey moves next to the mutexes. No behaviour change.
This commit is contained in:
2026-11-28 02:13:22 +00:00
committed by GitHub
parent 7fade3cdee
commit bfdffc2ab0
19 changed files with 493 additions and 103 deletions
+31 -3
View File
@@ -336,6 +336,26 @@ func replaceURLForm(msg, form string) string {
// base URL names no credential by itself, and any credential-shaped
// userinfo/query an operator mistakenly embedded in it is stripped by
// sanitizeBaseURL before this view is ever built.
// adminUpstreamErrorView is one tolerated modelBaseUrls discovery failure.
type adminUpstreamErrorView struct {
Upstream string `json:"upstream"`
Error string `json:"error"`
}
func adminUpstreamErrors(fails []upstreamFailure, rawBaseURL string) []adminUpstreamErrorView {
if len(fails) == 0 {
return nil
}
out := make([]adminUpstreamErrorView, len(fails))
for i, f := range fails {
out[i] = adminUpstreamErrorView{
Upstream: sanitizeBaseURL(f.Upstream),
Error: sanitizeProviderErr(sanitizeProviderErr(f.Err, f.Upstream), rawBaseURL),
}
}
return out
}
type adminProviderView struct {
LastRefresh time.Time `json:"lastRefresh"`
// OpenUntil is when this provider's breaker will next attempt a
@@ -394,6 +414,8 @@ type adminProviderView struct {
Type string `json:"type"`
BaseURL string `json:"baseUrl"`
LastErr string `json:"lastErr,omitempty"`
// UpstreamErrors lists modelBaseUrls upstreams whose discovery failed while the provider stayed healthy.
UpstreamErrors []adminUpstreamErrorView `json:"upstreamErrors,omitempty"`
// HealthState is this provider's discovery circuit breaker state
// (feat/provider-health): "closed" (normal), "open" (backing off
// after repeated discovery failures — maybeRefresh skips it until
@@ -649,6 +671,9 @@ type adminAliasView struct {
ModelMeta adminModelMetaView `json:"modelMeta"`
Alias string `json:"alias"`
Target string `json:"target"`
// ResolvedTarget is Target's canonical "provider/model" id; omitted
// while Target resolves to no known model.
ResolvedTarget string `json:"resolvedTarget,omitempty"`
}
// adminOverviewResponse is the full body of GET /admin/api/overview (spec
@@ -837,6 +862,7 @@ func (g *Gateway) buildAdminOverview() adminOverviewResponse {
ModelCount: s.modelCount,
LastRefresh: s.lastRefresh,
LastErr: sanitizeProviderErr(s.lastErr, s.baseURL),
UpstreamErrors: adminUpstreamErrors(s.upstreamErrs, s.baseURL),
DiscoveryEnabled: s.discoveryEnabled,
HealthState: s.health.String(),
OpenUntil: s.openUntil,
@@ -908,10 +934,12 @@ func (g *Gateway) buildAdminAliasViews() []adminAliasView {
aliasSnaps := g.registry.aliasSnapshot()
aliases := make([]adminAliasView, len(aliasSnaps))
for i, a := range aliasSnaps {
resolved, _ := g.registry.aliasTargetCanonical(a.Target)
aliases[i] = adminAliasView{
Alias: a.Alias,
Target: a.Target,
ModelMeta: buildAdminModelMetaView(g.registry.resolveMetaForAliasName(a.Alias)),
Alias: a.Alias,
Target: a.Target,
ResolvedTarget: resolved,
ModelMeta: buildAdminModelMetaView(g.registry.resolveMetaForAliasName(a.Alias)),
}
}
return aliases