Repository navigation
fix(spored): stop reporting CPU and stopped-time assumptions as measurements (#734, #735) - #746
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…rements Three states collapsed into one float, two of them sentinels a caller could not distinguish from data: /proc/stat unreadable -> 100.0 "assume active" no previous sample -> 100.0 "assume active" zero-length sample interval -> 0.0 <- the broken one The last returned the most REASSURING possible value from a no-information state while both siblings returned the most conservative one. `spored status` hits all of it in one process: it reads CPU once via IsIdle and again for the report, microseconds apart, against a function that overwrites its own previous sample. Hence `Not idle: CPU usage 100.00%` beside `CPU: 0.0%` — same instance, same breath, neither a measurement. - cpuUsage returns (value, measured). An unknown reading is the conservative 100%, consistently with its siblings and with getNetworkBytes. - buildStatusReport samples ONCE, after IsIdle, and reuses it. - The table prints "unknown (single sample; assuming active)" rather than a number; JSON gains cpu_measured so a consumer cannot plot an assumption. - isIdle logs which kind of reading it had, so the two numbers in one status output can no longer look like a contradiction. That branch also feeds the idle decision, so the one place returning "0% busy" from no information was the one that could let --idle-timeout stop a busy instance. The daemon's ticker spaces calls far enough apart that it was not reachable in practice — but one call site away from stopping a working box is not worth keeping. a residue — elapsed-since-launch minus compute-since-spored-started — so it absorbed boot, cloud-init and package installs and asserted `2m 13s stopped` on an instance that was never stopped. Boot time is now measured, not inferred: spored knows both the launch time and its own start. It is reported as its own term, so a slow boot is visible. Stopped time appears only with real evidence of a stop — compute carried over from a prior run through the tag (HasPriorComputeTime) — so a first boot shows "(20m 0s compute · 2m 13s boot)". sysReadCPUTimes is now reached through a package var. It is build-tagged and the darwin implementation always errors, so on the platform most development happens on every branch of the delta logic except the first was unreachable — #734 could not be reproduced locally at all before this. Gates confirmed to fail on revert: a measured 0.0 from a zero delta, the raw residue as stopped time, and printing an unmeasured sentinel as a reading. One test of mine initially failed for its own reason: the status fixture's agent is created at test time, so compute rounds to zero and the pre-existing `computeTime > 0` guard suppresses the whole breakdown. That guard is fine; the test now sets the reported shape explicitly.
scttfrdmn
force-pushed
the
fix/734-735-status-report
branch
from
October 8, 2026 03:50
8b33c3e to
0a2be04
Compare
scttfrdmn
added a commit
that referenced
this pull request
Nov 15, 2026
#746) (#1645) Co-authored-by: spore-host release <[email protected]>
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.
Closes #734. Closes #735. Both are in
spored status's report, and both are thesame defect in different clothes: a value that cannot be known rendered as a
value that is known.
#734 —
CPU: 0.0%on an instance running at 100%Three states collapsed into one float, two of them sentinels a caller could not
tell from data:
/proc/statunreadable100.0100.00.0The last returned the most reassuring possible value from a no-information
state, while both its siblings returned the most conservative one — and
getNetworkBytesdoes the same thing, returning its assume-active value on anunreadable counter. So it was inconsistent with every neighbour.
spored statushits all of it in a single process: it reads CPU once viaIsIdleand again for the report, microseconds apart, against a function thatoverwrites its own previous sample. Hence the reported pair —
Not idle: CPU usage 100.00%besideCPU: 0.0%, same instance, same breath, neither ameasurement.
cpuUsagereturns(value, measured); an unknown reading is the conservative100.0.buildStatusReportsamples once, afterIsIdle, and reuses it. Theordering is now deliberate and commented, since
IsIdleconsumes a sample.unknown (single sample; assuming active)rather than anumber. For a one-shot
spored statusthat is the common case, not an edgeone — there is no prior sample to delta against.
cpu_measured, so a dashboard cannot plot an assumption.isIdlelogs which kind of reading it had, so the two numbers in one statusoutput can no longer look like a contradiction.
The part that outlives the display: that branch feeds the idle decision, so
the one place returning "0% busy" from no information was the one that could let
--idle-timeoutstop a busy instance. The daemon's ticker spaces calls ≥1sapart, so it was not reachable in practice — which makes it latent, not harmless.
One call site away from stopping a working box is not a property worth keeping,
and it is cheap to fix now.
#735 — boot time reported as stopped time
on an instance that had never been stopped.
stoppedTimewas a residue —elapsed-since-launch minus compute-since-spored-started — so it absorbed boot,
cloud-init and package installs, and asserted a specific, checkable fact from
arithmetic that cannot distinguish being stopped from never having started.
Boot time is now measured, not inferred: spored knows both the instance
launch time and its own start, so
bootTime = sporedStart - launchTimeisdirectly computable. It is reported as its own term, which is worth having —
a slow boot is a real thing to notice. Stopped time appears only when there is
evidence of a stop: compute time carried over from a previous run through the tag
(
HasPriorComputeTime), which is non-zero only after a genuine stop/start. Afirst boot now shows
(20m 0s compute · 2m 13s boot)and claims nothing itcannot support.
A testability fix that was load-bearing
sysReadCPUTimesis now reached through a package var. It is build-tagged, andthe darwin implementation always returns
errBadProcStat— so on the platformmost development happens on, every branch of the delta logic except the first was
unreachable, and #734 could not be reproduced locally at all. The issue had to
record that as an open caveat; it no longer is.
Verification
0.0zero elapsed time reported 0% CPU — that is #734: the most reassuring possible value from a no-information state, and it is what feeds isIdleStoppedSeconds = 3600 on an instance that was never stopped — that is boot time mislabelled (#735)an unmeasured sentinel was printed as a readingAlso asserted explicitly: a measured 0% stays distinguishable from an
unknown 0%, which is the entire point of the second return value —
CPU: 0.0%meant both, and on the reported instance it meant the second while lookinglike the first. And that compute+boot+stopped accounts for elapsed, so the
residue is split rather than partly discarded.
One of my own tests failed for its own reason first: the status fixture's agent
is constructed at test time, so compute rounds to zero and the pre-existing
computeTime > 0guard suppresses the whole breakdown. That guard is defensibleand out of scope, so the test now sets the reported shape explicitly rather than
me changing production code to suit a fixture.
gofmt,go vet ./...,go test -short ./...(all green),make check-docs,changelog gate,
semgrep scan --config=auto --error(0 findings).Remaining from the demo notes
#733 (
spawn statusperforms a DNS registration write on every poll) and #736(terminated and shutting-down instances invisible to lookup).