Skip to content

feat(fabric-api): Add a Looking Glass switch, limits and clock check - #1121

Merged
privateip merged 3 commits into
mainfrom
feat/lg-backend-controls
Oct 27, 2026
Merged

privateip merged 3 commits into
mainfrom
feat/lg-backend-controls

Conversation

@privateip

@privateip privateip commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stopping customer Looking Glass diagnostics meant restarting the gateway, which pauses every operator probe in the cell for about two minutes.

A ConfigMap switch now turns customer execution off while the gateway runs, cancelling running requests without touching routing or operator queries, and admission limits become flags that can only lower the contract's defaults.

The leader and nodes refuse probes while the kernel clock is unsynchronised, and after 3 seconds of that the leader cancels all running probe work and serves a fresh two-minute hold. The gateway cannot read the switch until #1123 grants it, and #1122 and #1123 complete this stack.

Test plan

  • Lint, build and unit tests pass with the race detector
  • Switching the service off mid-stream cancels its routers within 2 seconds while an operator probe still runs and the limiter stays ready
  • The gateway refuses to start on a raised limit, a limit without aggregate budgets, or the switch without aggregate budgets
  • A brief bad clock refuses only new work, and one lasting 3 seconds ends the leader's term

Related to #1047

@privateip privateip self-assigned this Oct 26, 2026
@privateip
privateip force-pushed the feat/lg-backend-controls branch 2 times, most recently from f9291e9 to bcb5c24 Compare October 26, 2026 20:49
@privateip privateip changed the title feat(fabric-api): Switch Looking Glass execution off without a restart feat(fabric-api): Add a Looking Glass off switch, lower limits and a clock check Oct 26, 2026
@privateip privateip changed the title feat(fabric-api): Add a Looking Glass off switch, lower limits and a clock check feat(fabric-api): Add a Looking Glass off switch, limits and clock check Oct 26, 2026
@privateip privateip changed the title feat(fabric-api): Add a Looking Glass off switch, limits and clock check feat(fabric-api): Add a Looking Glass switch, limits and clock check Oct 26, 2026
@privateip
privateip marked this pull request as ready for review October 26, 2026 21:06
@privateip
privateip requested a review from a team as a code owner October 26, 2026 21:06
@privateip
privateip enabled stacked auto-merge October 26, 2026 21:06
@privateip

Copy link
Copy Markdown
Contributor Author

Two review passes ran on this PR. The first pass returned merge from the adversarial reviewer, with warnings on the clock epoch-loss wording, the clock prerequisite, the fail-closed switch on a read failure, and RBAC (tracked in #1123), plus a nit on State during grace. The conventions reviewer returned hold, for a five-sentence summary and a single combined commit. The applied fixes were the body rewrite, the split into three commits, and the State fix. Two suggestions were declined: tolerating failed ConfigMap reads (the switch stays fail-closed per the contract) and a clock override flag.

The second pass returned merge from pr-rereviewer, which confirmed all five applied findings fixed and ran go test -race on the State fix and on each of the three commits on its own. pr-conventions-reviewer also returned merge. Its two warnings, a 76-character commit subject and a title that named one of three changes, were fixed afterwards: the clock commit subject is now "feat(fabric-api): Refuse probe work on an unsynchronised clock" and the title is "feat(fabric-api): Add a Looking Glass switch, limits and clock check". The tree is unchanged from the reviewed head.

Author-run evidence on this tree: golangci-lint reports 0 issues repo-wide, and go test -race on internal/fabric/... and cmd/fabric-api passes at each commit.

CI is green on bcb5c24: Build, Lint, Unit Tests, Unit Tests (root), E2E Tests, Service API bundle, the image and bundle publish jobs, and the CLA check all pass.

Auto-merge is enabled with the merge method, the only one the ruleset allows. The ruleset requires one approving review from a code owner, requires approval of the last push, and dismisses stale approvals on push, so the PR waits for a human approval.

PRs #1122 and #1123 stack on this one.

@privateip
privateip disabled stacked auto-merge October 26, 2026 21:10
@privateip
privateip added this pull request to stack #1125 October 26, 2026 21:10

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

The service switch defaults off and is fail-closed, and every limit can only be lowered from the contract ceilings; CI is green at bcb5c24.

  • The switch reads the ConfigMap uncached every second, and only the exact value enabled turns execution on. A missing ConfigMap, empty or other value, or a failed read all turn it off. Turning it off cancels running service requests with Cancelled/ServiceDisabled.
  • --service-config-map and every limit flag are refused without --aggregate-budgets, and Qualified() plus Validate() reject raised or cross-field-invalid limits at startup (cmd/fabric-api/gateway.go).
  • KernelClock fails closed: a gateway on a host with no disciplined kernel clock, or on a seccomp profile that blocks adjtimex, refuses all budgeted work after the 3 s grace. Fine for an opt-in flag, but check it on the staging cells before enabling.

Follow-ups:

  • Qualified() does not check Streams (--service-streams) against a ceiling; it only falls under the MaxStreams hard bound in Validate(). Equal today, but it will drift if the two constants ever diverge.
  • The gateway needs get on the ConfigMap in its namespace; the RBAC and the ConfigMap itself are not part of this PR, so confirm the deploy manifests land before anyone sets --service-config-map.

The cell's aggregate admission rates and caps were fixed at the contract's defaults: only --cell-slots and --cell-queue changed anything, so an operator could not lower a request, packet, slot, queue, stream or queue-wait limit when a cell needed less traffic than the contract allows.

New gateway flags expose each of them: the request and packet rates and bursts for the cell, project or principal, destination host and destination prefix, the per-principal slots and queue, the cell and per-project live streams, and the queue wait. Each defaults to the contract value. Limits.Qualified refuses any value above that 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, naming every offending limit. A smaller --cell-slots, --cell-queue or --service-streams still lowers the per-principal default with it. The Looking Glass router queue wait follows --queue-wait.

Related to #1047
Every deadline, permit and recovery bound in the service contract assumes clocks within 1 s of each other, and the contract asks the backend to fail closed when clock health is unknown. Nothing checked it.

limit.KernelClock reads the clock discipline with adjtimex, which needs no capability and which the default containerd and Docker seccomp profiles allow. The clock is unhealthy while the kernel reports it unsynchronised or its estimated error above 500 ms. The maximum error is not used: it grows 500 µs a second between a time daemon's updates, which chrony spaces up to about 17 minutes apart, so it crosses the bound on a healthy host.

While the leader's clock is unhealthy, its authority refuses admissions and probe permits with LimiterUnavailable and reports itself unavailable. A single bad sample costs nothing more; once the clock has stayed unhealthy for 3 s, the authority ends its epoch like a failed Lease read, cancelling the epoch's operator, FabricQuery and service work and holding admission for a new recovery hold. A node with --probe-permits refuses every permit while its own clock is unhealthy. A host with no time daemon disciplining its kernel clock therefore runs no probe under aggregate budgets.

Related to #1047
Looking Glass execution was a startup setting that no deployment set, so stopping customer diagnostics meant restarting the gateway, and a restart starts the 125 s recovery hold that refuses every operator and FabricQuery probe in the cell.

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 all mean off, the last two with one warning: the switch fails closed, as the contract asks when an API read fails. Turning it off refuses new RunDiagnostic calls with ServiceDisabled and cancels running requests through their context, so their routers report Cancelled and the stream ends with complete reason Cancelled, or ServiceDisabled during discovery. The limiter, its election and operator and FabricQuery work are untouched, so no recovery hold starts. The gateway refuses the flag without --aggregate-budgets, and the gateway's RBAC grants no read of the ConfigMap until the Kustomize Component that ships it.

Related to #1047
@privateip
privateip force-pushed the feat/lg-backend-controls branch from bcb5c24 to eb31cc8 Compare October 27, 2026 02:02
@polylane

polylane Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Polylane could not verify the production impact of this pull request.

This repository deploys to no production resources Polylane knows about and the workspace has no connected cloud accounts or observability integrations, so there is nothing to check this change against.

View in Polylane Pause assessments

Polylane has no cloud accounts connected for this workspace, so it cannot see what this repository deploys to. Connect a cloud and every pull request will be checked against your production resources.

Connect a cloud

Polylane analysed eb31cc8 for production impact. You can ask follow-ups by mentioning @polylane in a comment.

Did this help? React 👍 or 👎 so the next review is sharper.

@privateip
privateip merged commit e803cd6 into main Oct 27, 2026
27 of 28 checks passed
@privateip
privateip deleted the feat/lg-backend-controls branch October 27, 2026 12:12
@privateip privateip mentioned this pull request Oct 29, 2026
7 tasks done
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.

3 participants