Repository navigation
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Oct 15, 2026
#919) The idle network check matched only "eth0"/"ens*", so the enp39s0 on m8a/AL2023 read 0 bytes. getNetworkBytes took prev==0 as "first call" and returned the 1,000,000 assume-active placeholder on every tick, so idle-stop could never trigger and status printed it as 976.6 KB/min of traffic. - Linux: sum every interface with a /sys/class/net/<if>/device link (lo, docker0, veth, bridges, tun, tailscale have none). No name matching. Report "unknown" when none is found instead of zeros. Parse /proc/net/dev on the colon so "eth0:4294967296" (no space) also parses. - agent: track the first sample with a bool. networkBytes() returns (bytes, measured, why), as cpuUsage does (#734). Unknown is still treated as active, and the unreadable case logs one warning that idle-stop will not trigger. A counter that goes backwards is unknown, not a negative "idle". - Windows: no adapters returned 0 ([int64]$null), not unknown. - metrics: the Prometheus network stat used the same filter and the "eth0" label. It now uses the shared reader and the real interface names. - spored status: prints "Network: unknown (...; assuming active)" and adds network_measured / network_unknown to the JSON output. Fixes #919 (#919)
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.
Fixes #919
Cause
sysReadNetworkBytesmatched onlyeth0/ens*, soenp39s0(m8a, AL2023) read 0 bytes.getNetworkBytestreatedprev == 0as the first call, so every tick returned the 1,000,000 assume-active placeholder. Idle-stop could never fire, andstatusprinted the placeholder asNetwork: 976.6 KB/min.Changes
pkg/agent/netdev.go, new and untagged so it is tested on every OS): interfaces are picked by structure. Every interface with a/sys/class/net/<if>/devicelink is summed. lo, docker0, veth, br-*, tun and tailscale have no such link. There is no name list. When nothing matches, the reader returnserrNoPhysicalInterfacerather than zeros./proc/net/devis now split on the colon, soeth0:4294967296(no space) also parses.netSampledbool.networkBytes()returns(bytes, measured, why), likecpuUsage()(spawn status reports CPU 0.0% on a 100%-busy instance: two different "unknown" sentinels rendered as measurements #734).WARNINGthat says idle-stop will not trigger on the host. Each tick also logsNot idle: network traffic could not be measured (<why>); assuming activeinstead of the fake byte count. A counter that goes backwards (ENI detach, reset) is reported as unknown, not as a negative "idle" delta.Get-NetAdapterStatisticsreturns no adapters, the old code produced[int64]$null= 0, which looked like a measured zero. It now reports unknown.GetNetworkStatshad the same name filter and always used the labeleth0. It now uses the shared reader and the real interface names, and emits no sample when nothing is found.spored status/spawn status: printsNetwork: unknown (single sample; assuming active)instead of 976.6 KB/min. The JSON output gainsnetwork_measuredandnetwork_unknown. A one-shot status always has a single sample, which matches the CPU line.Tests
Each test below was run against a revert that compiles and failed:
eth0/ensTestReadNetDevBytes_CountsPhysicalInterfacesWhateverTheirName/enp39s0_only,/multi-ENIlo.../docker0,_veth,_bridge,_tun_and_tailscale_are_not_counted,TestReadNetDevBytes_NoPhysicalInterfaceIsUnknownTestReadNetDevBytes_NoPhysicalInterfaceIsUnknownprev == 0first-sample testTestNetworkBytes_ZeroCountersAreNotAPermanentFirstSampleTestNetworkBytes_UnknownIsAssumedActiveAndWarnedOnceTestNetworkBytes_BackwardsCounterIsUnknownTestStatusTable_UnmeasuredNetworkIsNotPrintedAsAValueThe fixtures are
/proc/net/devdumps plus a fake/sys/class/netwithdevicesymlinks: enp39s0 only (the reported counters), ens5, eth0 in no-space format, ens5 plus docker0/veth/br-/tun/tailscale noise, and multi-ENI.make checkis green apart from the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, andmake check-nestedis green.Not verified
devicelink is what the kernel creates for ENA (PCI) and Xen netfront (vif), but I have not observed it on m8a.Conflicts with #916: the edits touch separate hunks in
agent.go,sys_*.goandcmd/spored/main.go, and none are adjacent to #916's changes.