Skip to content

fix(node-metrics): count only pod uplinks, include native sidecars, cache owner misses - #1443

Merged
beneiltis merged 1 commit into
mainfrom
fix/node-metrics-uplinks-sidecars
Nov 13, 2026
Merged

beneiltis merged 1 commit into
mainfrom
fix/node-metrics-uplinks-sidecars

Conversation

@beneiltis

Copy link
Copy Markdown
Contributor

Found by running node-metrics with MO_LOG_LEVEL=debug on homeserver (develop.856) for a few minutes.

Changes

Count only pod uplinks (networkmonitor.go, snoopy.go)
An ARC runner pod runs docker-in-docker as a native sidecar; its netns has docker0 and one veth per job container. metricsToPodstats summed every interface except lo, so traffic of a job container (veth → docker0 → eth0) was counted two or three times. Traffic is now summed over eth<N> (CNI; containerd numbers extra networks eth1, …) and net<N> (Multus) only. This applies to snoopy and /proc/net/dev data alike and works with any snoopy version. mogenius/snoopy#173 additionally stops snoopy from attaching to those inner interfaces.

Native sidecars (podinfo.go, store/podsonnode.go)
NewPodInfoList only read containerStatuses. Native sidecars (init containers with restartPolicy: Always, e.g. the dind sidecar here, or Istio/Linkerd in native sidecar mode) only appear in initContainerStatuses, so their processes were missing from the per-process cpu/memory stats. Both lists are read now; exited regular init containers have no processes and drop out in the process lookup. The slim pod view decodes initContainerStatuses as well.

Owner cache misses (store/ownercacheservice.go)
Every minute AddInterfaceStatsToDb resolves each pod's controller. Pods without owner and pods owned by kinds OwnerFromReference does not handle (EphemeralRunner, AutoscalingListener, Sandbox, …) were never cached, so each of them loaded the full pod from Valkey every minute. Both results are cached now (cleared on pod delete as before). Supported kinds that fail to resolve are still not cached, their owner may just not be in the store yet. Return values are unchanged.

Verification

go build ./..., go vet, unit tests and golangci-lint clean. Not yet deployed.

🤖 Generated with Claude Code

…ache owner misses

- sum traffic only over eth<N> (CNI) and net<N> (Multus): in pods with a
  nested runtime (docker-in-docker, kind) the bridges and veths carry the
  same traffic as eth0, which was counted two or three times; this also
  covers the /proc/net/dev fallback and old snoopy versions
- read initContainerStatuses too: native sidecars (restartPolicy Always,
  e.g. dind or a mesh proxy) were missing from per-process cpu/memory
  stats; exited init containers have no processes and drop out
- cache pods without owner and pods with an unsupported owner kind
  (EphemeralRunner, AutoscalingListener, Sandbox, ...): node-metrics
  loaded the full pod from Valkey for each of them every minute

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@beneiltis
beneiltis force-pushed the fix/node-metrics-uplinks-sidecars branch from 791608b to ac737d6 Compare November 13, 2026 13:00
@beneiltis
beneiltis merged commit 43755bb into main Nov 13, 2026
3 checks passed
@beneiltis
beneiltis deleted the fix/node-metrics-uplinks-sidecars branch November 13, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant