Repository navigation
fix(node-metrics): one snoopy per pod, graceful stop, eBPF-attached fallback - #1439
Merged
Merged
Conversation
…allback
- start one snoopy per pod instead of per container: all containers of a
pod share the sandbox netns, so extra instances stacked a TC program
per container on every packet and Metrics() flipped between handles in
random map order; the procdev reader also reported a pod once per
container
- stop snoopy with SIGTERM and only SIGKILL after 5s, so it can detach
its programs (netlink TC filters outlive a killed process on <6.6)
- read eBPF values once snoopy attached both counters, even while zero;
the all-zero heuristic read /proc/net/dev every second for every idle
pod, and lo is no longer read at all
- hand out a copy of the snoopy status: the handler mutated the slices
in place while the collector marshaled them; stale handles are now
removed from the status and errors are stored as text instead of {}
- write status:<node>:snoopy on change (refresh every 5 min) instead of
every second
- key traffic deltas by namespace/pod: equal pod names in different
namespaces mixed their counters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
While measuring node-metrics on homeserver (k3s, kernel 6.8) it turned out that snoopy has not loaded a single eBPF program since v0.4.0; every pod's traffic came from the
/proc/net/devfallback. That is fixed in mogenius/snoopy#172. This PR is the operator side; it works with the current snoopy v0.4.37 (behaves as today) and with the fixed one.Changes
snoopy.go,podinfo.go): all containers of a pod share the sandbox netns. Extra instances stacked one more TC program per container on every packet, andMetrics()flipped between the handles in random map order, producing wrong deltas for multi-container pods. The container to enter is picked in stable order, skipping first processes that already vanished. The procdev reader (networkstatsreader.go) also reported a pod once per container; it now tracks one entry per pod./proc/net/dev" rule read procdev every second for every idle pod. Now the fallback is used only until snoopy reports both counters attached.lois skipped (it was never reported).Status()hands out a copy (the handler mutated the slices in place while the collector marshaled them); replaced stale handles are removed from the status; failures carry the error text instead of{};status:<node>:snoopyis written on change plus every 5 min instead of every second.namespace/pod(dbstats.go): equal pod names in different namespaces (e.g.postgres-0) mixed their counters.Measurements (homeserver)
Verification
go build ./...,go vet, existing unit tests andgolangci-lintclean. Not yet deployed to a cluster.🤖 Generated with Claude Code