Repository navigation
feat(fabric-api): Add a Looking Glass switch, limits and clock check - #1121
Conversation
f9291e9 to
bcb5c24
Compare
|
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. |
ecv
left a comment
There was a problem hiding this comment.
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
enabledturns 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-mapand every limit flag are refused without--aggregate-budgets, andQualified()plusValidate()reject raised or cross-field-invalid limits at startup (cmd/fabric-api/gateway.go).KernelClockfails 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 checkStreams(--service-streams) against a ceiling; it only falls under theMaxStreamshard bound inValidate(). Equal today, but it will drift if the two constants ever diverge.- The gateway needs
geton 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
bcb5c24 to
eb31cc8
Compare
|
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. 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. Polylane analysed Did this help? React 👍 or 👎 so the next review is sharper. |
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
Related to #1047