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
2 changes: 2 additions & 0 deletions cmd/galactic-edge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"go.datum.net/galactic/internal/edge/timing"
"go.datum.net/galactic/internal/metadata"
"go.datum.net/galactic/internal/plumbing/ebpf/attach"
"go.datum.net/galactic/internal/plumbing/nldump"
)

type options struct {
Expand Down Expand Up @@ -173,6 +174,7 @@ func run(parent context.Context, o *options) error {
Metrics: diag.NewMetrics(ctrlmetrics.Registry, "node"),
},
}
nldump.MustRegister(ctrlmetrics.Registry)
if err := ctrlmetrics.Registry.Register(agent.Collector{Agent: a}); err != nil {
return fmt.Errorf("register edge node metrics: %w", err)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/galactic-gateway/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"go.datum.net/galactic/internal/gateway"
"go.datum.net/galactic/internal/metadata"
"go.datum.net/galactic/internal/plumbing/ebpf/xdpdispatch"
"go.datum.net/galactic/internal/plumbing/nldump"
"go.datum.net/galactic/internal/plumbing/sysctl"
)

Expand Down Expand Up @@ -198,6 +199,7 @@ func runCmd(cfg *config.GatewayConfig) error {
gwQuota := gateway.NewNodeQuotaEnforcer(gateway.DefaultMaxRulesPerTenant, gateway.DefaultMaxRuleTableEntries)
gwTelemetry := gateway.NewPrometheusTelemetryEmitter()
gwTelemetry.MustRegister(ctrlmetrics.Registry)
nldump.MustRegister(ctrlmetrics.Registry)
gwEngine := gateway.NewEngine(gwDatapath, gwQuota, gwTelemetry)

// The gateway engine reconciler. No SRv6 address is passed: this datapath
Expand Down
2 changes: 2 additions & 0 deletions cmd/galactic-nat/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"go.datum.net/galactic/internal/controller"
"go.datum.net/galactic/internal/metadata"
"go.datum.net/galactic/internal/plumbing/ebpf/xdpdispatch"
"go.datum.net/galactic/internal/plumbing/nldump"
"go.datum.net/galactic/internal/plumbing/sysctl"
)

Expand Down Expand Up @@ -143,6 +144,7 @@ func runCmd(cfg *config.NATConfig) error {
if err != nil {
return fmt.Errorf("setup egress translation eBPF datapath: %w", err)
}
nldump.MustRegister(ctrlmetrics.Registry)
if err := ctrlmetrics.Registry.Register(
newShardStateCollector(datapath, cfg.DatapathEnabled, cfg.XDPAttach)); err != nil {
return fmt.Errorf("register egress shard state metrics: %w", err)
Expand Down
2 changes: 2 additions & 0 deletions cmd/galactic-router/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"go.datum.net/galactic/internal/plumbing/ebpf/attach"
"go.datum.net/galactic/internal/plumbing/ebpf/vipxlatmap"
"go.datum.net/galactic/internal/plumbing/loaddr"
"go.datum.net/galactic/internal/plumbing/nldump"
"go.datum.net/galactic/internal/reconcile"
galacticruntime "go.datum.net/galactic/internal/runtime"
"go.datum.net/galactic/internal/runtime/gobgp"
Expand Down Expand Up @@ -105,6 +106,7 @@ func runCmd(cfg *config.RouterConfig) error {
}
serviceRouteMetrics := serviceroute.NewMetrics()
serviceRouteMetrics.MustRegister(ctrlmetrics.Registry)
nldump.MustRegister(ctrlmetrics.Registry)

// ctx carries a cause so an ordinary signal-triggered shutdown can be told
// apart from the health server's own Serve failure below. See the cause
Expand Down
2 changes: 2 additions & 0 deletions cmd/galactic-vrf/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"go.datum.net/galactic/internal/config"
"go.datum.net/galactic/internal/ingresssidecar"
"go.datum.net/galactic/internal/metadata"
"go.datum.net/galactic/internal/plumbing/nldump"
)

const (
Expand Down Expand Up @@ -67,6 +68,7 @@ func runCmd(cfg *config.VRFConfig) error {

metrics := ingresssidecar.NewMetrics()
metrics.MustRegister(ctrlmetrics.Registry)
nldump.MustRegister(ctrlmetrics.Registry)
lifecycle := ingresssidecar.NewLifecycleMetrics(cfg.SweepInterval, cfg.TeardownGracePeriod)
lifecycle.MustRegister(ctrlmetrics.Registry)

Expand Down
1 change: 1 addition & 0 deletions docs/observability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Metrics, scrape configuration and shipped alert rules. Use the subsystem referen
- [Routing](routing.md)
- [NAT66 / NAT64 — `galactic_nat_*`](nat.md)
- [Fabric looking glass — `fabric_api_*`](fabric-api.md)
- [Netlink listings — `galactic_netlink_dump_*`](netlink.md)
- [Shipped alerts](alerts.md)

## Where the metrics come from
Expand Down
45 changes: 45 additions & 0 deletions docs/observability/netlink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Netlink listings — `galactic_netlink_dump_*`

See [scraping and component ports](README.md#where-the-metrics-come-from).

The kernel interrupts a listing of links, addresses or routes when another
process changes them while it runs. The listing is then discarded and
retried: up to 5 rounds of 10 back-to-back attempts, with a pause of 20, 40,
60 and 80 ms between rounds. These counters show how often that happens on a
node, so sustained churn is visible before it makes a component fail.

| Metric | Type | Labels | Meaning |
| ----------------------------------------- | ------- | ----------------------------------- | ---------------------------------------------------------------------------------------------- |
| `galactic_netlink_dump_interrupted_total` | counter | `kind` (`link`, `address`, `route`) | Listing attempts the kernel interrupted. Each one is discarded and retried |
| `galactic_netlink_dump_failures_total` | counter | `kind` (`link`, `address`, `route`) | Listings still interrupted on their last attempt. The caller got an error and acted on nothing |

Each process counts only its own listings, on its existing metrics port:

| Component | Port | `job` from `config/monitoring/` |
| --------------------------------------- | -------------- | ---------------------------------------- |
| `galactic-cni` (`credential-refresh`) | 9180 | `galactic-cni` |
| `galactic-router`, `galactic-router-rr` | 9179 | `galactic-router` / `galactic-router-rr` |
| `galactic-nat` | 9182 | `galactic-nat` |
| `galactic-edge` | 9186 | `galactic-edge` |
| `galactic-vrf` | 9182 (default) | none shipped |
| `galactic-gateway` | 8081 | none shipped |

`galactic-vrf` and `galactic-gateway` need a scrape object of your own.
Until one exists, the queries below show nothing for them, which is not the
same as no churn.

The CNI plugins run once per attach and expose no metrics, so their
listings are not counted; an exhausted retry there fails the attach or
detach with the interruption error. Listings that do not go through the
shared retry are not counted either.

Interruptions are normal while pods start and stop. A failure is not: the
component returned an error for that pass and retries it later.

```promql
# Interruptions per second, by node, component and kind
sum by (node, job, kind) (rate(galactic_netlink_dump_interrupted_total[5m]))

# Listings that failed after every retry in the last hour
sum by (node, job, kind) (increase(galactic_netlink_dump_failures_total[1h])) > 0
```
2 changes: 2 additions & 0 deletions internal/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"go.datum.net/galactic/internal/plumbing/ebpf/metrics"
"go.datum.net/galactic/internal/plumbing/ebpf/prog"
"go.datum.net/galactic/internal/plumbing/ebpf/usidmap"
"go.datum.net/galactic/internal/plumbing/nldump"
"go.datum.net/galactic/internal/plumbing/radv"
)

Expand Down Expand Up @@ -1109,6 +1110,7 @@ func Run(ctx context.Context, grpcHealthPort, metricsPort int) error {
slog.Info("Starting CNI installer run daemon", "grpcHealthPort", grpcHealthPort, "metricsPort", metricsPort)

m := metrics.New()
nldump.MustRegister(m.Registry)

ebpfState, datapath, err := startEBPFDatapath(ctx, m)
if err != nil {
Expand Down
101 changes: 101 additions & 0 deletions internal/plumbing/nldump/churn_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2026 Datum Cloud, Inc.
//
// SPDX-License-Identifier: AGPL-3.0-or-later

package nldump

import (
"fmt"
"os"
"sync"
"testing"
"time"

"github.com/containernetworking/plugins/pkg/ns"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/vishvananda/netlink"
)

func requireRoot(t *testing.T) {
t.Helper()
if os.Geteuid() != 0 {
t.Skip("test requires root (CAP_NET_ADMIN) to create a network namespace; re-run via sudo")
}
}

// TestLinkList_CountsRealInterruptions lists links on a real kernel while
// other goroutines add and remove links in the same namespace. Every listing
// succeeds, and the interrupted counter records the interruptions the
// kernel reported along the way.
func TestLinkList_CountsRealInterruptions(t *testing.T) {
requireRoot(t)
nsObj, err := ns.TempNetNS()
if err != nil {
t.Fatalf("create test netns: %v", err)
}
t.Cleanup(func() { _ = nsObj.Close() })

err = nsObj.Do(func(_ ns.NetNS) error {
for i := range 300 {
if err := netlink.LinkAdd(&netlink.Dummy{LinkAttrs: netlink.LinkAttrs{Name: fmt.Sprintf("stab%d", i)}}); err != nil {
return fmt.Errorf("add stable link %d: %w", i, err)
}
}
return nil
})
if err != nil {
t.Fatal(err)
}

stop := make(chan struct{})
var wg sync.WaitGroup
for c := range 2 {
wg.Add(1)
go func() {
defer wg.Done()
_ = nsObj.Do(func(_ ns.NetNS) error {
for i := 0; ; i++ {
select {
case <-stop:
return nil
default:
}
dummy := &netlink.Dummy{LinkAttrs: netlink.LinkAttrs{Name: fmt.Sprintf("churn%d_%d", c, i%4)}}
if err := netlink.LinkAdd(dummy); err == nil {
_ = netlink.LinkDel(dummy)
}
// Bursts of changes, not a saturated loop that could
// outlast any bounded retry.
time.Sleep(2 * time.Millisecond)
}
})
}()
}
t.Cleanup(func() {
close(stop)
wg.Wait()
})

before := testutil.ToFloat64(interrupted.WithLabelValues(kindLink))
beforeFailures := testutil.ToFloat64(failures.WithLabelValues(kindLink))
err = nsObj.Do(func(_ ns.NetNS) error {
// Churn interrupts a listing within a few iterations; the deadline
// only bounds a kernel that never reports one.
deadline := time.Now().Add(10 * time.Second)
for i := 0; testutil.ToFloat64(interrupted.WithLabelValues(kindLink)) == before; i++ {
if time.Now().After(deadline) {
return fmt.Errorf("no interruption counted after %d listings under link churn", i)
}
if _, err := LinkList(); err != nil {
return fmt.Errorf("LinkList failed on iteration %d while links were changing: %w", i, err)
}
}
return nil
})
if err != nil {
t.Fatal(err)
}
if d := testutil.ToFloat64(failures.WithLabelValues(kindLink)) - beforeFailures; d != 0 {
t.Errorf("failure counter rose by %v, want 0", d)
}
}
Loading
Loading