Repository navigation
fix(agent): resolve the persistent label before copying the install logs - #4687
Conversation
CopyLogs handed /dev/disk/by-label/COS_PERSISTENT straight to mount(2). On an encrypted install that path is ambiguous: the raw crypto_LUKS container and its unlocked mapper both advertise the label, so udev's last writer decides where the symlink points. The hook runs immediately after Encrypt, while the mapper is still open, so it hits the ambiguous window every time. When the symlink lands on the raw side the mount fails, the hook warns and returns nil, and the install and reset logs are dropped on exactly the nodes where they are hardest to reproduce. Resolve the label through lookup.MountSourceForLabel, which returns the mapper for a LUKS-wrapped partition and the plain partition otherwise. The line above already mounted OEM through the fixed machine.Mount helper, so this call site was simply missed when kairos-io#4403 swept the rest. Fixes kairos-io#4685 Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
|
Picking this up for QA. |
QA Result: PASS
What was tested
Summary: the fix does what it claims. With both devices carrying QA performed by an AI agent, unattended. No human has reviewed this run. |
Fixes #4685
CopyLogshanded/dev/disk/by-label/COS_PERSISTENTstraight tomount(2):On an encrypted install that path is ambiguous. The raw
crypto_LUKScontainer and its unlocked mapper both advertiseCOS_PERSISTENT, so the symlink points at whichever device udev settled last. The hook runs fromFinishimmediately afterEncrypt, while the mapper is still open, so it sits in that window every time. When the symlink lands on the raw side the mount fails, the hook warns and returns nil, and the install and reset logs are silently dropped on exactly the nodes that are hardest to debug after the fact.This is the same defect #4403 fixed for immucore's mount step and for
machine.Mount. The line right above this one already mounts OEM through the fixed helper, so this call site was just missed in that sweep.The fix routes the label through
lookup.MountSourceForLabel, which returns the mapper path for a LUKS-wrapped partition and the plain partition path otherwise.c.Syscall.Mountis kept so the hook stays mockable.Three specs in
logs_test.godrive the real hook against aGhwMockdisk. All three fail onmaster:vda5=crypto_LUKScarrying the label) must mount/dev/mapper/vda5, never the by-label path/dev/vda5, never the by-label pathCOS_PERSISTENTat all must warn and return nil, never mount the by-label pathThat last one is worth calling out: today the hook mounts the by-label path unconditionally, so on a machine where the label does not resolve it was relying on
mount(2)to fail rather than checking.The two hardening suggestions in the issue are not in scope here. The
requested <= currentgrow error comes from yip'slayoutplugin, not this repo. Hard-failing the boot when/usr/localdoes not mount is a behaviour change that wants a maintainer call.