Repository navigation
fix(install): open the target disk with a path-recording backend - #5135
Conversation
go-diskfs falls back to per-partition BLKPG reconciliation when BLKRRPART cannot make the kernel re-read the partition table, which is the common case right after writing a table because the write triggers a udev re-probe. That fallback reads Backend.Path() first and gives up when it is empty. NewDisk opened the target with diskfs.Open, which builds its backend with file.New. file.New does not record the path, so Backend.Path() was always empty under Kairos and the fallback could never run: every busy device turned into a fatal "kernel re-read deferred" and failed the install. Build the backend with file.OpenFromPathWithExclusive instead, which records the path and keeps the same O_RDWR|O_EXCL flags diskfs.Open defaulted to. Fixes kairos-io#5134 Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
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.
Approving. file.OpenFromPathWithExclusive(device, false, true) opens with the same O_RDWR|O_EXCL as diskfs.Open, goes through the same initDisk path in OpenBackend, and now records the path that the BLKPG fallback reads first. NewDisk has one production caller (elemental.go), and the ISO extractor's diskfs.Open is read-only and untouched.
I ran go test ./agent/pkg/partitioner/... on master (4433f215) merged with this PR and it passes. The 2026-10-13 red unit-tests / test failed in kairos-init/pkg/validation, which this PR does not touch, and the rerun on the same head passed.
QA in progress: I'm testing this now. Results and proof will follow here. |
QA: pass at 7a74c87 (unit tests on the merge with master, no VM), details and proof: #5134 (comment) |
The earlier |
QA: pass at |
Fixes #5134
Summary
agent/pkg/partitioner.NewDiskopened the install target withdiskfs.Open, which builds its backend withfile.New.file.New's own doc comment says it "will not store any path", soBackend.Path()was always empty under Kairos.go-diskfs needs that path. When
BLKRRPARTcannot make the kernel re-read the table, it falls back to per-partitionBLKPGreconciliation (whatpartxdoes), and that fallback readsBackend.Path()on its first line and gives up withbackend has no path; cannot reconcile partitionswhen it is empty. So the fallback could never run here, and every busy device turned into a fatalpartition table written to disk but kernel re-read deferredand failed the install. The write itself provokes the busy condition, because it triggers a udev re-probe.This is what reddens
test-core-rocky-9 / selinuxon master, most recently in run 37016179742.The fix builds the backend with
file.OpenFromPathWithExclusive(device, false, true), which records the path and keeps exactly theO_RDWR|O_EXCLflagsdiskfs.Opendefaulted to, and hands it todiskfs.OpenBackend.Separate from #4632, which fixes the other defect in the same code path: that the re-read retry loop's result is discarded by an unconditional extra call. Both are needed. With #4632 alone the five retries would still each hit
EBUSYwith the fallback disabled.How it was tested
TestNewDiskBackendRecordsPathpinsBackend.Path(), the exact value theBLKPGfallback reads, and then partitions the disk to confirm the open is still read-write.Red on master:
Green with the change, along with the rest of the package and its caller:
The install path itself needs a real block device, so the
BLKPGfallback firing end to end is only provable in the e2e jobs on this PR.AI was used to write this change. No human has read it yet.
🤖 Generated with Claude Code