Repository navigation
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… spored can't leak into them (#1090)
This was referenced Oct 18, 2026
Closed
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 #1090.
Problem. Since #952 only the daemon's monitor loop samples the idle counters.
spored statusis a separate one-shot process with its own Agent, so its sample had no earlier one to delta against: CPU, network and disk always readunknown (single sample; assuming active), on every instance at every age. In the v0.131.1 idle test the daemon loggedNot idle: Disk I/O 1204224 bytesevery minute while status could show none of it.Design. Mirrors the compute clock (#896):
pkg/agent/idlestate.go:IdleState(taken, idle, reason, CPU/network/disk readings with measured flags and why, last activity). The monitor loop'scheckAndActpublishes each tick's evaluation viapublishIdleState, right afterevaluateIdle. The write is atomic (temp file and rename) and goes to/run/spored/idle-state.json(tmpfs). It is deliberately not fsynced: a per-minute disk write would itself count against idle (--idle-timeout never fires on an untouched default instance: system background I/O is 10-40x the 100 KB/min disk threshold #1093). Failures are logged once. The path issysIdleStatePath: Linux only; Windows and other platforms return "", as for the compute clock.idleStatePathis a var so tests can use a temp dir.IdleState.Fresh: taken withinIdleStateFreshFor(150 s, two ticks plus margin), not zero, not in the future.cmd/spored:buildStatusReportuses the daemon's fresh state for the readings, the idle decision and idle duration (from its last activity). Otherwise it falls back to the one-shot sample as before.daemonIdleStateis the seam. The report gainsIdleReading {source, age_seconds, reason}in the JSON output, and the table gainsIdle check:with the daemon's verdict and its age, ordaemon reading unavailable; one-shot sample.spawn statuspasses spored's lines through (localizeSporedTimesonly rewrites timestamps), and the new line carries no timestamp.Verification.
TestCheckAndAct_PublishesTheIdleEvaluation,TestIdleState_Fresh,TestIdleState_RoundTrip,TestStatus_ShowsTheDaemonsIdleReadings(table and JSON),TestStatus_DaemonIdleDecisionDrivesTheIdleLineandTestStatus_LabelsTheOneShotFallback.Freshreduced to non-zero → Fresh fails;ok && false) → both daemon status tests fail;pkg/agent,cmd/sporedand thecmdstatus tests pass underbin/hermetic-exec.go vetpasses for linux, windows and darwin.