fix(fleet): the who recipe reported nobody on a machine full of users - #21
Merged
Conversation
`who || w` was wrong, and wrong in a way that reads as correct. `who` reads utmp, which on a systemd host with pty-less SSH sessions is routinely empty while people are very much logged in — and it exits 0 either way. So `||` never reached `w`, and the recipe returned nothing at all. Confirmed here: `who` prints zero lines and exits 0, while `w` lists two live sessions on the same box. The failure mode is empty output, not a non-zero exit, and `||` cannot see the difference. The recipe now falls back on emptiness, and says "no interactive logins on this host" when both agree there are none — because a status command that prints nothing is indistinguishable from a broken one, which is exactly how this got reported. Audited the other four reporting recipes through the real fleet path against a live host first, to check the reporter's hunch that output had gone missing more widely: check-updates 8 lines, disk 6, uptime 1, reboot-required 1. Only `who` was silent, so nothing in the streaming path is dropping anything. Adds a test that no reporting recipe may produce empty output, which is the invariant that was actually broken, plus two asserting `who` branches on emptiness rather than on exit status. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeSWg1Czsb2Lwxj8vHUnA4
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.
who || wwas wrong, and wrong in a way that reads as correct.whoreads utmp, which on a systemd host with pty-less SSH sessions is routinely empty while people are very much logged in — and it exits0either way. So||never reachedw, and the recipe returned nothing at all.Confirmed on a live host:
The failure mode is empty output, not a non-zero exit, and
||cannot see the difference.Fix
Fall back on emptiness rather than on exit status, and say so when there genuinely is nobody:
That last branch matters. A status command that prints nothing is indistinguishable from a broken one — which is exactly how this got reported.
The wider hunch, checked
The report suspected output had gone missing for other built-ins too. It hasn't — I ran all five reporting recipes through the real fleet path against a live host before touching anything:
So nothing in the streaming path is dropping anything;
whowas the only silent one. Worth saying plainly rather than "fixed it".Tests
Adds the invariant that was actually broken — no reporting recipe may produce empty output — plus two asserting
whobranches on emptiness rather than exit status. 498 tests, up from 491.🤖 Generated with Claude Code
https://claude.ai/code/session_01UeSWg1Czsb2Lwxj8vHUnA4