Repository navigation
fix(agent): let upgrade run on a machine with no recovery partition - #4821
Conversation
NewUpgradeSpec leaves Partitions.Recovery nil when the machine has no COS_RECOVERY, and Sanitize only requires it for a recovery upgrade. Run mounted it unconditionally, so a plain upgrade on such a machine panicked with a nil pointer dereference inside MountPartition instead of upgrading. A system upgrade never writes to the recovery partition: it is read only in the RecoveryUpgrade branch that picks the final image file. Skip the mount when it is absent, the way OEM, persistent and EFI are already skipped in this file. Fixes kairos-io#4820 Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
Picking this up for review โ checking the nil-partition fix against the upgrade code paths it touches and the accompanying test. |
itxaka-agent
left a comment
There was a problem hiding this comment.
Automated triage agent (
kairos-triage-agent) running as@itxaka-agent.
This comment was generated by software. A human maintainer can override any
action taken here.
Round 0: approve. The nil-recovery-partition panic in #4820 is real โ MountRWPartition discards the "nil partition" error IsMounted returns, so the nil reaches MountPartition's dereference. The fix matches how OEM, persistent, and EFI are already skipped when absent elsewhere in this file, and the flipped test panics on master and passes with the fix.
Two things worth a maintainer's glance before merge, not blockers: the commit's Signed-off-by (Ettore Di Giacinto) doesn't match the PR account (ci-robbot), and the PR body has no AI-use disclosure per the repo's AGENTS.md.
Audit summary โ round 0: approve. Full review: #4821 (review) |
Fixes #4820
kairos-agent upgradepanicked with a nil pointer dereference on any machine without aCOS_RECOVERYpartition.NewUpgradeSpecleavesPartitions.Recoverynil when neither the ghw partition list nor the device-mapper lookup finds it, andUpgradeSpec.Sanitizerequires it only for a--recoveryupgrade.Runthen mounted it unconditionally, andMountRWPartitiondiscards the "nil partition" errorIsMountedreturns, so the nil reachedMountPartitionand was dereferenced.A system upgrade never writes to the recovery partition.
Partitions.Recoveryis read exactly once inupgrade.go, inside theRecoveryUpgrade()branch that picks the final image file. Every other optional partition in the same file already skips when absent: OEM and persistent inupgradeHook, persistent inrecordState, EFI inrefreshESP. This makes recovery behave the same way.Test
New spec in
agent/pkg/action/upgrade_test.go, in the existing "Booting from COS_ACTIVE" context: setspec.Partitions.Recovery = niland upgrade from a docker source, asserting the active image is replaced and the old one is backed up to passive.Checked by mutation: with the fix reverted the spec fails with
runtime error: invalid memory address or nil pointer dereference; with it,1 Passed. The wholeagent/pkg/actionsuite is green.AI disclosure
Written by an AI agent. No human read the code before this pull request was opened.