Repository navigation
fix(deploykit): emit a SELF-CONTAINED VM-box disk (flatten the COW overlay) [successor to #320] - #340
Conversation
…erlay) charly vm build produces a copy-on-write qcow2 whose backing file is a host-absolute path under the build cache; a FROM scratch + COPY box carries only the overlay, so on another host (a KubeVirt node's containerd) the backing path is absent and the guest cannot open the disk. EmitVmBoxAt now detects a backing file (qemu-img info) and flattens it (qemu-img convert -O qcow2) into the build context, so the COPY is the whole artifact. R7: vm_box_flatten_test.go builds a real base+overlay and fails without the fix.
Round-1 finding B18/R4: isQcow2Overlay returned a bare bool and treated an unreadable image as 'not an overlay' (fail-OPEN), reaching the plain COPY path with an unflattened COW disk whose host-absolute backing file is absent on any other host — the exact CrashLoop this PR fixes. It now returns (bool, error); EmitVmBoxAt propagates the error instead of wrapping an unflattened overlay. Tests updated for the new signature + a new TestIsQcow2Overlay_UnreadableErrorsClosed proves the fail-closed path; TestIsQcow2Overlay_NonImageIsRawWholeDisk documents that a readable raw disk (qemu-img exit 0) still falls through correctly. GOWORK=off go build ./... ; GOWORK=off go test ./deploykit/... -> ok Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)
…tained and non-zero (B18) Round-2 finding 4: the flatten target lives inside the build context; the diff alone cannot show the downstream COPY is not a self-copy that truncates the disk. This LIVE test calls EmitVmBoxAt on a real COW overlay with the real podman engine, extracts the disk the emitted box carries, and asserts it is non-zero-length AND carries no backing file. It proves the emitter neither collides nor dead-stores. Live-or-skip: skips cleanly without qemu-img/podman. Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)
|
STATUS Operator direction on file (break A) — this producer lands bed-exempted for the cycle. This fix is the direct cause of Per the operator's chosen break (applied identically to This comment is the sign-off of record for Agent: |
Review — BLOCKHead SHA: Change class: SDK Go ( Blocks
Comment 5971758003 (@aitrawog): Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — PASSHead SHA: Security screen: PASS — T1/T2 clean (no embedded directives, no rulebook/validator edits); T3 no secrets/egress/obfuscation/weakened guardrail; the added Checklist: All applicable rules PASS or NA.
Comment dispositions:
Note (non-blocking, B15): three non-changelog commits will collapse on squash — no partial/split/Phase-2 work pattern is present in the diff or commit set. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…g qemu-img CI's `go` check failed on the prior head: the fail-closed isQcow2Overlay shelled out to qemu-img for EVERY disk, so on a host/CI without qemu-img it errored on the pre-existing non-qcow2 fixture disks (TestVmBoxEmitReadBackRoundTrip, TestEmitVmBoxAtContainerDiskPathLive). Read the qcow2 magic first: a non-qcow2 artifact (a raw whole-disk image, or a fixture) is not a COW overlay and needs no tool — the caller copies it as-is. Only a real qcow2 image consults qemu-img, and an unreadable one still fails CLOSED (never a silent false that would wrap an unflattened host-coupled overlay). TestIsQcow2Overlay_NonImageIsRawWholeDisk / _UnreadableErrorsClosed now run WITHOUT qemu-img (the open failure precedes any tool). Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)
Review — PASSHead SHA: Security screen: PASS — T1/T2 clean (no embedded directives, no rulebook/validator edits); T3 no secrets/egress/obfuscation/weakened guardrail ( Comments:
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
golangci-lint errcheck required it. Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)
Review — PASSHead SHA: Change class: SDK Go ( Security screen: PASS — T1/T2 clean (no embedded directives; no rulebook/validator edits); T3 scope matches the body exactly (only Checklist: All applicable rules PASS or NA.
Comment dispositions:
Note (non-blocking, B15): the five non-changelog commits collapse on squash — no partial/split/Phase-2 work pattern is present. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — BLOCKHead SHA: Change class: SDK Go ( Blocks
Comment dispositions
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — BLOCKHead SHA: Change class: SDK Go ( Blocks
Comment dispositions
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
The read error was lumped: only io.EOF / io.ErrUnexpectedEOF (a genuine short read — a file too small to hold an image header) means "not an overlay". Every OTHER read error (EISDIR from an os.Open'd directory, EIO, …) is a genuinely unreadable disk and must fail CLOSED, never a silent false — the exact path this change exists to guard. Branch on the error; the inline comment no longer claims an unreadable file "already errored above" (only an UNOPENABLE one does). TestIsQcow2Overlay_UnreadableErrorsClosed now also passes a DIRECTORY (open succeeds on Linux; the EISDIR surfaces at the read), which the open-only case could not reach. Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)
Review — PASSHead SHA: Security screen: PASS — T1/T2 clean (no embedded directives; no rulebook/validator edits); T3 scope matches the body exactly ( Checklist: All applicable rules PASS or NA.
Comment dispositions:
Note (non-blocking): the body's aside "the earlier tip Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
charly vm buildproduces a copy-on-write qcow2 overlay whose backing file is a host-absolute path under the build cache (~/.cache/charly/vm-images/<sha>.qcow2). A VM box is aFROM scratch+ COPY image, so it carries only the overlay — on any other host (a KubeVirt node's containerd) the backing file is absent and the guest cannot open the disk. This is exactly what leftcharly#730'scheck-kubevirt-vmVMI stuck un-Ready.Fix: flatten the overlay into a standalone qcow2 (
qemu-img convert) before wrapping it into the box/containerDisk, so the COPY is the whole artifact.isQcow2Overlayfails CLOSED on an unreadable image (never a silent false), so a failedqemu-img infocannot wrap an unflattened overlay whose backing is missing on every other host.This is the successor of the auto-closed
opencharly/sdk#320, carried forward on the operator's break A (the same cycle break asplugin-kubevirt#4→#10,plugin-vm#61→#67).Head
622ca75(branchfeat/kubevirt-vm-box-flatten-3) — the tip is a fix commit on top of amain-into-branch merge (cd0983c); the earlier tip35fdf8awas rebased. Every finding from the prior verdicts is fixed in this head.Supersedes
opencharly/sdk#320— the same change rebased, all findings addressed.Every diff item, accounted for
deploykit/vm_box_emit.goEmitVmBoxAtnow inspects the disk (isQcow2Overlay); if it is a COW overlay itflattenQcow2s it into a standalone qcow2 and COPYs that.isQcow2Overlayreads the qcow2 magic first — a non-qcow2 artifact (a raw whole-disk image, or a fixture) is not an overlay and needs noqemu-img, so a host/CI withoutqemu-imgstill emits a raw disk; only a real qcow2 image consultsqemu-img. It fails closed: onlyio.EOF/io.ErrUnexpectedEOF(a genuine short read) means "not an overlay"; every OTHER read error (e.g.EISDIR) is a genuinely unreadable disk and is returned as an error, never a silent false.deploykit/vm_box_emit_e2e_test.goTestEmitVmBoxAt_OverlayIsFlattenedIntoSelfContainedBox: a live end-to-end proof (real COW overlay → real container engine →EmitVmBoxAtatVmBoxDiskPath→podman cpthe emitted disk out → assert it has no backing file and is non-zero).deploykit/vm_box_flatten_test.goTestIsQcow2Overlay_DetectsBackingFile(an overlay is detected),TestIsQcow2Overlay_NonImageIsRawWholeDisk(a raw/whole-disk image is not an overlay → falls through to the plain COPY),TestIsQcow2Overlay_UnreadableErrorsClosed(an unopenable path AND anos.Open'd directory — the EISDIR read error — both error, never a silent false) — the latter two run withoutqemu-img.How tested
Change class: SDK Go (
deploykit/vm_box_emit.go— the VM-box emit path) + R7 tests. No charly-core change.The three
...IsQcow2Overlay...tests andTestEmitVmBoxAt_OverlayIsFlattenedIntoSelfContainedBoxare exactly the tests this diff adds; the broader./deploykit/...suite (including the pre-existingTestEmitVmBoxAtRejectsRelativePath/TestEmitVmBoxAtRejectsUnsafePath/TestEmitVmBoxAtContainerDiskPathLive) also passes.TestEmitVmBoxAt_OverlayIsFlattenedIntoSelfContainedBoxis the behavioral guard: it builds an overlay, emits a box, and asserts the emitted disk has no backing file — it fails without the flatten (the overlay's backing path would persist).The R10 bed — the cycle, and break A
The bed this change unblocks is
charly#730'scheck-kubevirt-vm— the exact place the unflattened overlay surfaced (prepare-venue: timeout waiting for VirtualMachineInstance … Ready). Per the operator's break A: this producer lands bed-exempted for the cycle;#730then pins the mergedsdktag (charly'sgo.modsdk/spec) and runs the fresh-rebuild bed. Live proof retained now: the bed run oncharly#730's branch reached deliver → VMI boot and failed only on the unflattened backing; a charly rebuilt against this fix is the direct confirmation (pasted in#730).Rulebook compliance
/charly-internals:plugin(the SDK kit surface) +/charly-internals:git-workflowloaded.FROM scratchbox; the node cannot open it.flattenQcow2/isQcow2Overlaypair owns the behaviour.GOWORK=off; the module resolves from its owngo.mod.check-kubevirt-vmbed ridescharly#730(operator break A).Change classification
deploykit/vm_box_emit.go) + R7 tests.analysed on a live system.Authoring-runtime evidence (A3):
Carried forward from / supersedes
opencharly/sdk#320. Unblocksopencharly/charly#730'scheck-kubevirt-vmbed.Agent:
umbrella-catchup· sessionses_f01e6144bffesN8qO8MaOSEPGdAssisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)