LB buckets column + health cascade; VPP dump fix; maglevc strictness

SPA (cmd/frontend/web):
- New "lb buckets" column backed by a 1s-debounced GetVPPLBState
  fetch loop with leading+trailing edge coalesce.
- Per-frontend health icon (/⚠️//‼️/) in the Zippy header,
  gated by a settling flag that suppresses ‼️ until the next lb-state
  reconciliation after a backend transition or weight change.
- In-place leaf merge on lb-state so stable bucket values (e.g. "0")
  don't retrigger the Flash animation on every refresh.
- Zippy cards remember open state in a cookie, default closed on
  fresh load; fixed-width frontend-title-name + reserved icon slot
  so headers line up across all cards.
- Clock-drift watchdog in sse.ts that forces a fresh EventSource on
  laptop-wake so the broker emits a resync instead of hanging on a
  dead half-open socket.

Frontend service (cmd/frontend):
- maglevClient.lbStateLoop, trigger on backend transitions +
  vpp-connect, best-effort fetch on refreshAll.
- Admin handlers explicitly wake the lb-state loop after lifecycle
  ops and set-weight (the latter emits no transition event on the
  maglevd side, so the WatchEvents path wouldn't have caught it).
- /favicon.ico served from embedded web/public IPng logo.

VPP integration:
- internal/vpp/lbstate.go: dumpASesForVIP drops Pfx from the dump
  request (setting it silently wipes IPv4 replies in the LB plugin)
  and filters results by prefix on the response side instead, which
  also demuxes multi-VIP-on-same-port cases correctly.

maglevc:
- Walk now returns the unconsumed token tail; dispatch and the
  question listener reject unknown commands with a targeted error
  instead of dumping the full command tree prefixed with garbage.
- On '?', echo the current line (including the '?') before the help
  list so the output reads like birdc.

Checker / prober:
- internal/checker: ±10% jitter on NextInterval so probes across
  restart don't all fire on the same tick.
- internal/prober: HTTP User-Agent now carries the build version
  and project URL.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 14:23:34 +02:00
parent 35643fd774
commit 1a1c48ef54
28 changed files with 828 additions and 57 deletions

View File

@@ -0,0 +1,55 @@
import { createSignal } from "solid-js";
// Persistence layer for collapsible (Zippy) panels. The cookie is a
// best-effort hint: the page always renders all Zippies closed unless
// their stable id is in the cookie's open-set, but a missing or
// corrupt cookie just falls back to "everything closed", so losing it
// (browser data clear, expiry, private window, write failure) is a
// pure cosmetic regression.
//
// localStorage would arguably be a tidier home for this — it's
// client-only and doesn't ride on every HTTP request — but the
// payload is tiny and the user asked for a cookie, so a cookie it
// is. SameSite=Lax keeps it from leaking to third-party iframes.
const COOKIE_NAME = "maglev_zippy_open";
const COOKIE_MAX_AGE = 60 * 60 * 24 * 365; // 1 year
function readCookie(): Set<string> {
try {
const raw = document.cookie
.split("; ")
.find((c) => c.startsWith(COOKIE_NAME + "="));
if (!raw) return new Set();
const value = decodeURIComponent(raw.slice(COOKIE_NAME.length + 1));
if (!value) return new Set();
return new Set(value.split(","));
} catch {
return new Set();
}
}
function writeCookie(ids: Set<string>) {
try {
const value = encodeURIComponent([...ids].join(","));
document.cookie = `${COOKIE_NAME}=${value}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax`;
} catch {
// best-effort — quota, third-party-cookie blocks, etc. all silently fall back
}
}
const [openSet, setOpenSet] = createSignal<Set<string>>(readCookie());
export function isZippyOpen(id: string): boolean {
return openSet().has(id);
}
export function setZippyOpen(id: string, open: boolean) {
const cur = openSet();
if (open === cur.has(id)) return;
const next = new Set(cur);
if (open) next.add(id);
else next.delete(id);
setOpenSet(next);
writeCookie(next);
}