Repository navigation
Conversation
This was referenced Oct 15, 2026
…tructure (#937) The idle check compared the since-boot disk I/O total with a per-minute threshold, and its name filter dropped every NVMe disk (nvme0n1 is "longer than 4 and ends in a digit") while counting sda1/vda1 as extra disks. On Nitro the disk signal was therefore always 0; on xvd/sd/vd hosts it was always over 100 KB, so idle-stop could never fire. - Choose whole disks by structure: /sys/block lists whole devices only, and of those, the ones with a /sys/block/<dev>/device link are backed by hardware (loop, ram, zram, dm-*, md* are not). Shared by the idle check and the Prometheus disk metric. - diskIOBytes returns (delta, measured, why) with a diskSampled bool, in the networkBytes style from #919: first sample, unreadable counters and backwards counters are unknown, which means assume active, and an unreadable counter is warned about once. - Windows: a missing _Total perf instance is unknown, not a measured 0. The darwin stub reports unknown. - spored status gains a Disk I/O line that prints "unknown (why)" when nothing was measured, plus disk_bytes_per_min / disk_measured / disk_unknown in the JSON. - Audit: cpuUsage now treats counters that go backwards as unknown (it could produce a negative usage, which reads as idle). - Removed three monitoring_test.go tests that re-implemented the old filter inline and asserted its behaviour, including skipping nvme0n1. Filed from the audit: #952 (metrics scrape shares sample state), #953 (presence-only PTY/last checks), #954 (GPU unknown reads as 0). (#937)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 #937. Stacked on #936 (fix/919), so merge that first. The base is
fix/919and the diff shows only #937.What was wrong
The idle disk check compared the since-boot I/O total with a "100KB/min" threshold. Its name filter also dropped every NVMe disk and counted
sda1/vda1as extra disks. So on Nitro the disk signal was always 0, and on xvd/sd/vd hosts it was always over the threshold, which meant idle-stop could never fire there.What changed
pkg/agent/diskstats.go, untagged so it is tested on every platform). A device counts if it is in/sys/block, which lists only whole devices since partitions sit under their disk, and has a/sys/block/<dev>/devicelink. That link is absent on loop, ram, zram, dm-* and md*. The idle check and the Prometheus disk metric both use this.diskIOBytes() (bytes, measured, why)with adiskSampledbool, written likenetworkBytesin Count physical NICs by structure so idle-stop can fire on enp*s* hosts (#919) #936. The first sample, an unreadable counter and a counter that went backwards are all unknown. Unknown is treated as active (the conservative direction), shown as unknown in status, and warned about once.DiskBytesPersecin the raw class is a cumulative counter, so the new delta logic handles it. A missing_Totalinstance now returns unknown, where before[int64]$nullgave a measured 0. The darwin stub returns unknown.Disk I/O:line printsunknown (<why>; assuming active)rather than the placeholder. The JSON gainsdisk_bytes_per_min,disk_measuredanddisk_unknown.cpuUsagenow treats counters that went backwards (deltaTotal<0, deltaIdle<0, or deltaIdle>deltaTotal) as unknown. Before, they produced readings of 50%, 150% or -200%, and the negative one reads as idle.monitoring_test.go. They re-implemented the old filter inline and asserted what it did, including "nvme0n1 skipped", so they certified the bug (rule 5).Tests and the revert check (rule 1)
Fixtures cover a
/proc/diskstatsand a kernel-shaped/sys/block(symlinks into/sys/devices, partitions as subdirectories, adevicelink only on hardware disks) for nvme0n1+p1+p128, nvme0n1+nvme1n1, xvda+xvda1, sda+sda1 and vda+vda1, plus noise from loop0/loop1/dm-0/md0/zram0. There are also tests for the first sample, the delta, a zero counter, a backwards counter and unknown with a single warning.Before each check I confirmed that every revert compiles (
go vetclean), then watched the test fail:CountsWholeDisksByStructure: nvme0n1, nvme0n1+nvme1n1, sda, vdaIsADeltaAfterAFirstSample,BackwardsCounterIsUnknownIsADeltaAfterAFirstSampleprev != 0as the first-sample test (the #919 shape)ZeroCounterIsNotAPermanentFirstSampleBackwardsCounterIsUnknownUnknownIsAssumedActiveAndWarnedOnceUnknownIsAssumedActiveAndWarnedOnceDiskAssumedActiveIsOverTheIdleThresholdCPUUsage_BackwardsCountersAreUnknown(all 3 cases)StatusTable_UnmeasuredDiskIsNotPrintedAsAValueStatusReport_OneShotDiskIsUnknownWithAReasonmake checkpasses except for the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, because no Docker daemon is running.make check-nestedpasses: all 9 nested modules are clean.Caveats
/sys/blocklayout in the fixtures comes from how the kernel lays out sysfs, not from a capture. The Windows change is not exercised by any test.nvme0c0n1path devices could appear and be counted next to the head node. EBS and instance-store controllers are single-controller, so this should not happen on EC2, but I have not verified it.spawn_disk_io_bytes_totaldevicelabel changes, for example tonvme0n1ornvme0n1,nvme1n1, so existing series change label. This is noted in the CHANGELOG.Filed from the idle-signal audit
IsIdle()/getCPUUsage()and shares the sample fields with the monitor loop. This is a data race, and a scrape can shrink the loop's delta window enough to cause a false idle-stop./dev/ptsentry or still-open login blocks idle-stop forever, which defeats the idle-time logic incountActiveSessions. There is also a possiblewcolumn-layout issue.nvidia-smifails, the GPU reads as 0% (idle), and Neuron/Gaudi/AMD accelerators are never measured.