Skip to content

feat(fabric-api): Add a Looking Glass off switch and tunable limits - #1120

Closed
privateip wants to merge 2 commits into
mainfrom
fix/issue-1047
Closed

privateip wants to merge 2 commits into
mainfrom
fix/issue-1047

Conversation

@privateip

Copy link
Copy Markdown
Contributor

Summary

Operators had no way to stop customer Looking Glass diagnostics without restarting the gateway, which also pauses every operator and FabricQuery probe in the cell for two minutes.

A ConfigMap switch now turns customer execution on or off while the gateway runs, cancelling running requests within 2 seconds and leaving routing, operator and FabricQuery work alone. Admission limits become flags that can only lower the contract's defaults, the leader and nodes refuse work while the kernel clock is unsynchronised, and new metrics, four alerts and opt-in Kustomize Components cover throttling, limiter health and the rollout order.

Everything ships off: a cell runs customer diagnostics only after an operator applies the Components and flips the switch.

Test plan

  • Lint, build and unit tests pass, with the alert rules under promtool and the Components rendered in order and out of order
  • Switching the service off mid-stream cancels its routers within 2 seconds while an operator probe still runs and the limiter stays ready
  • Logs and metric labels from real requests carry no target, result, project or request ID
  • The clock check passes in a container with every capability dropped under the default seccomp profile

Fixes #1047

… backend

Operators had no way to stop customer diagnostics without restarting the gateway, and a restart starts the 125 s recovery hold that refuses every operator and FabricQuery probe in the cell. The admission rates and caps were fixed at the contract's defaults, nothing reported throttling, limiter health or service outcomes, no alert covered them, and the node permit and aggregate budget flags existed only as manual steps in the docs. Nothing checked the clock that every deadline and permit bound depends on.

The gateway's --service-config-map names a ConfigMap whose key "service" turns execution on ("enabled") or off while it runs. Each replica reads it uncached every second; a missing ConfigMap or key, a failed read and any other value mean off. Turning it off refuses new RunDiagnostic calls with ServiceDisabled and cancels running requests through their context within 2 s: their routers report Cancelled and the stream ends with complete reason Cancelled. It leaves the limiter, its election and operator and FabricQuery work untouched, so no recovery hold starts. The gateway refuses the flag without --aggregate-budgets.

New gateway flags expose every admission rate, burst and cap. Limits.Qualified refuses any value above the contract default, which stays the ceiling until a contract revision qualifies more, and the gateway refuses to start on a limit flag without --aggregate-budgets, a raised value or limits that break a cross-field rule.

limit.KernelClock reads the clock discipline with adjtimex. While the kernel reports its clock unsynchronised, or its maximum error above 500 ms, the leader's authority refuses with LimiterUnavailable and cancels the epoch's work like a failed Lease read, starting a new hold once the clock recovers, and a node refuses every probe permit.

The gateway now exports service requests by operation and reason, router outcomes and omissions, request duration, admission refusals by traffic class, limiter scope and reason, charged packets by traffic class, the switch's state, live streams, limiter state and key counts, and clock health; the node exports permit decisions by outcome and its clock health. Labels come from fixed sets: no project, request or service ID, node name or target is a label. The leader logs one line per request it ran with attribution and coverage counts, never targets, results or node error text. A test runs requests and throttling and checks the registry and the logs for each.

The fabric-api rule group gains FabricAPILimiterUnavailable, FabricAPIClockUnsynchronized, FabricAPIServiceThrottled and FabricAPIServiceExecutionFailing, each unit-tested with promtool, including idle and disabled cells that must not fire.

Four opt-in Kustomize Components package the rollout: fabric-api-permits and fabric-api-require-permits for the fabric-router sidecar, aggregate-budgets and service for the gateway. Each fails its build without the Component it needs. The service Component's ConfigMap ships disabled and carries Flux's ssa IfNotPresent annotation, so an operator's kubectl stop survives reconciliation. task test:manifests renders each composition and each invalid one, and a new CI job runs it. configuration.md documents the switch and what happens to active work, the limit flags with tuning guidance and failure bounds, diagnosis from the new metrics, and the upgrade and rollback order.

Fixes #1047
The clock check compared the kernel's maximum error with the 500 ms bound. That figure grows by 500 µs every second between the time daemon's updates, and chrony spaces them up to about 17 minutes apart, so a healthy host crossed the bound before each update and the leader dropped its limiter into a fresh 125 s hold. A host measured at a 1034 s update interval reported 148 ms of maximum error against 2 ms of estimated error. The check now uses the estimated error; an unsynchronised clock still fails, and the kernel marks a clock unsynchronised itself once the maximum error reaches 16 s.

The adjtimex read is allowed by the default containerd and Docker seccomp profiles with every capability dropped, which the doc comment now says.

The service switch no longer warns about an unreadable ConfigMap when the gateway shuts down, the request duration metric's help names its actual start and scope, and the docs say a disable takes effect once a replica reads it, within a second.
@privateip privateip self-assigned this Oct 26, 2026
@privateip privateip changed the title feat(fabric-api): Let operators switch off and tune the Looking Glass backend feat(fabric-api): Add a Looking Glass off switch and tunable limits Oct 26, 2026
@privateip

Copy link
Copy Markdown
Contributor Author

Superseded by the stack #1121, #1122 and #1123, which splits this change and debounces the clock check.

@privateip privateip closed this Oct 26, 2026
@ecv
ecv deleted the fix/issue-1047 branch October 29, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deliver backend configuration, diagnostics, and operational controls

1 participant