Repository navigation
NAS-145202 / 28.0.0-BETA.1 / truenas-appliance-runner: set the appliance's clock after a revert - #29
Merged
Merged
Conversation
loadvm restores the appliance's memory, its clock included, so after a revert the appliance runs minutes behind the runner until it catches up, and it has no NTP to catch up with. A suite's two-factor codes, tokens and timestamps, made on the runner's clock, are then refused or wrong (truenas-connect/cui#79's two-factor spec after a retry). qemu now gives the guest agent a channel (virtio-serial, org.qemu.guest_agent.0 on $DIR/qga.sock); TrueNAS ships qemu-ga, which starts once the port appears. tnctl's set-time syncs the channel with guest-sync, sets the clock with guest-set-time, and checks it took. revert runs it after loadvm and warns, without failing, if it cannot; probe checks the clock after its revert and fails if it is over 5 s off.
On a TrueNAS appliance guest-set-time sets the system clock and then fails: qemu-ga runs /sbin/hwclock to copy it to the hardware clock, and TrueNAS does not ship hwclock. revert warned with the clock 0.4 s off (truenas-connect/cui#82). The hardware clock does not matter here, so the clock check after the call decides, and the call's error is reported only when the clock did not take or the error is about something else. qga() also closes its socket's file: socket.close() leaves the connection open while the file lives, an error's traceback kept it alive, and qemu's chardev serves one client at a time, so the next call hung.
|
No findings. No human review needed. What I checked:
|
Contributor
Contributor
|
This PR has been merged and conversations have been locked. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
truenas-appliance revertdoesloadvm, which restores the appliance's memory, its clock included. After a revert the appliance ran minutes behind the runner, with no NTP to catch up with, so a suite's two-factor codes, tokens and timestamps made on the runner's clock were refused or wrong. truenas-connect/cui#79's two-factor spec hit it on a retry: the right code was refused.Changes
virtio-serial-pciwith avirtserialportnamedorg.qemu.guest_agent.0on$APPLIANCE_DIR/qga.sock. TrueNAS shipsqemu-guest-agent(scale-build'sconf/build.manifest), which starts once the port appears.tnctl.py set-time SOCKET:guest-syncwith a fresh id first (aloadvmrestores the channel's buffers too), thenguest-set-timewith the runner's time, then reads the clock back and fails if it is over 2 s off. Logs how far off it was.guest-set-timesets the system clock and then fails, because qemu-ga runs/sbin/hwclockand TrueNAS does not ship it. The hardware clock does not matter here (loadvmrestores it, the guest reads it only at boot), so the read-back decides.qga()closes its socket's file too: otherwise the connection stays open after an error, and qemu's chardev serves one client at a time.revertrunsset-timeafterloadvm. If it fails, the revert still succeeds, with a::warning::that the clock is behind.probechecks the clock through middleware'ssystem.infoafter its revert, and fails if it is over 5 s off.revert.Testing
python3 test_tnctl.py: 10 tests, four new against a fake guest agent (a stale reply in the channel, the clock set, a guest withouthwclock, a clock that does not take, no agent).e2e.ymlat this branch and rantruenas-appliance probe seededafter the suite (run):This directory changing makes github-truenas-runner build a new appliance image; its
appliance.ymlprobe then checks the clock on every revert.Needs a NAS ticket in the title for the ticket check.