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

@@ -37,6 +37,23 @@ func registerHandlers(mux *http.ServeMux, clients []*maglevClient, broker *Broke
_, _ = w.Write([]byte("ok\n"))
})
// Favicon served from the same embedded dist tree Vite produced.
// Browsers auto-fetch /favicon.ico from the document root regardless
// of where the SPA itself is mounted, so we register a top-level
// handler in addition to whatever /view/favicon.ico picks up via the
// static file server below. Read once at registration so we don't
// touch the embed.FS on every request, and serve with a long
// max-age since the bytes never change for a given binary.
if favicon, ferr := fs.ReadFile(webFS, "web/dist/favicon.ico"); ferr == nil {
mux.HandleFunc("/favicon.ico", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "image/x-icon")
w.Header().Set("Cache-Control", "public, max-age=86400")
_, _ = w.Write(favicon)
})
} else {
slog.Warn("favicon-missing", "err", ferr)
}
mux.HandleFunc("/view/api/version", func(w http.ResponseWriter, _ *http.Request) {
writeJSON(w, VersionInfo{
Version: buildinfo.Version(),
@@ -188,6 +205,13 @@ func handleBackendLifecycle(w http.ResponseWriter, r *http.Request, c *maglevCli
}
slog.Info("admin-backend-action",
"maglevd", c.name, "backend", name, "action", action, "state", snap.State)
// The maglevd→watch path will deliver a transition event that
// also wakes the lb-state loop, but firing here too makes the
// admin path self-contained and shaves the worst-case race
// where the SPA is still waiting on the WatchEvents replay
// when the POST response lands. The debouncer coalesces any
// duplicate wake.
c.triggerLBStateFetch()
writeJSON(w, snap)
}
@@ -219,6 +243,14 @@ func handleBackendWeight(w http.ResponseWriter, r *http.Request, c *maglevClient
slog.Info("admin-set-weight",
"maglevd", c.name, "frontend", frontend, "pool", pool, "backend", backend,
"weight", body.Weight, "flush", body.Flush)
// Weight changes never produce a transition event on the maglevd
// side (the backend's state is unchanged), so the WatchEvents
// stream won't wake the lb-state loop for us — without an explicit
// trigger here the SPA's bucket column would stay stale until the
// next 30s refresh tick. SyncLBStateVIP on the maglevd side has
// already pushed the new weights into VPP synchronously, so the
// fetch we kick off will see fresh post-mutation buckets.
c.triggerLBStateFetch()
writeJSON(w, snap)
}