[1.4] Make host file helpers report failure instead of silently patching - #4242
Conversation
load_file treated a failed cat as an empty file, locate_file never returned None, and save_file ignored a failed upload. A read-only boot partition or a missing file then looked like a successful patch.
…missing revert_update_dwc2 and clean_config_pi3 walked cmdline.txt / config.txt without the None guard the other boot patches already use.
Automated PR Review0. Summary
Makes the shared host-file helpers in 1. Correctness & Implementation Bugs
7. Tests
8. Documentation
Generated by PR Review Bot. This is advisory, a human reviewer must still approve. |
load_file now raises, so a down SSH used to crash wifi can_work instead of selecting NetworkManager the way an empty os-release used to.
On Bullseye, find errors on /boot/firmware/config.txt then still prints /boot/config.txt. A returncode check would drop that path with green tests.
…r patch fails A HostFileError from cgroups aborted the listcomp, so a startup.json rewrite that already returned True never got its reboot.
…eye on read failure load_file now raises when /etc/os-release cannot be read over SSH. Treat that like the old empty string so serial enumeration keeps working.
|
Let's wait for 1.4.4 release. |
Follow-up to #4232. Addresses #4235.
The shared host-file helpers used by
blueos_startup_updatecould not report failure. A failedcatlooked like an empty file (so the next successful write could replaceconfig.txt/cmdline.txtwith only the patch),locate_filenever returnedNone(so the existingis Noneguards never fired), andsave_fileignored a failed upload then returned to a caller that asked for a reboot.What changed
load_fileraisesHostFileErrorwhencatfails. A real empty file (returncode == 0) is still"".locate_filereturnsNonewhenfindprints nothing. It still accepts a match whenfindexits 1 because an earlier candidate was missing (Bullseye:/boot/firmware/config.txtdoes not exist,/boot/config.txtdoes).save_fileraisesHostFileErrorwhen thescpor thesudo mvonto the destination fails. A failed backup is logged and is not treated as success of the write.revert_update_dwc2andclean_config_pi3skip when the boot file was not found, matching the other boot patches.Truestill request a reboot. The previous list comprehension aborted on the firstHostFileError, so astartup.jsonrewrite could lose its restart.get_host_os()returnsHostOs.Otherif the host/etc/os-releasecannot be read, which is what an empty read used to do.load_filestays strict. That keepswifi.can_workfrom taking down the wifi API when SSH is not up yet.A patch that raises no longer returns
True, soBOOT_LOOP_DETECTORis not created for work that did not happen.Test plan
Local: tests in
core/libs/commonwealth/commonwealth/utils/tests/test_commands.pyandtest_general.py. Reverting each of the three helper fixes turns the matching test red.locate_fileis also pinned for find exit 1 with a printed path (Bullseye).get_host_osis pinned toOtherwhenload_fileraises.On hardware, the patched
commands.pywas copied intoblueos-coreon three boards, exercised, then restored. Boot partitions were remounted read-only for the save test and remounted read-write afterwards.config.txt/cmdline.txthashes were unchanged.192.168.0.177)/boot/firmware/boot/firmware/config.txt''→ patchedNoneHostFileErrorHostFileErroronmv, file unchanged192.168.0.124)/boot/firmware/boot/firmware/config.txt''→ patchedNoneHostFileErrorHostFileErroronmv, file unchanged192.168.0.88)/boot/boot/config.txt''→ patchedNoneHostFileErrorHostFileErroronmv, file unchangedOn the read-only boot partition,
scpto/tmpstill succeeds andsudo mvonto the FAT is what fails. That matches the investigation of #4235: the silent every-other-boot reboot is the ignored-scppath; a remounted-RO boot raises (previouslyCalledProcessError, nowHostFileError) and does not reboot. Either way the patches no longer claim success.