mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-12-06 11:03:52 +00:00
fix(webui): show provider upstream errors
The dashboard ignored upstreamErrors from the admin overview. A provider with a failing modelBaseUrls upstream looked healthy. The provider panel now lists each upstream error, and the breaker rows mark such a provider as degraded.
This commit is contained in:
@@ -221,6 +221,30 @@ describe('breakerRows', () => {
|
||||
it('returns nothing without an overview', () => {
|
||||
expect(breakerRows(null)).toEqual([])
|
||||
})
|
||||
|
||||
it('breakerRows marks a closed provider with upstreamErrors as degraded', () => {
|
||||
const rows = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: [{ upstream: 'http://x', error: 'boom' }] }] })
|
||||
expect(rows[0]!.degraded).toBe(true)
|
||||
})
|
||||
|
||||
it('breakerRows shows the first upstream error when lastErr is empty', () => {
|
||||
const errs = [
|
||||
{ upstream: 'http://x', error: 'boom' },
|
||||
{ upstream: 'http://y', error: 'bang' },
|
||||
]
|
||||
const [one] = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: errs.slice(0, 1) }] })
|
||||
expect(one!.lastErr).toBe('http://x: boom')
|
||||
const [two] = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: errs }] })
|
||||
expect(two!.lastErr).toBe('http://x: boom (+1 more)')
|
||||
const [own] = breakerRows({ providers: [{ ...p('a', 'closed', { lastErr: 'real' }), upstreamErrors: errs }] })
|
||||
expect(own!.lastErr).toBe('real')
|
||||
})
|
||||
|
||||
it('breakerRows keeps a closed provider with neither healthy', () => {
|
||||
const [row] = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: [] }] })
|
||||
expect(row!.degraded).toBe(false)
|
||||
expect(row!.lastErr).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('ratePercentSeries', () => {
|
||||
|
||||
@@ -180,11 +180,11 @@ export interface BreakerRow {
|
||||
state: ProviderHealthState
|
||||
openUntil: string
|
||||
lastErr: string
|
||||
/** Closed breaker that still reports a last error. */
|
||||
/** Closed breaker that still reports a last error or a failing upstream. */
|
||||
degraded: boolean
|
||||
}
|
||||
|
||||
type BreakerSource = Pick<AdminProviderView, 'name' | 'healthState' | 'openUntil' | 'lastErr'>
|
||||
type BreakerSource = Pick<AdminProviderView, 'name' | 'healthState' | 'openUntil' | 'lastErr' | 'upstreamErrors'>
|
||||
|
||||
const BREAKER_STATE_ORDER: Record<ProviderHealthState, number> = { open: 0, 'half-open': 1, closed: 2 }
|
||||
|
||||
@@ -193,15 +193,27 @@ function breakerTier(r: BreakerRow): number {
|
||||
return r.state === 'closed' && !r.degraded ? 3 : BREAKER_STATE_ORDER[r.state]
|
||||
}
|
||||
|
||||
/** The last error, or the first upstream error (with a count of the rest) when there is none. */
|
||||
function breakerErrText(p: BreakerSource): string {
|
||||
if (p.lastErr) return p.lastErr
|
||||
const ups = p.upstreamErrors ?? []
|
||||
if (ups.length === 0) return ''
|
||||
const first = `${ups[0]!.upstream}: ${ups[0]!.error}`
|
||||
return ups.length > 1 ? `${first} (+${ups.length - 1} more)` : first
|
||||
}
|
||||
|
||||
/** One row per provider, ordered open, half-open, degraded, healthy; ties by name. */
|
||||
export function breakerRows(overview: { providers: ReadonlyArray<BreakerSource> } | null): BreakerRow[] {
|
||||
const rows = (overview?.providers ?? []).map((p) => ({
|
||||
provider: p.name,
|
||||
state: p.healthState,
|
||||
openUntil: p.openUntil,
|
||||
lastErr: p.lastErr ?? '',
|
||||
degraded: p.healthState === 'closed' && !!p.lastErr,
|
||||
}))
|
||||
const rows = (overview?.providers ?? []).map((p) => {
|
||||
const lastErr = breakerErrText(p)
|
||||
return {
|
||||
provider: p.name,
|
||||
state: p.healthState,
|
||||
openUntil: p.openUntil,
|
||||
lastErr,
|
||||
degraded: p.healthState === 'closed' && lastErr !== '',
|
||||
}
|
||||
})
|
||||
return rows.sort((a, b) => breakerTier(a) - breakerTier(b) || a.provider.localeCompare(b.provider))
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,10 @@ function showAll(): void {
|
||||
|
||||
<PanelSection title="Last error">
|
||||
<p v-if="provider.lastErr" class="text-destructive m-0 text-sm break-words whitespace-pre-wrap" data-testid="provider-last-err">{{ provider.lastErr }}</p>
|
||||
<p v-else class="text-muted-foreground m-0 text-sm">No error recorded.</p>
|
||||
<ul v-if="provider.upstreamErrors?.length" class="m-0 flex list-none flex-col gap-1 p-0" :class="{ 'mt-2': provider.lastErr }" aria-label="Upstream errors" data-testid="provider-upstream-errors">
|
||||
<li v-for="(e, i) in provider.upstreamErrors" :key="i" class="text-destructive text-sm break-words whitespace-pre-wrap">{{ e.upstream }}: {{ e.error }}</li>
|
||||
</ul>
|
||||
<p v-if="!provider.lastErr && !provider.upstreamErrors?.length" class="text-muted-foreground m-0 text-sm">No error recorded.</p>
|
||||
</PanelSection>
|
||||
|
||||
<PanelSection title="Latency (time to first byte)">
|
||||
|
||||
@@ -103,6 +103,8 @@ export interface AdminProviderView {
|
||||
baseUrl: string
|
||||
lastRefresh: string
|
||||
lastErr?: string
|
||||
/** modelBaseUrls upstreams whose discovery failed while the provider stayed healthy (admin.go: adminProviderView.UpstreamErrors). */
|
||||
upstreamErrors?: Array<{ upstream: string; error: string }>
|
||||
/** Sorted explicit∪discovered model ids (admin.go: adminProviderView.Models) — always an array, never omitted, even when empty. */
|
||||
models: string[]
|
||||
/** Display labels from the provider's `kinds` config, keyed by model id or endpoint path (admin.go: adminProviderView.Kinds). */
|
||||
|
||||
Reference in New Issue
Block a user