Repository navigation
fix: service: a failed journal read is not an empty log - #2011
Conversation
parse_recent_log's Systemd arm answered Some regardless of the command's exit, so a journalctl that could not run - journald missing from the image, "System has not been booted with systemd", a user-scope bus that will not connect - reported the unit's log as empty and available. The Procd arm has guarded exactly this: a failed command with an empty stdout is None, the machine's "no log to ask for by unit", not the unit's "wrote nothing". Same rule for Systemd now. A partial listing printed before a failure still parses, and a zero exit with the permission hint on stderr still reads as unreadable rather than empty-quiet.
|
I have read the CLA Document and I hereby sign the CLA |
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
…and test the log against a real systemd machine
What this changes
parse_recent_log's Systemd arm answeredSome(parse_journal(...))regardless of the command's exit, so ajournalctlthat could not run reported the unit's log as empty andavailable: true. The failure paths are ordinary: a minimal image or container without journald, "System has not been booted with systemd", a user-scopejournalctl --userthat cannot reach its bus — all exit non-zero with an empty stdout and the real error on stderr. What the caller then shows is "this unit has never written a log", which is the one thing those failures did not say.The Procd arm has guarded exactly this since the sbm_parser move (#1645):
!succeeded && stdout emptyisNone— the machine's "no log to ask for by unit", per the function's own doc comment — not the unit's "wrote nothing". This gives the Systemd arm the same rule.What the new arm deliberately leaves alone:
Some) — what the command did print is a log, whatever its exit said. Covered by a test case.Some— including the permission-hint path (insufficient permissionson stderr →unreadable: true), which exits zero and is untouched. Covered too.How it was tested
cargo test -p sbm_parser --test service_compat— 18 passed, including the newa_journal_read_that_failed_is_not_an_empty_log(four branches: failed → None, partial-then-failed → parses, exit-zero-empty →unreadable, Procd failed → None unchanged).cargo clippy -p sbm_parserclean.Note: the two pre-existing
monitor_agent::tests::the_*_is_valid_shellfailures undercargo test -p sbm_parser --libfail identically on unmodifiedmainon this Windows machine — environment, not this change.No Dart, no ARB, no
monitor/change.Summary by CodeRabbit