Repository navigation
refactor(cni): Create datapath metrics with the instrumentation library - #1184
Conversation
The CNI run daemon served a private registry, and the netlink listing counters were registered by every binary on whatever registry it passed in. Neither went through go.miloapis.com/instrumentation, so the reserved-label check and its lint never saw them. - internal/plumbing/ebpf/metrics creates its counters and gauges with the library's constructors and registers the map collectors with metrics.MustRegister. Metrics no longer carries a registry or a handler, and the run daemon serves metrics.Handler. - The endpoint snapshot collector is shared by every SidecarReturn, because a collector can be registered only once per process. - The nldump counters are created when the package loads. Every binary that serves metrics and links nldump registered them before, so the explicit MustRegister calls are gone. - Registering the map collectors can no longer fail at run time; a descriptor clash now panics at startup instead of being logged. Series names, labels and types are unchanged. The CNI endpoint now also exports instrumentation_build_info and the standard Go runtime, process and controller-runtime series that controller-runtime's registry carries, which the private registry did not. Tests read the shared registry and check how much a counter changed, so repeated runs and other tests can't change their result. The CNI scrape test creates the run daemon's series first and lints them. Refs: #1149 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The root-only suite runs the CNI daemon against a real datapath, which registers the map collectors on the shared registry and closes their maps when it stops. A later test in the same process that gathered the whole registry then failed on those collectors' errors, as the sidecar return and egress group route tests did. Those tests now read only the families under the prefix they check, and fail on a collection error only from one of those families. Refs: #1149 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Polylane could not verify the production impact of this pull request. I checked the production account: the only Galactic workload deployed is fabric-identity-system/galactic-controller-fabric, which does not link the changed packages. No galactic-cni, router, NAT, gateway, edge or vrf workload runs in datum-cloud-prod. Also considered · 5 refuted
Analysed against 1 cloud account and 1 repository
Polylane could not find the cloud resources this repository manages, so this review looked at the entire cloud account. Connect this repository to its resources and the next review will focus on exactly what this code deploys to. Polylane analysed Did this help? React 👍 or 👎 so the next review is sharper. |
ecv
left a comment
There was a problem hiding this comment.
Approve.
Every datapath, egress-control, sidecar-return, endpoint-slice-repair, event and nldump series keeps its name, type, labels and help; the library adds no prefix or suffix and no constant labels, and galactic-cni run serves the same registry it now creates on. CI is green.
galactic-cni/metrics now also carries the Go and process series,instrumentation_build_infoand any client-go series, because it serves the shared registry instead of a private one. All additive; nothing in infra queries the old absence.RegisterDatapathCollectorandRegisterEgressShardCollectornowMustRegister, so a descriptor clash panics the daemon at startup where it used to log a warning and run without datapath metrics. Same collectors and names as before, so no clash exists today.- The plugin ADD/DEL binaries never built
metrics.New(), so they lose nothing; only therundaemon exports.
Follow-ups:
- Binaries that link
nldumpwithout having calledMustRegister(for examplefabric-config-agent,galactic-controller) now export zero-valuedgalactic_netlink_dump_*series. Harmless, but worth knowing if cardinality is ever audited.
Summary
The CNI daemon served its datapath metrics from a private registry, and every binary registered the netlink listing counters on whatever registry it passed in, so the instrumentation library's reserved-label check and lint never saw them.
Both now go through the library, and the CNI daemon serves the library's handler.
This is the first of seven layers that move every Galactic metric onto the library, one subsystem each.
Stack
Merge in order:
Compatibility
Every existing CNI series keeps its name, labels and type. The endpoint also gains the build-info series and about 150 standard Go runtime, process and controller-runtime families from the shared registry, which the private registry left out. No scrape config caps samples.
Rolling back restores the previous endpoint. No state is persisted.
The draft #598 edits two of the CNI files this layer changes. Whichever lands second rebases, and #598's new metrics then go through the library to pass the adoption test.
Test plan
Related to #1149
🤖 Generated with Claude Code