From 6c138d6f406e79444852639a1c1c38e8af77b67f Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Mon, 26 Oct 2026 16:48:53 -0400 Subject: [PATCH] feat(fabric-api): Package the Looking Glass rollout as Components Turning on aggregate probe budgets and the Looking Glass service meant hand-editing the fabric-router and gateway manifests in the order the contract requires, and nothing stopped an overlay from enabling the service before every node charged direct operator probes. Four opt-in Components package that rollout. fabric-api-permits adds --probe-permits to the fabric-router sidecar, mounts the ServiceAccount token into it and grants get on the gateway's Lease alone; fabric-api-require-permits adds --require-probe-permits and the gateway Service address. aggregate-budgets adds --aggregate-budgets to the gateway, and service adds --service-config-map, the looking-glass service identity, the fabric-api-service ConfigMap shipped disabled and a Role that can get that ConfigMap alone. Each fails its build without the Component it needs. The ConfigMap carries Flux's ssa IfNotPresent annotation, so an operator's kubectl stop survives reconciliation. task test:manifests renders each valid composition under tests/manifests and checks that each out-of-order one fails, and a new CI job runs it. configuration.md documents the limit flags with tuning guidance and the contract's failure bounds, and the clock check. operations.md documents the Components and the enabling order, the switch and what happens to running work, diagnosis from the new metrics and alerts, and the upgrade and rollback order. The Looking Glass service design, the fabric-api architecture, deployment and security pages and the alert catalog describe the same. Fixes #1047 --- .github/workflows/ci.yaml | 21 ++ Taskfile.yaml | 32 +++ .../aggregate-budgets/deployment-patch.yaml | 3 + .../aggregate-budgets/kustomization.yaml | 24 ++ .../components/service/configmap.yaml | 12 + .../components/service/deployment-patch.yaml | 12 + .../components/service/kustomization.yaml | 38 ++++ .../fabric-api/components/service/rbac.yaml | 26 +++ .../fabric-api-permits/daemonset-patch.yaml | 17 ++ .../fabric-api-permits/kustomization.yaml | 37 +++ .../components/fabric-api-permits/rbac.yaml | 26 +++ .../daemonset-patch.yaml | 15 ++ .../kustomization.yaml | 32 +++ docs/designs/looking-glass-service.md | 25 ++- docs/fabric-api/architecture.md | 26 ++- docs/fabric-api/configuration.md | 189 +++++++++++----- docs/fabric-api/deployment.md | 5 +- docs/fabric-api/operations.md | 210 ++++++++++++++---- docs/fabric-api/security.md | 11 +- docs/observability/alerts.md | 4 + tests/manifests/README.md | 6 + .../gateway-service/kustomization.yaml | 7 + .../node-permits/kustomization.yaml | 7 + .../kustomization.yaml | 4 + .../kustomization.yaml | 5 + .../kustomization.yaml | 4 + 26 files changed, 668 insertions(+), 130 deletions(-) create mode 100644 config/fabric-api/components/aggregate-budgets/deployment-patch.yaml create mode 100644 config/fabric-api/components/aggregate-budgets/kustomization.yaml create mode 100644 config/fabric-api/components/service/configmap.yaml create mode 100644 config/fabric-api/components/service/deployment-patch.yaml create mode 100644 config/fabric-api/components/service/kustomization.yaml create mode 100644 config/fabric-api/components/service/rbac.yaml create mode 100644 config/fabric-router/components/fabric-api-permits/daemonset-patch.yaml create mode 100644 config/fabric-router/components/fabric-api-permits/kustomization.yaml create mode 100644 config/fabric-router/components/fabric-api-permits/rbac.yaml create mode 100644 config/fabric-router/components/fabric-api-require-permits/daemonset-patch.yaml create mode 100644 config/fabric-router/components/fabric-api-require-permits/kustomization.yaml create mode 100644 tests/manifests/README.md create mode 100644 tests/manifests/fabric-api/gateway-service/kustomization.yaml create mode 100644 tests/manifests/fabric-api/node-permits/kustomization.yaml create mode 100644 tests/manifests/invalid/permits-without-sidecar/kustomization.yaml create mode 100644 tests/manifests/invalid/require-without-permits/kustomization.yaml create mode 100644 tests/manifests/invalid/service-without-budgets/kustomization.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 061337012..c0bc96111 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -240,6 +240,27 @@ jobs: hack/service-api-bundle.sh ci dist cd dist && sha256sum -c SHA256SUMS + # The opt-in Kustomize Components that must be listed in order fail their + # build when one is missing; tests/manifests renders each composition. + manifests: + name: Manifests + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-go@v7 + with: + go-version: ${{ env.GO_VERSION }} + + - uses: arduino/setup-task@v3.0.0 + with: + version: ${{ env.TASK_VERSION }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Render the Component fixtures + run: task test:manifests + # Tier 2: Integration tests (every PR, main branch, and releases) test-e2e: name: E2E Tests diff --git a/Taskfile.yaml b/Taskfile.yaml index 7481cc32b..45cde294b 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -8,9 +8,11 @@ vars: [ -n "$gobin" ] && echo "$gobin" || echo "$(go env GOPATH)/bin" GOLANGCI_LINT: '{{.LOCALBIN}}/golangci-lint' YAMLFMT: '{{.LOCALBIN}}/yamlfmt' + KUSTOMIZE: '{{.LOCALBIN}}/kustomize' GO_LICENSES: '{{.LOCALBIN}}/go-licenses' GOLANGCI_LINT_VERSION: v2.12.2 YAMLFMT_VERSION: v0.21.0 + KUSTOMIZE_VERSION: v5.8.1 GO_LICENSES_VERSION: v1.6.0 PROMETHEUS_VERSION: v3.15.0 tasks: @@ -203,6 +205,27 @@ tasks: - mkdir -p {{.GOBGP_BIN}} - CGO_ENABLED=0 GOBIN={{.GOBGP_BIN}} go install github.com/osrg/gobgp/v4/cmd/gobgpd@v4.10.0 github.com/osrg/gobgp/v4/cmd/gobgp@v4.10.0 - go run ./hack/fabric-api-loadtest --mrt {{.MRT}} --gobgp-bin {{.GOBGP_BIN}} {{.CLI_ARGS}} + test:manifests: + desc: Render the opt-in Component fixtures in tests/manifests + # Every fixture under tests/manifests/fabric-api composes Components the + # way a cell overlay does and must build; every fixture under + # tests/manifests/invalid omits a Component another requires and must + # fail to build. + deps: [kustomize] + cmds: + - | + status=0 + for dir in tests/manifests/fabric-api/*/; do + if ! {{.KUSTOMIZE}} build "$dir" > /dev/null; then + echo "FAIL: $dir does not build"; status=1 + fi + done + for dir in tests/manifests/invalid/*/; do + if {{.KUSTOMIZE}} build "$dir" > /dev/null 2>&1; then + echo "FAIL: $dir builds, but omits a required Component"; status=1 + fi + done + exit $status test:alerts: desc: Unit-test the alert rules in config/monitoring/ with promtool # promtool reads plain rule files, so the PrometheusRule's spec is @@ -252,6 +275,15 @@ tasks: TARGET: '{{.GOLANGCI_LINT}}' PACKAGE: github.com/golangci/golangci-lint/v2/cmd/golangci-lint VERSION: '{{.GOLANGCI_LINT_VERSION}}' + kustomize: + desc: Download kustomize if needed + run: once + cmds: + - task: install-tool + vars: + TARGET: '{{.KUSTOMIZE}}' + PACKAGE: sigs.k8s.io/kustomize/kustomize/v5 + VERSION: '{{.KUSTOMIZE_VERSION}}' yamlfmt: desc: Download yamlfmt if needed run: once diff --git a/config/fabric-api/components/aggregate-budgets/deployment-patch.yaml b/config/fabric-api/components/aggregate-budgets/deployment-patch.yaml new file mode 100644 index 000000000..019d25424 --- /dev/null +++ b/config/fabric-api/components/aggregate-budgets/deployment-patch.yaml @@ -0,0 +1,3 @@ +- op: add + path: /spec/template/spec/containers/0/args/- + value: --aggregate-budgets diff --git a/config/fabric-api/components/aggregate-budgets/kustomization.yaml b/config/fabric-api/components/aggregate-budgets/kustomization.yaml new file mode 100644 index 000000000..2676397db --- /dev/null +++ b/config/fabric-api/components/aggregate-budgets/kustomization.yaml @@ -0,0 +1,24 @@ +# Turns on the cell's aggregate admission and probe packet budgets in the +# fabric-api gateway (--aggregate-budgets). Include it from the per-cell +# gateway overlay of config/fabric-api/base: +# +# resources: +# - ../../config/fabric-api/base +# components: +# - ../../config/fabric-api/components/aggregate-budgets +# +# Apply it only once every node's sidecar verifies probe permits +# (config/fabric-router/components/fabric-api-permits): the gateway sends a +# probe to no other node. From then on every probe in the cell, operator, +# FabricQuery and Looking Glass, is charged to the cell's budgets, and each +# gateway start or failover refuses probes for 125 seconds while the leader +# serves its recovery hold. The limits are the contract's defaults; an +# overlay may lower any of them with the gateway's limit flags, never raise +# one. See docs/fabric-api/configuration.md#aggregate-probe-budgets. +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +patches: + - path: deployment-patch.yaml + target: + kind: Deployment + name: fabric-api-gateway diff --git a/config/fabric-api/components/service/configmap.yaml b/config/fabric-api/components/service/configmap.yaml new file mode 100644 index 000000000..8878a1fa1 --- /dev/null +++ b/config/fabric-api/components/service/configmap.yaml @@ -0,0 +1,12 @@ +# The Looking Glass service switch. Only the exact value "enabled" turns +# execution on; "disabled", a missing key or ConfigMap, an unreadable one or +# any other value keeps it off. Each gateway replica reads it every second. +apiVersion: v1 +kind: ConfigMap +metadata: + name: fabric-api-service + namespace: galactic-system + annotations: + kustomize.toolkit.fluxcd.io/ssa: IfNotPresent +data: + service: disabled diff --git a/config/fabric-api/components/service/deployment-patch.yaml b/config/fabric-api/components/service/deployment-patch.yaml new file mode 100644 index 000000000..8c7b19dd7 --- /dev/null +++ b/config/fabric-api/components/service/deployment-patch.yaml @@ -0,0 +1,12 @@ +# Tests that components/aggregate-budgets came first: the service executes +# only under the cell's aggregate budgets, and the gateway refuses +# --service-config-map without them. +- op: test + path: /spec/template/spec/containers/0/args/1 + value: --aggregate-budgets +- op: add + path: /spec/template/spec/containers/0/args/- + value: --service-config-map=fabric-api-service +- op: add + path: /spec/template/spec/containers/0/args/- + value: --service-identities=looking-glass diff --git a/config/fabric-api/components/service/kustomization.yaml b/config/fabric-api/components/service/kustomization.yaml new file mode 100644 index 000000000..bd154e405 --- /dev/null +++ b/config/fabric-api/components/service/kustomization.yaml @@ -0,0 +1,38 @@ +# Wires the Looking Glass service into the fabric-api gateway: the service +# identities it accepts and the fabric-api-service ConfigMap whose key +# "service" turns execution on ("enabled") or off ("disabled") while the +# gateway runs, without a restart. List it after +# components/aggregate-budgets, which it requires; the build fails without +# it: +# +# resources: +# - ../../config/fabric-api/base +# components: +# - ../../config/fabric-api/components/aggregate-budgets +# - ../../config/fabric-api/components/service +# +# The ConfigMap ships with execution off. Flux creates it once and never +# overwrites it (kustomize.toolkit.fluxcd.io/ssa: IfNotPresent), so the +# value in the cluster is the switch an operator turns with kubectl, and a +# reconcile never turns the service back on after an emergency stop. +# Each replica reads it every second. Once the leader reads "disabled", it +# cancels running Looking Glass requests within 2 seconds and refuses new +# ones with ServiceDisabled; operator and FabricQuery work and the +# limiter's state are untouched. See +# docs/fabric-api/configuration.md#operating-the-looking-glass-service. +# +# Prerequisites: every node requires probe permits +# (config/fabric-router/components/fabric-api-require-permits), so direct +# operator probes are charged too, and the cell's fabric-api Issuer issues +# the service certificate. Replace looking-glass in --service-identities +# when the service's certificate names another service. +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +resources: + - configmap.yaml + - rbac.yaml +patches: + - path: deployment-patch.yaml + target: + kind: Deployment + name: fabric-api-gateway diff --git a/config/fabric-api/components/service/rbac.yaml b/config/fabric-api/components/service/rbac.yaml new file mode 100644 index 000000000..437556312 --- /dev/null +++ b/config/fabric-api/components/service/rbac.yaml @@ -0,0 +1,26 @@ +# The gateway reads the service switch, and nothing else among the +# namespace's ConfigMaps. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: fabric-api-gateway-service + namespace: galactic-system +rules: + - apiGroups: [""] + resources: ["configmaps"] + resourceNames: ["fabric-api-service"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: fabric-api-gateway-service + namespace: galactic-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: fabric-api-gateway-service +subjects: + - kind: ServiceAccount + name: fabric-api-gateway + namespace: galactic-system diff --git a/config/fabric-router/components/fabric-api-permits/daemonset-patch.yaml b/config/fabric-router/components/fabric-api-permits/daemonset-patch.yaml new file mode 100644 index 000000000..f49c6e678 --- /dev/null +++ b/config/fabric-router/components/fabric-api-permits/daemonset-patch.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: fabric-router + namespace: galactic-system +spec: + template: + spec: + containers: + - name: fabric-api + args: + - node + - --probe-permits + volumeMounts: + - name: kube-api-access + mountPath: /var/run/secrets/kubernetes.io/serviceaccount + readOnly: true diff --git a/config/fabric-router/components/fabric-api-permits/kustomization.yaml b/config/fabric-router/components/fabric-api-permits/kustomization.yaml new file mode 100644 index 000000000..676000107 --- /dev/null +++ b/config/fabric-router/components/fabric-api-permits/kustomization.yaml @@ -0,0 +1,37 @@ +# Makes each node's fabric-api sidecar verify the cell gateway's probe +# permits (--probe-permits). List it after components/fabric-api, which it +# requires; the build fails without it: +# +# resources: +# - ../../config/fabric-router +# components: +# - ../../config/fabric-router/components/fabric-api +# - ../../config/fabric-router/components/fabric-api-permits +# +# The sidecar then reads the gateway's election Lease (fabric-api-gateway in +# galactic-system) to check each permit's epoch, so it gets the +# fabric-router ServiceAccount's token and a Role allowing get on that one +# Lease. It accepts a permit once, sends nothing past its packets or +# deadline, refuses every permit for 32 seconds after it starts and while +# its host's clock is unsynchronised, and reports probePermits in Info, +# which the gateway requires before it sends a node a probe under +# --aggregate-budgets. A probe without a permit still runs. +# +# Applying it changes the pod template, so every fabric-router pod restarts +# and FRR with it: roll it out as a routing change (one canary node, check +# underlay sessions and convergence, then paced expansion). See +# docs/fabric-api/configuration.md#enabling. +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +resources: + - rbac.yaml +patches: + - path: daemonset-patch.yaml + # Fails the build unless components/fabric-api, which adds this + # DaemonSet, came first; it changes nothing. + - patch: |- + apiVersion: apps/v1 + kind: DaemonSet + metadata: + name: fabric-api-certs + namespace: galactic-system diff --git a/config/fabric-router/components/fabric-api-permits/rbac.yaml b/config/fabric-router/components/fabric-api-permits/rbac.yaml new file mode 100644 index 000000000..50fec4747 --- /dev/null +++ b/config/fabric-router/components/fabric-api-permits/rbac.yaml @@ -0,0 +1,26 @@ +# The sidecar reads the gateway's election Lease, uncached, to check each +# probe permit's epoch, and reads nothing else. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: fabric-api-node-lease + namespace: galactic-system +rules: + - apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + resourceNames: ["fabric-api-gateway"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: fabric-api-node-lease + namespace: galactic-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: fabric-api-node-lease +subjects: + - kind: ServiceAccount + name: fabric-router + namespace: galactic-system diff --git a/config/fabric-router/components/fabric-api-require-permits/daemonset-patch.yaml b/config/fabric-router/components/fabric-api-require-permits/daemonset-patch.yaml new file mode 100644 index 000000000..fae2b45ee --- /dev/null +++ b/config/fabric-router/components/fabric-api-require-permits/daemonset-patch.yaml @@ -0,0 +1,15 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: fabric-router + namespace: galactic-system +spec: + template: + spec: + containers: + - name: fabric-api + args: + - node + - --probe-permits + - --require-probe-permits + - --gateway-address=fabric-api-gateway.galactic-system.svc:9346 diff --git a/config/fabric-router/components/fabric-api-require-permits/kustomization.yaml b/config/fabric-router/components/fabric-api-require-permits/kustomization.yaml new file mode 100644 index 000000000..5a8a7db5d --- /dev/null +++ b/config/fabric-router/components/fabric-api-require-permits/kustomization.yaml @@ -0,0 +1,32 @@ +# Makes each node's fabric-api sidecar refuse a probe without a permit +# (--require-probe-permits). A probe an operator sends a node directly +# first obtains a permit from the cell gateway's Service, charged to that +# operator, so every probe in the cell counts against the aggregate budgets; +# the Looking Glass service must not be enabled before this. List it after +# components/fabric-api-permits, which it requires; the build fails without +# it: +# +# resources: +# - ../../config/fabric-router +# components: +# - ../../config/fabric-router/components/fabric-api +# - ../../config/fabric-router/components/fabric-api-permits +# - ../../config/fabric-router/components/fabric-api-require-permits +# +# Apply it only once the gateway runs with --aggregate-budgets +# (config/fabric-api/components/aggregate-budgets): without a gateway +# issuing permits, every probe on these nodes is refused. Like +# components/fabric-api-permits, applying it restarts FRR on every node: roll +# it out as a routing change. See docs/fabric-api/configuration.md#enabling. +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +patches: + - path: daemonset-patch.yaml + # Fails the build unless components/fabric-api-permits, which adds this + # Role, came first; it changes nothing. + - patch: |- + apiVersion: rbac.authorization.k8s.io/v1 + kind: Role + metadata: + name: fabric-api-node-lease + namespace: galactic-system diff --git a/docs/designs/looking-glass-service.md b/docs/designs/looking-glass-service.md index 053f5cd8b..ed716c3d1 100644 --- a/docs/designs/looking-glass-service.md +++ b/docs/designs/looking-glass-service.md @@ -28,8 +28,8 @@ schemas and result meanings. FabricQuery retains its existing persistence and resume semantics; customer requests have no such persistence or replay. Today, `api/fabric/v1/fabric.proto` exposes only unary methods. The gateway -authenticates service identities and validates their requests (#1043). With -`gateway.Service.Enabled` set, the leader streams a request as specified under +authenticates service identities and validates their requests (#1043). While +its `gateway.Service.Switch` is on, the leader streams a request as specified under "Stream grammar and coverage": `Discoverer.Inventory` takes the unique-router snapshot, `Runner.Stream` hands off each router's outcome as it finishes, and the terminal coverage follows (#1044). With the gateway's `--aggregate-budgets`, @@ -39,16 +39,24 @@ nodes run with `--probe-permits` verify each probe's permit (#1045). Execution requires the gateway's admission, and capabilities advertise `aggregate-probe-budgets` only while execution is enabled with it. Nodes charge direct operator probes only with `--require-probe-permits`, so enabling -execution requires every node to run with it. No deployment sets `Enabled` or -these flags, so a valid `RunDiagnostic` is answered with `ServiceDisabled`. +execution requires every node to run with it. Opt-in Kustomize Components set +these flags, and the gateway's `--service-config-map` names the ConfigMap +whose `service` key switches execution on and off at run time (#1047); it +ships off, so a valid `RunDiagnostic` is answered with `ServiceDisabled` until +an operator switches it on. The delivery and transport bounds under "Cancellation, delivery, and failure assumptions" are enforced (#1046): one writer per stream, the 2 s write and hand-off bound on the leader and on a forwarding follower, the per-outcome and per-stream output caps, the per-replica call and service connection caps, fixed 64 KiB windows and buffers, and keepalive on the gateway listener (`internal/fabric/gateway/stream.go`). A shutdown signal stops the listener at -once. Service disable is a startup setting until #1047 adds its controls, and -the metrics and packaged configuration are #1047's. Operator and FabricQuery +once. Switching the service off cancels its running requests within the 2 s +bound without a restart. The limits are gateway flags that may only lower +the defaults below; the gateway refuses to start on any other value, and +the leader and nodes fail closed while the kernel clock is unsynchronised +within 500 ms. [operations.md](../fabric-api/operations.md#operating-the-looking-glass-service) +documents the switch, the limit flags, the metrics, the alerts and the +upgrade and rollback order. Operator and FabricQuery discovery still return pod candidates, including duplicates. ## Service and identity @@ -651,8 +659,9 @@ an operator explicitly returns to legacy policy. Removing permit enforcement must not leave a service advertising aggregate guarantees. No service endpoint is exposed publicly by this contract. Configure it alongside -the internal gateway listener with distinct method authorization. #1047 defines -validated configuration keys and operational commands from these semantics. +the internal gateway listener with distinct method authorization. Its +validated configuration keys and operational commands are in +[operations.md](../fabric-api/operations.md#operating-the-looking-glass-service). Metrics use bounded labels (operation, reason, traffic class, limiter scope), never project IDs, request IDs, destinations, node UIDs, or result contents. Routine logs may contain sanitized attempt metadata but not diagnostic output, diff --git a/docs/fabric-api/architecture.md b/docs/fabric-api/architecture.md index 167de6bf0..92abada9f 100644 --- a/docs/fabric-api/architecture.md +++ b/docs/fabric-api/architecture.md @@ -72,17 +72,19 @@ The node runs with the socket group and only the raw-socket capability it needs. ## Source and validation map -| Area | Source | Validation | -| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -| Requests, canonicalization, destination policy | `internal/fabric/query` | Unit tests for limits, families and policy | -| FRR protocol and parsing | `internal/fabric/frr` | Captured version-specific fixtures and framing/error tests | -| ICMP execution | `internal/fabric/probe` | Fake sockets; opt-in real raw-socket tests | -| Trust, rotation, certificate copying | `internal/fabric/identity` | mTLS, bad renewal and overlapping CA tests | -| Node budgets and execution | `internal/fabric/node` | RPC, shaping, deadline and duplicate-cache tests | -| Probe permits on the node | `internal/fabric/node` (`permit.go`) | Single-use and refusal tests | -| Discovery, scheduling, status and cleanup | `internal/fabric/gateway` | Reconcile, failover, fairness, bounded-result and service streaming tests | -| Aggregate admission, permits, delivery bounds | `internal/fabric/gateway/limit`, `internal/fabric/gateway` (`admission.go`, `permit.go`, `stream.go`) | Bucket, attempt-key, Lease authority, admission and stream-bound tests | -| BMP station and indexed searches | `internal/fabric/index` | Stream, synchronization and search tests; full-table load harness | -| Schema | `internal/fabric/api/v1alpha1` | Envtest admission tests, requiring KUBEBUILDER_ASSETS | +| Area | Source | Validation | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| Requests, canonicalization, destination policy | `internal/fabric/query` | Unit tests for limits, families and policy | +| FRR protocol and parsing | `internal/fabric/frr` | Captured version-specific fixtures and framing/error tests | +| ICMP execution | `internal/fabric/probe` | Fake sockets; opt-in real raw-socket tests | +| Trust, rotation, certificate copying | `internal/fabric/identity` | mTLS, bad renewal and overlapping CA tests | +| Node budgets and execution | `internal/fabric/node` | RPC, shaping, deadline and duplicate-cache tests | +| Probe permits on the node | `internal/fabric/node` (`permit.go`) | Single-use and refusal tests | +| Discovery, scheduling, status and cleanup | `internal/fabric/gateway` | Reconcile, failover, fairness, bounded-result and service streaming tests | +| Aggregate admission, permits, delivery bounds | `internal/fabric/gateway/limit`, `internal/fabric/gateway` (`admission.go`, `permit.go`, `stream.go`) | Bucket, attempt-key, Lease authority, admission and stream-bound tests | +| Looking Glass switch, limit flags, clock check | `internal/fabric/gateway` (`serviceswitch.go`), `internal/fabric/gateway/limit`, `cmd/fabric-api` (`gatewayLimits`) | Switch, limit-validation and clock tests | +| Opt-in budget, permit and service Components | `config/fabric-api/components/`, `config/fabric-router/components/fabric-api-*permits/` | `task test:manifests` renders `tests/manifests/` | +| BMP station and indexed searches | `internal/fabric/index` | Stream, synchronization and search tests; full-table load harness | +| Schema | `internal/fabric/api/v1alpha1` | Envtest admission tests, requiring KUBEBUILDER_ASSETS | The lab's `verify:fabric-api` task exercises node and gateway queries and FabricQuery completion. `verify:fabric-api-bootstrap` deliberately breaks certificate issuance to test the routing-isolation boundary. These require the lab; a unit-test run alone does not establish those outcomes. [Operational verification](operations.md#verifying) lists the commands and expected observations. diff --git a/docs/fabric-api/configuration.md b/docs/fabric-api/configuration.md index 09aa3d1d3..4b4eb499d 100644 --- a/docs/fabric-api/configuration.md +++ b/docs/fabric-api/configuration.md @@ -45,38 +45,38 @@ variables then apply. Trace-context propagation is always on. ### `fabric-api node` -| Flag | Env | Default | Meaning | -| ------------------------------ | ------------------------ | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `--node-name` | `NODE_NAME` | | This node's name. Required; requests naming another node are refused (`WrongNode`) | -| `--site` | `SITE` | | Site this node serves; reported by `Info` | -| `--cell` | `CELL` | | Cell name in the mTLS identities. If empty the process idles and serves only metrics | -| `--namespace` | `POD_NAMESPACE` | | This pod's namespace. Required | -| `--pod-name` | `POD_NAME` | | This pod's name. Required | -| `--host-ip` | `HOST_IP` | | Address the gRPC service binds to: the pod's `hostIP`. Required | -| `--port` | | `9344` | gRPC port | -| `--metrics-bind-address` | `METRICS_BIND_ADDRESS` | `:9345` | Address serving `/metrics` | -| `--frr-socket-dir` | | `/run/frr` | Directory holding `bgpd.vty` and `zebra.vty` | -| `--tls-cert` | `FABRIC_API_TLS_CERT` | `/var/run/fabric-api/tls/tls.crt` | Certificate file | -| `--tls-key` | `FABRIC_API_TLS_KEY` | `/var/run/fabric-api/tls/tls.key` | Private key file | -| `--tls-ca` | `FABRIC_API_TLS_CA` | `/var/run/fabric-api/tls/ca.crt` | Trust bundle file | -| `--probe-source-ipv4` | `PROBE_SOURCE_IPV4` | | Explicit IPv4 probe source | -| `--probe-source-ipv6` | `PROBE_SOURCE_IPV6` | | Explicit IPv6 probe source | -| `--probe-source-interface` | `PROBE_SOURCE_INTERFACE` | `lo` | Interface whose single global address per family is the source for a family with no explicit one; empty disables | -| `--deny-prefixes` | | | Comma-separated platform or management CIDRs no probe may target | -| `--operator-allow-prefixes` | | | Comma-separated CIDRs only operator identities may probe. Lab only; never set in production | -| `--enable-expensive-queries` | | `false` | Enable `ASPath`, `Community` and `LargeCommunity` searches. See [Query types](#query-types) | -| `--max-concurrent` | | `4` | `Execute` calls running at once; further calls wait within their deadline | -| `--max-expensive` | | `1` | Expensive searches running at once; no queue (`NodeBusy`) | -| `--max-probes` | | `2` | Probes running at once; no queue (`NodeBusy`) | -| `--probe-packet-rate` | | `20` | Probe packets per second across all probes on the node (burst 5, not configurable) | -| `--expensive-breaker-cooldown` | | `10m` | How long expensive searches stay suspended after one times out (`--search-source=frr` only) | -| `--search-source` | | `index` | What answers AS-path and community searches: `index` (a local copy of bgpd's Loc-RIB fed over BMP) or `frr` (FRR's own scans, which starve bgpd on full tables) | -| `--bmp-station-address` | | `127.0.0.1:9348` | Loopback address the BMP station listens on, with `--search-source=index` | -| `--search-index-max-routes` | | `4000000` | Prefixes the index holds at most; announcements for new prefixes beyond it are dropped and counted | -| `--probe-permits` | | `false` | Verify and enforce the gateway's probe permits, and report `probePermits` in `Info`. Needs API access; see [Aggregate probe budgets](#aggregate-probe-budgets) | -| `--require-probe-permits` | | `false` | With `--probe-permits`, refuse any probe without a permit; a direct operator's probe first obtains one from `--gateway-address` | -| `--gateway-address` | | | `host:port` of the cell gateway's gRPC service, from which direct operator probes obtain permits. Required by `--require-probe-permits` | -| `--gateway-lease-name` | | `fabric-api-gateway` | The gateway's election lease, read uncached in `--namespace` to verify each permit's epoch | +| Flag | Env | Default | Meaning | +| ------------------------------ | ------------------------ | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `--node-name` | `NODE_NAME` | | This node's name. Required; requests naming another node are refused (`WrongNode`) | +| `--site` | `SITE` | | Site this node serves; reported by `Info` | +| `--cell` | `CELL` | | Cell name in the mTLS identities. If empty the process idles and serves only metrics | +| `--namespace` | `POD_NAMESPACE` | | This pod's namespace. Required | +| `--pod-name` | `POD_NAME` | | This pod's name. Required | +| `--host-ip` | `HOST_IP` | | Address the gRPC service binds to: the pod's `hostIP`. Required | +| `--port` | | `9344` | gRPC port | +| `--metrics-bind-address` | `METRICS_BIND_ADDRESS` | `:9345` | Address serving `/metrics` | +| `--frr-socket-dir` | | `/run/frr` | Directory holding `bgpd.vty` and `zebra.vty` | +| `--tls-cert` | `FABRIC_API_TLS_CERT` | `/var/run/fabric-api/tls/tls.crt` | Certificate file | +| `--tls-key` | `FABRIC_API_TLS_KEY` | `/var/run/fabric-api/tls/tls.key` | Private key file | +| `--tls-ca` | `FABRIC_API_TLS_CA` | `/var/run/fabric-api/tls/ca.crt` | Trust bundle file | +| `--probe-source-ipv4` | `PROBE_SOURCE_IPV4` | | Explicit IPv4 probe source | +| `--probe-source-ipv6` | `PROBE_SOURCE_IPV6` | | Explicit IPv6 probe source | +| `--probe-source-interface` | `PROBE_SOURCE_INTERFACE` | `lo` | Interface whose single global address per family is the source for a family with no explicit one; empty disables | +| `--deny-prefixes` | | | Comma-separated platform or management CIDRs no probe may target | +| `--operator-allow-prefixes` | | | Comma-separated CIDRs only operator identities may probe. Lab only; never set in production | +| `--enable-expensive-queries` | | `false` | Enable `ASPath`, `Community` and `LargeCommunity` searches. See [Query types](#query-types) | +| `--max-concurrent` | | `4` | `Execute` calls running at once; further calls wait within their deadline | +| `--max-expensive` | | `1` | Expensive searches running at once; no queue (`NodeBusy`) | +| `--max-probes` | | `2` | Probes running at once; no queue (`NodeBusy`) | +| `--probe-packet-rate` | | `20` | Probe packets per second across all probes on the node (burst 5, not configurable) | +| `--expensive-breaker-cooldown` | | `10m` | How long expensive searches stay suspended after one times out (`--search-source=frr` only) | +| `--search-source` | | `index` | What answers AS-path and community searches: `index` (a local copy of bgpd's Loc-RIB fed over BMP) or `frr` (FRR's own scans, which starve bgpd on full tables) | +| `--bmp-station-address` | | `127.0.0.1:9348` | Loopback address the BMP station listens on, with `--search-source=index` | +| `--search-index-max-routes` | | `4000000` | Prefixes the index holds at most; announcements for new prefixes beyond it are dropped and counted | +| `--probe-permits` | | `false` | Verify and enforce the gateway's probe permits, and report `probePermits` in `Info`. Permits are refused while the kernel clock is unsynchronised. Needs API access; see [Aggregate probe budgets](#aggregate-probe-budgets) | +| `--require-probe-permits` | | `false` | With `--probe-permits`, refuse any probe without a permit; a direct operator's probe first obtains one from `--gateway-address` | +| `--gateway-address` | | | `host:port` of the cell gateway's gRPC service, from which direct operator probes obtain permits. Required by `--require-probe-permits` | +| `--gateway-lease-name` | | `fabric-api-gateway` | The gateway's election lease, read uncached in `--namespace` to verify each permit's epoch | Not configurable by flag: the 4 MiB FRR read cap, the 2 second socket dial timeout, the duplicate-suppression cache (1024 entries or 32 MiB), the 60 second @@ -93,32 +93,34 @@ FRR, so it follows [Rollout](operations.md#rollout). ### `fabric-api gateway` -| Flag | Env | Default | Meaning | -| ------------------------------------- | ------------------------------------ | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `--site` | `SITE` | | Site this cell serves. Required | -| `--cluster-name` | `CLUSTER_NAME` | | This cell's Karmada member cluster name. Required | -| `--cell` | `CELL` | | Cell name in the mTLS identities. Required | -| `--namespace` | `POD_NAMESPACE` | `galactic-system` | Namespace of the `fabric-router` pods, the election lease and this pod | -| `--pod-name` | `POD_NAME` | | This pod's name. Required | -| `--debug-bind-address` | | | Address the debug service binds to. Empty binds every address in the pod's network namespace, which a port-forward (through the pod's loopback) and the Service both need | -| `--pod-selector` | | `app.kubernetes.io/name=fabric-router` | Label selector of `fabric-router` pods | -| `--certs-selector` | | `app.kubernetes.io/name=fabric-api-certs` | Label selector of the per-node `fabric-api-certs` pods whose identity each sidecar presents | -| `--lease-name` | | `fabric-api-gateway` | Leader election lease name | -| `--debug-port` | | `9346` | Operator debug gRPC port | -| `--metrics-bind-address` | | `:9347` | Address serving `/metrics` | -| `--health-probe-bind-address` | | `:8081` | Address serving `/healthz` and `/readyz` | -| `--tls-cert`, `--tls-key`, `--tls-ca` | `FABRIC_API_TLS_CERT`, `_KEY`, `_CA` | `/var/run/fabric-api/tls/tls.crt`, `tls.key`, `ca.crt` | As for the node | -| `--cell-slots` | | `8` | Node RPCs running at once across all queries | -| `--cell-expensive-slots` | | `2` | Of those, expensive searches | -| `--cell-queue` | | `256` | Node RPCs that may wait for a slot | -| `--max-nodes` | | `32` | Nodes one query executes on in this cell (ceiling 32) | -| `--max-object-bytes` | | `393216` (384 KiB) | Serialized `FabricQuery` size ceiling (ceiling 384 KiB) | -| `--max-node-response-bytes` | | `131072` (128 KiB) | Node response ceiling (ceiling 128 KiB) | -| `--max-in-flight` | | `256` | Queries executing at once; more wait for a requeue | -| `--retention` | | `1h` | Retention the stale-object count assumes; keep equal to the janitor's `--retention` | -| `--cleanup-grace` | | `15m` | Cleanup grace the stale-object count assumes; keep equal to the janitor's `--grace` | -| `--service-identities` | | | Comma-separated names of the Looking Glass service identities allowed to call this gateway. Empty allows none | -| `--aggregate-budgets` | | `false` | Enforce the cell's aggregate admission and probe packet budgets on every caller and issue probe permits. Requires `--cell-slots` at most 8; a principal's share is 2 slots and 32 queued jobs, lowered to `--cell-slots` and `--cell-queue` when those are smaller. See [Aggregate probe budgets](#aggregate-probe-budgets) | +| Flag | Env | Default | Meaning | +| ------------------------------------- | ------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `--site` | `SITE` | | Site this cell serves. Required | +| `--cluster-name` | `CLUSTER_NAME` | | This cell's Karmada member cluster name. Required | +| `--cell` | `CELL` | | Cell name in the mTLS identities. Required | +| `--namespace` | `POD_NAMESPACE` | `galactic-system` | Namespace of the `fabric-router` pods, the election lease and this pod | +| `--pod-name` | `POD_NAME` | | This pod's name. Required | +| `--debug-bind-address` | | | Address the debug service binds to. Empty binds every address in the pod's network namespace, which a port-forward (through the pod's loopback) and the Service both need | +| `--pod-selector` | | `app.kubernetes.io/name=fabric-router` | Label selector of `fabric-router` pods | +| `--certs-selector` | | `app.kubernetes.io/name=fabric-api-certs` | Label selector of the per-node `fabric-api-certs` pods whose identity each sidecar presents | +| `--lease-name` | | `fabric-api-gateway` | Leader election lease name | +| `--debug-port` | | `9346` | Operator debug gRPC port | +| `--metrics-bind-address` | | `:9347` | Address serving `/metrics` | +| `--health-probe-bind-address` | | `:8081` | Address serving `/healthz` and `/readyz` | +| `--tls-cert`, `--tls-key`, `--tls-ca` | `FABRIC_API_TLS_CERT`, `_KEY`, `_CA` | `/var/run/fabric-api/tls/tls.crt`, `tls.key`, `ca.crt` | As for the node | +| `--cell-slots` | | `8` | Node RPCs running at once across all queries | +| `--cell-expensive-slots` | | `2` | Of those, expensive searches | +| `--cell-queue` | | `256` | Node RPCs that may wait for a slot | +| `--max-nodes` | | `32` | Nodes one query executes on in this cell (ceiling 32) | +| `--max-object-bytes` | | `393216` (384 KiB) | Serialized `FabricQuery` size ceiling (ceiling 384 KiB) | +| `--max-node-response-bytes` | | `131072` (128 KiB) | Node response ceiling (ceiling 128 KiB) | +| `--max-in-flight` | | `256` | Queries executing at once; more wait for a requeue | +| `--retention` | | `1h` | Retention the stale-object count assumes; keep equal to the janitor's `--retention` | +| `--cleanup-grace` | | `15m` | Cleanup grace the stale-object count assumes; keep equal to the janitor's `--grace` | +| `--service-identities` | | | Comma-separated names of the Looking Glass service identities allowed to call this gateway. Empty allows none | +| `--service-config-map` | | | ConfigMap in `--namespace` whose key `service` turns Looking Glass execution on (`enabled`) or off while the gateway runs, read every second. Empty keeps it off. Needs `--aggregate-budgets`. See [Operating the Looking Glass service](operations.md#operating-the-looking-glass-service) | +| `--aggregate-budgets` | | `false` | Enforce the cell's aggregate admission and probe packet budgets on every caller and issue probe permits. Requires `--cell-slots` at most 8. See [Aggregate probe budgets](#aggregate-probe-budgets) | +| Limit flags | | The contract's | `--request-*`, `--packet-*`, `--principal-slots`, `--principal-queue`, `--service-streams`, `--project-streams` and `--queue-wait`: the aggregate limits, each only lowerable; need `--aggregate-budgets`. See [Limits and capacity](#limits-and-capacity) | `--max-nodes`, `--max-object-bytes` and `--max-node-response-bytes` can only lower their ceilings: zero or a value above the ceiling selects the ceiling. The @@ -369,8 +371,75 @@ one from the gateway's `RequestPermit`, charged to that operator. When a probe's node call ends without the node's answer, its slot stays held until the job's deadline plus 2 seconds, since the node may still be sending -it. The rates and caps are the contract's defaults; only `--cell-slots` and -`--cell-queue` change them. +it. The rates and caps are the contract's defaults, which are also their +ceilings: [Limits and capacity](#limits-and-capacity) lists the flags that +lower them. + +The leader trusts its clock only while the kernel reports it synchronised, +with an estimated error of at most 500 ms (`adjtimex`, read without +privileges and allowed by the default seccomp profiles). Otherwise its +limiter is unavailable: it admits no probe and no Looking Glass request +(`LimiterUnavailable`), whoever asks. A shorter run than 3 seconds refuses +only new work; once the clock has been unhealthy for 3 seconds, the leader +cancels the epoch's work like a failed Lease read and serves a new +125-second hold once the clock recovers. A node with `--probe-permits` refuses every permit while its +own clock is unsynchronised. A host whose time daemon (chrony, ntpd, +systemd-timesyncd, Talos timed) disciplines the kernel clock passes; a host +with none does not. + +### Limits and capacity + +Every limit defaults to the [service contract](../designs/looking-glass-service.md#initial-defaults-and-hard-bounds)'s +qualified value, which is also its ceiling: a cell may lower one, never raise +it, until a contract revision qualifies a higher value. A limit flag without +`--aggregate-budgets`, a value above its ceiling, and a combination that +breaks a cross-field rule (a non-positive rate, a burst over 120 seconds of +its rate, a packet burst that cannot fund one 20-packet traceroute, a +per-project or per-principal limit above its cell's) all stop the gateway +from starting, naming every offending limit in its log. A rolling update to +such a configuration leaves the previous replicas serving. + +| Flag | Default and ceiling | Bounds | +| ----------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------ | +| `--request-cell-rate`, `--request-cell-burst` | 2/s, 8 | Looking Glass requests admitted in the cell | +| `--request-project-rate`, `--request-project-burst` | 0.2/s, 2 | Looking Glass requests admitted per project | +| `--packet-cell-rate`, `--packet-cell-burst` | 100/s, 640 | Worst-case probe packets charged in the cell, every caller included | +| `--packet-principal-rate`, `--packet-principal-burst` | 20/s, 640 | Worst-case probe packets per project, `FabricQuery` source or operator | +| `--packet-host-rate`, `--packet-host-burst` | 20/s, 640 | Worst-case probe packets per destination address | +| `--packet-prefix-rate`, `--packet-prefix-burst` | 40/s, 640 | Worst-case probe packets per destination IPv4 /24 or IPv6 /64 | +| `--cell-slots`, `--principal-slots` | 8, 2 | Node jobs running at once in the cell, and per principal | +| `--cell-queue`, `--principal-queue` | 256, 32 | Node jobs queued in the cell, and per principal | +| `--service-streams`, `--project-streams` | 16, 2 | Live Looking Glass streams in the cell, and per project, queued and draining ones included | +| `--queue-wait` | 10s | A Looking Glass router job's, or a direct operator permit's, wait for a slot | + +A smaller `--cell-slots`, `--cell-queue` or `--service-streams` lowers the +per-principal default with it. Changing any limit restarts the gateway, so +like any gateway restart it cancels running Looking Glass requests and +refuses every probe in the cell for the 125-second recovery hold; make limit +changes when that pause is acceptable. + +Lower a limit when its traffic is a problem, not because it refuses work. +`fabric_api_gateway_admission_refusals_total` shows which scope refuses: + +- `scope="project"`: one project, `FabricQuery` source or operator at its + own budget. Fairness working; lower the project limits only to protect the + routers or destinations further. +- `scope="cell"`: the cell's budget is exhausted across callers. Raising it + needs a contract revision; lower `--request-project-*` to share it more + evenly. +- `scope="destination"`: probes concentrated on one address or prefix, + whatever their callers. These budgets protect the destination. +- `scope="queue"`: slots, queue or streams are full. A request selecting + fewer routers needs fewer slots. + +The bounds these limits give, from the contract: a cancelled, disabled or +stalled request releases its slots and stops its reachable routers within 2 +seconds; a queued router job dispatches or fails `QueueTimeout` within +`--queue-wait`; a node sends no probe packet later than its permit's deadline +plus 2 seconds, at most 32 seconds after dispatch; a new leader admits +nothing for 125 seconds. In any interval of length T, the packets a bucket of +rate r and burst B allows the cell to send are at most B + r(T + 32): with the +destination host defaults, at most 1300 packets in any one second. ### Stream delivery and transport bounds diff --git a/docs/fabric-api/deployment.md b/docs/fabric-api/deployment.md index b885e571f..e62cbae07 100644 --- a/docs/fabric-api/deployment.md +++ b/docs/fabric-api/deployment.md @@ -202,8 +202,9 @@ What the Component changes in the pod: `0770 frr:frrvty` sockets through group 102. - Sets `automountServiceAccountToken: false` on the pod and adds a projected token volume mounted only into `frr-init` and `config-agent`, the containers - that call the Kubernetes API. The sidecar has no API access unless it runs - with `--probe-permits`, which no manifest sets yet (see + that call the Kubernetes API. The sidecar has no API access unless the + opt-in `components/fabric-api-permits` Component adds `--probe-permits` and + mounts the token into it (see [Enabling aggregate probe budgets](operations.md#enabling-aggregate-probe-budgets)). The `fabric-api-certs` DaemonSet runs the same image with `args: [certsync, ...]`, diff --git a/docs/fabric-api/operations.md b/docs/fabric-api/operations.md index 3084292af..38295983a 100644 --- a/docs/fabric-api/operations.md +++ b/docs/fabric-api/operations.md @@ -15,17 +15,21 @@ Scrape config and alert rules are in `config/monitoring/` (not part of - The `fabric-api` group in `prometheusrule.yaml`, unit-tested by `task test:alerts`. None fires merely because nobody ran a query. -| Alert | Fires when | For | -| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | --- | -| `FabricAPIExecutionStalled` | A gateway has executions in flight and finished none in 10 minutes | 10m | -| `FabricAPINodeDiagnosticsUnavailable` | `fabric_api_node_diagnostics_available` is 0 | 15m | -| `FabricAPINodeUnreachable` | More than half of at least 5 node calls in 30 minutes were `NodeUnreachable` or `Timeout` | 15m | -| `FabricAPIResultsOversized` | 10 or more `ResponseTooLarge` outcomes on a node in an hour | 15m | -| `FabricAPICleanupBacklog` | More than 50 stale `FabricQuery` objects | 1h | -| `FabricAPICertificateRenewalFailing` | A loaded certificate has less than 4 hours left | 15m | -| `FabricAPICredentialsMissing` | `fabric_api_credentials_loaded` is 0 | 15m | -| `FabricAPISearchIndexUnsynced` | `fabric_api_node_search_index_synced` is 0 on a node whose index has held routes (a node with no `bmp targets fabric-api` block never fires) | 15m | -| `FabricAPIMetricsDown` | A fabric-api target cannot be scraped | 10m | +| Alert | Fires when | For | +| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | --- | +| `FabricAPIExecutionStalled` | A gateway has executions in flight and finished none in 10 minutes | 10m | +| `FabricAPINodeDiagnosticsUnavailable` | `fabric_api_node_diagnostics_available` is 0 | 15m | +| `FabricAPINodeUnreachable` | More than half of at least 5 node calls in 30 minutes were `NodeUnreachable` or `Timeout` | 15m | +| `FabricAPIResultsOversized` | 10 or more `ResponseTooLarge` outcomes on a node in an hour | 15m | +| `FabricAPICleanupBacklog` | More than 50 stale `FabricQuery` objects | 1h | +| `FabricAPICertificateRenewalFailing` | A loaded certificate has less than 4 hours left | 15m | +| `FabricAPICredentialsMissing` | `fabric_api_credentials_loaded` is 0 | 15m | +| `FabricAPISearchIndexUnsynced` | `fabric_api_node_search_index_synced` is 0 on a node whose index has held routes (a node with no `bmp targets fabric-api` block never fires) | 15m | +| `FabricAPILimiterUnavailable` | No gateway replica in a cell has had a ready aggregate limiter (`fabric_api_gateway_limiter_state{state="ready"}`), so every probe is refused | 10m | +| `FabricAPIClockUnsynchronized` | A gateway with `--aggregate-budgets` or a node with `--probe-permits` runs on a kernel clock not synchronised within 500 ms | 10m | +| `FabricAPIServiceThrottled` | More than half of at least 20 Looking Glass requests in 30 minutes were refused `Throttled`, `QueueFull` or `LimiterUnavailable` | 15m | +| `FabricAPIServiceExecutionFailing` | More than half of at least 10 executed Looking Glass requests in 30 minutes ended `ExecutionFailed`, `NoNodesAvailable`, `OwnershipLost` or `Internal` | 15m | +| `FabricAPIMetricsDown` | A fabric-api target cannot be scraped | 10m | All are `severity: warning`, `service: galactic`, `team: connect`. A deployment that evaluates its own copy of the rules changes them here first, with their tests, then @@ -44,8 +48,12 @@ Node metrics (port 9345, a private registry with Go and process collectors): `fabric_api_node_expensive_breaker_open`, `fabric_api_node_probe_packets_total`, `fabric_api_node_identity_refreshes_total{outcome}`, +`fabric_api_node_permits_total{outcome}` (`accepted`, or why a permit was +refused: `invalid`, `malformed`, `mismatch`, `expired`, `starting`, `clock`, `lease`, +`epoch`, `replayed`, `full`), `fabric_api_certificate_expiry_timestamp_seconds` and -`fabric_api_credentials_loaded`. +`fabric_api_credentials_loaded`. With `--probe-permits` the node also exports +`fabric_api_node_clock_synchronized`. Gateway metrics (port 9347, on controller-runtime's registry, so its own metrics appear too): `fabric_api_gateway_queries_total{type,reason}`, @@ -57,7 +65,17 @@ appear too): `fabric_api_gateway_queries_total{type,reason}`, `completion`), `fabric_api_gateway_executions_in_flight`, `fabric_api_gateway_queue_wait_seconds` (time a node RPC waited for a cell slot), `fabric_api_gateway_stale_objects`, `fabric_api_certificate_expiry_timestamp_seconds` -and `fabric_api_credentials_loaded`. Request IDs and targets are never labels. +and `fabric_api_credentials_loaded`. For the Looking Glass service: +`fabric_api_gateway_service_enabled`, +`fabric_api_gateway_service_requests_total{operation,reason}`, +`fabric_api_gateway_service_router_outcomes_total{operation,outcome}` and +`fabric_api_gateway_service_request_duration_seconds{operation}`. With +`--aggregate-budgets`: `fabric_api_gateway_admission_refusals_total{class,scope,reason}`, +`fabric_api_gateway_probe_packets_charged_total{class}`, +`fabric_api_gateway_limiter_state{state}`, `fabric_api_gateway_limiter_keys{kind}`, +`fabric_api_gateway_service_streams` and `fabric_api_gateway_clock_synchronized`. +Request, project and service IDs, node names and targets are never labels; +[Telemetry and diagnosis](#telemetry-and-diagnosis) walks them. ## Rollout @@ -101,41 +119,145 @@ unavailable, FRR and the underlay are unaffected; read `unavailableReason`. ### Enabling aggregate probe budgets -The deployment manifests do not set the [aggregate probe budget](configuration.md#aggregate-probe-budgets) flags yet. Turn them on in this -order, each step cell by cell: - -1. **Nodes verify permits.** Give the `fabric-router` ServiceAccount `get` on - the gateway's Lease and mount its token into the `fabric-api` container (the - Component mounts it only into `frr-init` and `config-agent`): - - ```yaml - apiVersion: rbac.authorization.k8s.io/v1 - kind: Role - metadata: - name: fabric-api-node-lease - namespace: galactic-system - rules: - - apiGroups: ["coordination.k8s.io"] - resources: ["leases"] - resourceNames: ["fabric-api-gateway"] - verbs: ["get"] - ``` - - Bind it to the `fabric-router` ServiceAccount and add `--probe-permits` to - the sidecar's args. This changes the pod template, so it is a routing - rollout: follow [Rollout](#rollout). -2. **The gateway enforces budgets.** Add `--aggregate-budgets` to the gateway. - Expect operator and `FabricQuery` probes to be refused for 125 seconds after - each gateway restart. +Opt-in Kustomize Components set the +[aggregate probe budget](configuration.md#aggregate-probe-budgets) flags. Turn them on in this order, +each step cell by cell: + +1. **Nodes verify permits.** Add + `config/fabric-router/components/fabric-api-permits` after + `components/fabric-api` in the cell's `fabric-router` overlay. It adds + `--probe-permits` to the sidecar, mounts the `fabric-router` + ServiceAccount's token into it and grants `get` on the gateway's Lease + alone (Role `fabric-api-node-lease`). This changes the pod template, so it + is a routing rollout: follow [Rollout](#rollout). +2. **The gateway enforces budgets.** Add + `config/fabric-api/components/aggregate-budgets` to the cell's gateway + overlay. Expect operator and `FabricQuery` probes to be refused for 125 + seconds after each gateway restart. 3. **Nodes require permits.** Until this step, probes operators send nodes directly are not charged, and the Looking Glass service must not be - enabled. Add `--require-probe-permits` and - `--gateway-address=fabric-api-gateway.galactic-system.svc:9346` (the gateway - Service) to the sidecar, so direct operator probes are charged too. Another + enabled. Add `config/fabric-router/components/fabric-api-require-permits` + after `components/fabric-api-permits`. It adds `--require-probe-permits` + and `--gateway-address=fabric-api-gateway.galactic-system.svc:9346` (the + gateway Service), so direct operator probes are charged too. Another routing rollout. +4. **The gateway serves the Looking Glass service, switched off.** Add + `config/fabric-api/components/service` after + `components/aggregate-budgets`. See + [Operating the Looking Glass service](#operating-the-looking-glass-service) + for turning it on. + +Each Component that needs an earlier one fails the build without it, so an +overlay cannot list them out of order. Roll back in the reverse order. +Removing `--aggregate-budgets` while nodes still require permits refuses +every gateway probe (`LimiterUnavailable`). + +## Operating the Looking Glass service + +### Turning execution on and off + +A gateway executes a Looking Glass request only when all of these hold: + +- it runs with `--aggregate-budgets`; +- `--service-config-map` names a ConfigMap in its namespace whose key + `service` is exactly `enabled`; +- the caller's service identity is in `--service-identities`. + +`config/fabric-api/components/service` sets `--service-config-map` to +`fabric-api-service`, `--service-identities` to `looking-glass`, and creates +that ConfigMap with `service: disabled` and a Role that lets the gateway +`get` it and no other ConfigMap. Each replica reads it, uncached, every +second. A missing ConfigMap or key, `disabled`, a failed read and any other +value all mean off; the last two log a warning once. The gateway refuses to +start with `--service-config-map` but without `--aggregate-budgets`. + +The ConfigMap carries `kustomize.toolkit.fluxcd.io/ssa: IfNotPresent`, so Flux +creates it once and never overwrites it: the value in the cluster is the +switch, and a reconcile never turns the service back on after an operator +stopped it. To manage it from Git instead, drop the annotation in the +overlay. + +To stop new customer execution: + +```sh +kubectl -n galactic-system patch configmap fabric-api-service --type merge \ + -p '{"data":{"service":"disabled"}}' +``` + +Each replica reads the change within a second, and from then on, without a +restart: + +- a new `RunDiagnostic` is refused with `ServiceDisabled` (`FAILED_PRECONDITION`), + and `GetCapabilities` reports `enabled: false`; +- every running request's queued and running routers are cancelled within 2 + seconds. Each such router's outcome is `Cancelled`, and the stream ends + with `complete` reason `Cancelled` while its consumer is still reading. A + request still in router discovery is refused with `ServiceDisabled`; +- nothing resumes when the service is turned back on. Request tokens and + probe packets already charged stay charged, so the customer service starts + any new attempt itself, with a new request ID. + +Routing, operator `Query`/`ListNodes`, direct node probes, `FabricQuery` +execution and the limiter's buckets and election are untouched: turning the +switch never starts a recovery hold. Turn it back on with +`{"data":{"service":"enabled"}}`. + +### Telemetry and diagnosis + +The gateway logs one line per Looking Glass request the leader ran, +`Looking Glass request finished`, with the service name, project, request ID, +operation, reason, router counts (`routers`, `selected`, `successful`, +`failed`, `omitted`, `truncated`) and duration; a request refused before its +snapshot is logged at debug level only. No log line or metric label carries +a target, a result, node error text, or node or pod names, and no metric +label carries a project, request or service name. + +To find out why requests fail: + +1. `fabric_api_gateway_service_requests_total{operation,reason}` gives each + request's end: a terminal coverage reason (`Succeeded`, `PartialResults`, + `ExecutionFailed`, ...), the refusal's reason before the snapshot + (`Throttled`, `QueueFull`, `ServiceDisabled`, `LimiterUnavailable`, ...), + or `DeliveryFailed` when the stream broke. A follower counts only what it + refused itself; the leader counts the rest, including forwarded requests + it refused. +2. For throttling, `fabric_api_gateway_admission_refusals_total{class,scope,reason}` + splits refusals by traffic class (`service`, `operator`, `fabricquery`) + and limiter scope; see [Limits and capacity](configuration.md#limits-and-capacity). +3. For `LimiterUnavailable`, `fabric_api_gateway_limiter_state` shows whether + the leader is `ready`, `recovering` or `unavailable`, and + `fabric_api_gateway_clock_synchronized` whether its clock is trusted. + `fabric_api_gateway_limiter_keys{kind}` near 4096 project or 16384 + destination keys means new keys are refused until old ones refill. +4. For failed routers, `fabric_api_gateway_service_router_outcomes_total{operation,outcome}` + gives each router's failure or omission reason, and + `fabric_api_node_permits_total{outcome}` on the node why it refused a + permit. +5. A specific request's log line, found by its request ID, gives its counts. + +### Upgrade and rollback + +Roll out in the [Enabling](#enabling-aggregate-probe-budgets) order, then switch the service on only +after the cell's qualification. Every replica must run an image that knows +`--service-config-map` before `components/service` is applied; an older +image refuses to start on the unknown flag. A node without `--probe-permits` +never runs a probe for the gateway under `--aggregate-budgets` (its router +fails `QueryTypeUnavailable`), so mixed node versions reduce coverage, not +the budgets. + +To roll back: + +1. Switch the service off (above); running requests stop within 2 seconds. +2. Remove `components/service`. Its ConfigMap is pruned, which also reads as + off. +3. Remove `components/fabric-api-require-permits`, a routing rollout. Direct + operator probes are no longer charged. +4. Remove `components/aggregate-budgets`. Probes are no longer charged to + the aggregate budgets. +5. Remove `components/fabric-api-permits`, a routing rollout. -Roll back in the reverse order. Removing `--aggregate-budgets` while nodes still -require permits refuses every gateway probe (`LimiterUnavailable`). +Keep step 4 after step 3: nodes requiring permits refuse every probe while +no gateway issues them. ## Verifying diff --git a/docs/fabric-api/security.md b/docs/fabric-api/security.md index f49cccc48..13cb5cb34 100644 --- a/docs/fabric-api/security.md +++ b/docs/fabric-api/security.md @@ -128,10 +128,13 @@ service presents the certificate on its gRPC connection to the gateway's `debug` port and, to rotate without a restart, reloads the files as cert-manager renews them; the gateway accepts the overlapping-bundle rotation below. The service contract is [service-contract.md](../designs/looking-glass-service.md). The gateway -does not execute service diagnostics: it answers a valid `RunDiagnostic` -with `ServiceDisabled`, and `GetCapabilities` reports `enabled: false`. With -`--aggregate-budgets`, `GetCapabilities` also lists `aggregate-probe-budgets` -and the cell's admission limits. +executes service diagnostics only while its service switch is on, under +`--aggregate-budgets` (see +[Operating the Looking Glass service](operations.md#operating-the-looking-glass-service)); +otherwise it answers a valid `RunDiagnostic` with `ServiceDisabled`, and +`GetCapabilities` reports `enabled: false`. While execution is on, +`GetCapabilities` also lists `aggregate-probe-budgets` and the cell's +admission limits. ### Rotation diff --git a/docs/observability/alerts.md b/docs/observability/alerts.md index 0f8368ebd..45bc261d6 100644 --- a/docs/observability/alerts.md +++ b/docs/observability/alerts.md @@ -63,6 +63,10 @@ carries `service: galactic`, `team: connect` and a `runbook_url`. | FabricAPICertificateRenewalFailing | mTLS certificate expires in under 4 hours | 15m | warning | | FabricAPICredentialsMissing | `fabric_api_credentials_loaded == 0` | 15m | warning | | FabricAPISearchIndexUnsynced | search index holds routes but is not synced with bgpd | 15m | warning | +| FabricAPILimiterUnavailable | no gateway replica has had a ready aggregate limiter | 10m | warning | +| FabricAPIClockUnsynchronized | limiter or permit-checking kernel clock not synchronised | 10m | warning | +| FabricAPIServiceThrottled | over half of 20+ Looking Glass requests in 30m throttled | 15m | warning | +| FabricAPIServiceExecutionFailing | over half of 10+ executed Looking Glass requests in 30m failed | 15m | warning | | FabricAPIMetricsDown | `fabric-api-node` or `fabric-api-gateway` scrape down | 10m | warning | | GalacticEdgeAttachmentNotProgrammed | admitted and allocated attachments not programmed by their node | 15m | warning | | GalacticEdgeServicePolicyUnresolved | an `EdgeService`'s `TrafficPolicyResolved` is False | 10m | warning | diff --git a/tests/manifests/README.md b/tests/manifests/README.md new file mode 100644 index 000000000..0c322a7de --- /dev/null +++ b/tests/manifests/README.md @@ -0,0 +1,6 @@ +# Manifest render fixtures + +`task test:manifests` builds every kustomization here with kustomize. Each +directory under `fabric-api/` composes opt-in Components the way a cell +overlay does and must build; each directory under `invalid/` lists a +Component without the one it requires and must fail to build. diff --git a/tests/manifests/fabric-api/gateway-service/kustomization.yaml b/tests/manifests/fabric-api/gateway-service/kustomization.yaml new file mode 100644 index 000000000..fcd705d08 --- /dev/null +++ b/tests/manifests/fabric-api/gateway-service/kustomization.yaml @@ -0,0 +1,7 @@ +# The gateway enforcing aggregate budgets and serving the Looking Glass +# service behind its switch. +resources: + - ../../../../config/fabric-api/base +components: + - ../../../../config/fabric-api/components/aggregate-budgets + - ../../../../config/fabric-api/components/service diff --git a/tests/manifests/fabric-api/node-permits/kustomization.yaml b/tests/manifests/fabric-api/node-permits/kustomization.yaml new file mode 100644 index 000000000..d93f2805e --- /dev/null +++ b/tests/manifests/fabric-api/node-permits/kustomization.yaml @@ -0,0 +1,7 @@ +# The node sidecar requiring probe permits, with every Component it needs. +resources: + - ../../../../config/fabric-router +components: + - ../../../../config/fabric-router/components/fabric-api + - ../../../../config/fabric-router/components/fabric-api-permits + - ../../../../config/fabric-router/components/fabric-api-require-permits diff --git a/tests/manifests/invalid/permits-without-sidecar/kustomization.yaml b/tests/manifests/invalid/permits-without-sidecar/kustomization.yaml new file mode 100644 index 000000000..b3f8b8285 --- /dev/null +++ b/tests/manifests/invalid/permits-without-sidecar/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - ../../../../config/fabric-router +components: + - ../../../../config/fabric-router/components/fabric-api-permits diff --git a/tests/manifests/invalid/require-without-permits/kustomization.yaml b/tests/manifests/invalid/require-without-permits/kustomization.yaml new file mode 100644 index 000000000..ceb1052cb --- /dev/null +++ b/tests/manifests/invalid/require-without-permits/kustomization.yaml @@ -0,0 +1,5 @@ +resources: + - ../../../../config/fabric-router +components: + - ../../../../config/fabric-router/components/fabric-api + - ../../../../config/fabric-router/components/fabric-api-require-permits diff --git a/tests/manifests/invalid/service-without-budgets/kustomization.yaml b/tests/manifests/invalid/service-without-budgets/kustomization.yaml new file mode 100644 index 000000000..de3e2da30 --- /dev/null +++ b/tests/manifests/invalid/service-without-budgets/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - ../../../../config/fabric-api/base +components: + - ../../../../config/fabric-api/components/service