Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions cmd/galactic-router/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func setupServiceRouteController(
ctrl.Log.Error(err, "service route eBPF maps are not available yet; initialization will retry on reconcile")
}

return (&controller.ServiceRoutePolicyReconciler{
if err := (&controller.ServiceRoutePolicyReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
NodeName: nodeName,
Expand All @@ -465,7 +465,17 @@ func setupServiceRouteController(
Metrics: serviceRouteMetrics,
FrontendEnabled: frontendEnabled,
Applied: make(map[types.NamespacedName]map[types.NamespacedName]serviceroute.RouteIntent),
}).SetupWithManager(mgr)
}).SetupWithManager(mgr); err != nil {
return err
}
if err := (&controller.ServiceProducerHealthReconciler{
Client: mgr.GetClient(),
NodeName: nodeName,
Metrics: serviceRouteMetrics,
}).SetupWithManager(mgr); err != nil {
return fmt.Errorf("setup service producer health controller: %w", err)
}
return nil
}

// newRootCommand builds the root cobra command with all flags and the
Expand Down
1 change: 1 addition & 0 deletions config/galactic-router/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ rules:
- servicevipbindings/status
- networkservices/status
- serviceroutepolicies/status
- serviceendpoints/status
verbs: ["get", "update", "patch"]
- apiGroups: ["galactic.datumapis.com"]
resources:
Expand Down
8 changes: 5 additions & 3 deletions docs/agents/ARCHITECTURE-ROUTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,16 @@ lives in `root.go`'s `runCmd`:
with the manager — see the peer-FSM design decision below.
9. Register the controllers: BGPRouter, BGPPeer, BGPAdvertisement,
BGPVRFInstance, BGPPolicy, Secret, Node, ServiceVIPBinding,
NetworkServiceBinding, NodeDeparture, ServiceRoutePolicy (plain role only;
a route reflector has no service route maps to program and skips it),
NetworkServiceBinding, NodeDeparture, ServiceRoutePolicy and
ServiceProducerHealth (plain role only; a route reflector has no service
route maps to program and skips both),
and GC (the GC controller also starts a ticker goroutine that waits for
cache sync, then runs on `--gc-interval`, default 5m; NodeDeparture
sweeps on the same interval, and when `vip_xlat_table` opened in step 6,
each GC tick after the first pass also sweeps it).
10. `mgr.Start(ctx)` — blocks until the signal-handler context is cancelled.

Apart from the ServiceRoutePolicy controller and the `vip_xlat_table` log
Apart from the ServiceRoutePolicy and ServiceProducerHealth controllers and the `vip_xlat_table` log
level noted above, this is identical whether the pod is running in the plain
role (`config/galactic-router/overlays/router/`, opt-in via
`galactic.datumapis.com/galactic=router` — deployed on both `compute` and
Expand Down Expand Up @@ -278,6 +279,7 @@ co-located `galactic-gateway` container's own health port on the same
- **A tenant VRF route that fails to install is retried, not dropped.** `processEVPNPath` writes a VRF-scoped path's route into `egress_route_table` through `internal/runtime/gobgp/vrfroutes.go`. `Register` resolves the SID's uplink and neighbor MAC at write time, which fails while an uplink is still coming up after a restart, and BGP never redelivers an unchanged best path, so before #676 such a route stayed missing until the path changed upstream. `vrfRoutes` keeps each failed route in a pending set and retries it whenever the main table changes (1s debounce) and every 30s, until it installs or its path is withdrawn; removing a VRF drops its pending routes. One mutex serializes every write to the map from this runtime, taken per route during a retry so an unresolvable neighbor (up to 2s) does not hold up the RIB watcher for the whole pass. `EgressRouteTable.Refresh` cannot cover this: it walks existing entries only. The pending count, and the plain-route reconciler's failing count, are exported as `galactic_router_route_install_failing{kind="vrf"|"plain"}`, and `GalacticRouterRoutesNotInstalled` fires when either stays above 0 for 10 minutes.
- **`ServiceVIPBinding`s are generated, one per node per backend.** `NetworkServiceBindingReconciler` (`internal/controller/networkservice_binding_controller.go`) runs on every node and writes a binding for each VIP of each accepted `NetworkService`, at most one per family (`ruleTranslatedVIPs`) and, for the IPv4 VIP, only while some gateway node's `<node>/IPv4Served` condition reports it loaded (`ipv4LoadedOnSomeNode`; a status change to that signal passes `ruleBindingInputsChanged`, and the node deletes its IPv4 bindings once no gateway does), and each backend the rule's `backendSelector` places on this node, through the same `selectRuleBackends` the gateway uses, so the gateway never sends a backend's flows to a node with no binding planned for it. Workloads are IPv6 only, so both VIPs' backends are the selected attachments' IPv6 addresses: an IPv4 VIP's binding pairs the IPv4 `vipAddress` with an IPv6 `backendAddress`, which the backend node serves by translating the flows (see [ARCHITECTURE-CNI.md](ARCHITECTURE-CNI.md#key-design-decisions)). `ServiceVIPBindingReconciler` refuses an IPv4 `backendAddress` with `BindFailed`. Each node writes and deletes only its own bindings (labelled `galactic.datum.net/binding-node` and `app.kubernetes.io/managed-by: galactic-router`), so there is one writer per object and no leader election. A binding is owned by its rule, records the rule's `vpcRef` (which names the VRF its rows go in) and takes `egressKind` from the attachment's interface mode. `ServiceVIPBindingReconciler` programs a binding only when a `BGPAdvertisement` on this node's `BGPRouter` with that VRF's ID has a prefix containing `backendAddress`, and otherwise reports `BindFailed`; it watches advertisements on its own router so a binding written before its advertisement converges, and teardown skips the check. A backend serves only the oldest rule (by creation time, then namespace/name) selecting it on the same backend port and protocol, since its node translates the backend's replies back to only one VIP; a claim (`backendClaim`) carries the VIP's family, since a reply to an IPv4 client takes the IPv4 VIP's egress-translated row and any other reply the IPv6 VIP's egress row, so one backend socket answers for one VIP of each family, an IPv4 rule never competes with an IPv6 one, and two rules with IPv4 VIPs on one socket do; both sides compute that owner with `ruleBackendOwners` over every rule in the namespace, so a newer rule gets no binding for the backend and no flows for it from the gateway, and every rule in a namespace is re-queued when one of them changes. Rules compete only within a VPC, so the per-VPC `VPCAttachment` fan-out still reaches every rule an attachment change can affect. The node summarizes its bindings on the rule as `<node>/BackendsBound` (`BackendsClaimed` names a backend an older rule serves); a rule whose spec cannot be built into bindings (a second IPv6 VIP, or a selector that does not parse) keeps the node's existing bindings, the same as a rule that loses `Accepted`, so an invalid edit does not drop the backend nodes' `vip_xlat_table` rows; a second IPv4 VIP does the same for the IPv4 family alone, writing no IPv4 binding and keeping the IPv4 ones it had while the IPv6 VIP's bindings stay current, and both report `InvalidRule`. Only the nodes that hold bindings for such a rule report `InvalidRule`, since the gateways already report the error and a condition from every node would be a status write per node per edit. Each rule reconcile lists only its own VPC's attachments, through the VPCAttachment→`status.vpc` field index (`listVPCAttachmentsInVPC`), and skips the cache's deep copy because nothing it does writes to them. Several backends of one VIP can share a node: the gateway writes each backend's slot into the uSID and `usid.c` keys the ingress row on it (#799).
- **Each node probes its own backends and publishes their health.** For a `NetworkService` with `spec.healthCheck`, `BackendHealthReconciler` (`internal/controller/backendhealth_controller.go`) runs one TCP probe loop per backend on its node (`internal/healthprobe`), over the backend's host-side interface (the attachment's `status.hostInterface`) from that interface's link-local address, on `healthCheck.port` or the rule's `backendPort`. The link-local source is what lets the SYN-ACK back: `usid_egress` hands a reply to a link-local destination to the kernel before its VIP rewrite (see [ARCHITECTURE-CNI.md](ARCHITECTURE-CNI.md#key-design-decisions)). A decision moves after `unhealthyThreshold` consecutive failures or `healthyThreshold` consecutive successes; a probe that cannot be sent (no interface, no link-local address) counts toward `Unknown`/`ProbeUnavailable`, never toward `Unhealthy`. The decision goes into `status.health` of each of the backend's bindings, with the attachment UID and probed port, by a merge patch of that field alone and only when it changes, so it never races the `Bound` condition. Every binding of one backend shares one loop. A restarted router seeds each loop from the published decision when its attachment UID and port still match, so a restart changes no gateway's table. A rule losing its `healthCheck` clears `status.health` and stops the loops. The design is [docs/gateway/backend-health.md](../gateway/backend-health.md).
- **A `Spread` service endpoint's producers are probed by their own node, and a consumer's route reads a producer set.** `ServiceProducerHealthReconciler` (`internal/controller/serviceproducerhealth_controller.go`) runs one `internal/healthprobe` loop per producer on its node of each `ServiceEndpoint` with `spec.distribution: Spread`, to the producer attachment's first IPv6 address on `healthCheck.port`, and server-side applies that node's entries of the endpoint's `status.producers` under its own field manager (`galactic-router/<node>`), so nodes never overwrite each other's entries and an entry a node stops applying disappears. `ServiceRoutePolicyReconciler` reads them: for a Spread endpoint, `serviceroute.Compile` emits one `LocalSet` intent per consumer holding every producer on the consumer's node, `Unhealthy` ones marked draining unless all are. `EBPFRouteProgrammer` writes it as a mode-3 `service_route_table` row plus a `service_producer_set_table` row under the same key; `usid_egress` pins each TCP flow in `service_flow_table` and picks a producer per UDP datagram (see [docs/router/private-service-routes.md](../router/private-service-routes.md#several-producers-on-one-node)). A changed `LocalSet` intent is applied before the old one is removed, and the programmer keeps the newest of a key's producer sets in the map, so a health or membership change never drops the consumer's route. A datapath without the producer set map gets `serviceroute.ErrProducerSetsUnavailable` for `LocalSet` intents only.
- **Surviving routers clean up after a departed node.** Only a node's own `NetworkServiceBindingReconciler` clears its `<node>/BackendsBound` conditions and deletes its generated bindings, and only its own `ServiceVIPBindingReconciler` removes the teardown finalizer from bindings targeting it. So once a node's `Node` object is deleted, `NodeDepartureReconciler` (`internal/controller/node_departure_controller.go`) on every other router removes that node's `BackendsBound` condition from every `NetworkService`, deletes its generated bindings and removes the finalizer from every binding whose `targetRef.name` names it, hand-written ones included; the kernel rows went with the node. Without it the conditions stayed forever and a deleted rule's bindings stayed `Terminating`. Every Node create and delete maps to one sweep key, so the sweep runs on the initial Node list (startup), on every Node delete and every `--gc-interval`, and a router down during the delete still converges. A node missing from the cached Node list counts as departed only once an uncached `Get` returns NotFound. Every router sweeps, with no leader election: status writes and finalizer patches retry on conflict (the patch carries the resourceVersion) and NotFound counts as done.
- **Deleting a `ServiceVIPBinding` does not need its VRF on the node.** A binding's two `vip_xlat_table` rows are keyed on its VRF's uSID Argument. `ServiceVIPBindingReconciler` reads it from the `BGPVRFInstance` its `vpcRef` names on this node, and that is gone once the VPC leaves the node. Before #750, deletion re-derived it, failed, held the finalizer forever and left both rows in the map. Teardown now finds the rows by value with `vipxlatmap.UnregisterBinding`: since #764 each key carries the VIP or backend address, and since #799 the ingress key also carries the backend's slot, so the binding's ingress row (its VIP, port and slot, rewriting to its backend) and egress row (its backend and port, rewriting to its VIP) are found exactly, under any Argument. Each row is removed only while it still holds the binding's values, so a row another binding has since written stays. When the VRF context still resolves, `UnregisterBindingAt` applies the same checks at that location too. Neither pass deletes a row without first reading it, and a process-wide lock keeps a bind from landing between the read and the delete. A value check cannot tell two bindings with identical values apart, so while such a twin is live on the node, deleting one removes nothing. Rows exist only for an IPv6 backend, so an IPv4 or unparseable `backendAddress` skips both passes instead of blocking deletion. Only a failed kernel delete keeps the finalizer. Rows left behind some other way, by a finalizer cleared by hand, a crash or a manual write, are removed by the periodic sweep below; to remove one sooner, use `galactic-router vip xlat list` and `vip xlat remove --protocol --vip --port --backend --backend-port` (`--slot` defaults to the backend's own), run in that node's `galactic-router` pod (`kubectl exec <pod> -- /galactic-router vip xlat list`).
- **`vip_xlat_table` holds both VIP families in one layout.** The map (`struct vip_xlat_key`, 32 bytes: block, argument, protocol, direction, port, slot, 16-byte address; `struct vip_xlat_value`, 18 bytes: 16-byte address, port) is pinned by `galactic-cni` at `/sys/fs/bpf/galactic/vip_xlat_table` and reused across restarts and upgrades by `attach.Load`; `galactic-router`'s `ServiceVIPBindingReconciler` and the `vip xlat` CLI are its only writers. Its layout is fixed, since CNI ADD and binding time write the rows and a new layout would empty the map until every binding was written again. A binding writes two rows, by its VIP's family (every key also carries block, argument and protocol):
Expand Down
32 changes: 21 additions & 11 deletions docs/enhancements/networking/private-service-connect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,19 @@ in the edge API. It derives current desired programming through these steps:
1. Resolve `serviceRef`, validate the service tuple and placement, and resolve
the pinned consumer VPC name and UID.
2. Select producer attachments with current-generation `Ready` and `Programmed`
status, a node, allocated network identities, and a host interface. Service
owners must ensure selected producers are also healthy for the declared tuple.
status, a node, allocated network identities, and a host interface. For a
`Single` endpoint, service owners must ensure selected producers are also
healthy for the declared tuple; a `Spread` endpoint's producers are probed
by their nodes.
3. Select consumer attachments through protected labels and verify their live
VPC membership and programmed attachment identity.
4. Choose one producer for each consumer. Prefer a local producer; `NodeLocal`
leaves the consumer without a path if none is available. `PreferNodeLocal`
permits a ready remote producer. Selection uses a deterministic attachment
ordering, not round-robin balancing or application health probes.
4. Choose producers for each consumer. A `Single` endpoint gets one, chosen by
a deterministic attachment ordering, preferring a local producer. A `Spread`
endpoint gets every producer on the consumer's node as one set: new flows go
to the ones its health check has not found `Unhealthy`, each TCP connection
stays with its first producer, and each UDP datagram picks its own. In both,
`NodeLocal` leaves the consumer without a path if no local producer is
available, and `PreferNodeLocal` permits one ready remote producer.
5. Program this node's consumer and producer paths. Remote paths require both
sides' trusted attachment identities, matching service grants, and return
routing. Grants bind the policy, endpoint, and attachment lifetimes to the
Expand All @@ -355,9 +360,12 @@ policy intent invalid. A missing endpoint or mismatched VPC identity invalidates
the contract and requires stale access to be removed. An unresolved remote path
prevents that node from serving even if the shared policy remains accepted.

Service owners withdraw unhealthy producers through the endpoint's selection
contract. Galactic's attachment readiness checks establish network eligibility;
they do not substitute for service health.
Service owners of a `Single` endpoint withdraw unhealthy producers through the
endpoint's selection contract. Galactic's attachment readiness checks establish
network eligibility; they do not substitute for service health. A `Spread`
endpoint's producers are probed over TCP by their own node, which publishes
each decision in the endpoint's `status.producers`; see
[Private service routes](../../../router/private-service-routes.md#several-producers-on-one-node).

### Status and lifecycle

Expand Down Expand Up @@ -421,8 +429,10 @@ sequenceDiagram

`NodeLocal` requires a producer on the consumer's node. `PreferNodeLocal` uses
a local producer when available and otherwise selects a ready remote producer.
Selection is deterministic. The current direct-endpoint path rejects multiple
ready producers in the same node and VPC because it cannot distinguish them.
A `Single` endpoint's selection is deterministic, and it rejects multiple ready
producers in the same node and VPC because its one-target route cannot
distinguish them. A `Spread` endpoint routes to a set of up to 16 producers on
the consumer's node instead.

Overlapping consumer addresses remain scoped to their attachments. Remote
delivery requires matching platform-programmed service grants. Tenant-supplied
Expand Down
1 change: 1 addition & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ labels, so the series stay bounded.
| `galactic_service_route_reconcile_duration_seconds` | histogram | none | Time per reconcile (default buckets) |
| `galactic_service_route_route_operations_total` | counter | `operation` (`apply`, `remove`), `result` (`success`, `error`) | Datapath writes and removals |
| `galactic_service_route_programmed_routes` | gauge | none | Attachment-scoped service paths the controller now tracks |
| `galactic_service_route_producers` | gauge | `state` (`Healthy`, `Unhealthy`, `Unknown`) | Producers of `Spread` endpoints this node probes |

Datapath drops on these paths are the `service_route_*` reasons of
`galactic_usid_drops_total`.
Expand Down
Loading
Loading