usb-ready: wait for a queued unit, not just a running one - #148
Merged
Merged
Conversation
ConditionResult is "no" both for a unit systemd has skipped and for one it has not evaluated yet, so the fallback written for the skipped case also fired in the window before ssh-keygen-boot started. Reflash took that as permission to mount, and mounted /dev/sda2 while expand-usb's mkfs was still running inside that unit: "bad superblock", storage FAILED, no host keys, no sshd. The board served HTTP fine and looked, from outside, like a board that would not boot. The Job property is what separates the two. Measured on systemd 257 (the board's own) and 237: case ActiveState ConditionResult Job skipped by its condition inactive no (empty) queued, not started yet inactive no 12561 ExecStart running activating yes 12561 finished active yes (empty) Everything else is identical in the first two rows, including ConditionTimestamp and ExecMainStartTimestamp, which are 0 for both - so the discriminator this needed was never in the properties it was reading. The existing test for this window stubbed ConditionResult as "yes", which is not what systemd reports there, so it passed while the real case failed. It now stubs what a board actually reports, and fails against the old script. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The helper's job is to imitate systemd, and the last version of it was written from what seemed reasonable rather than from what a board says: it stubbed ConditionResult=yes for a unit that had not started, where systemd says "no". The test passed, the real case failed, and #147 went unnoticed until a board came up without sshd. The table is measured, with the probe's shape and the systemd versions it was taken on, so the next stub can be written from it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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 #147.
ConditionResultisnoboth for a unit systemd has skipped and for one ithas not evaluated yet, so
usb-ready's fallback for the skipped case alsofired in the window before
ssh-keygen-bootstarted. Reflash mounted/dev/sda2whileexpand-usb'smkfswas still running inside that unit, themount failed with
bad superblock, storage was marked FAILED and no host keyswere written - so the board came up serving HTTP with no sshd.
Jobis the property that separates them. Measured on the board's own systemd257, and on 237:
inactivenoinactiveno12561activatingyes12561activeyesConditionTimestampandExecMainStartTimestampare0for both of the firsttwo rows, so the discriminator was not among the properties being read.
On the test
The existing case for this window stubbed
ConditionResultasyes, which isnot what systemd reports there - so it passed while the real thing failed. It
now stubs what a board reports (
inactive/no/ a job id), and failsagainst the old script, which is how I checked it reproduces the bug:
make test-batsis otherwise unchanged and green.Not covered here
Whether a stick left half-formatted by this race repairs itself on the next
boot, or stays broken because
expand-usbearly-exits on[ -b /dev/sda2 ].That is the same "partition exists, filesystem does not" state seen on a6, and
it deserves its own fix.