fix(vm): tolerate missing hotplug image during attach (revert #2574)#2582
Merged
Conversation
During a VMBDA hotplug attach KubeVirt adds the volume to KVVM before the image appears in the VM block device refs, so viByName/cviByName do not contain it yet. setVMBDABlockDeviceDisk then hit the hard "image should exist in the cluster" error and aborted the whole reconcile. Skip the VirtualImage/ClusterVirtualImage disk when the image is not in the maps yet: the volume is already present and options are applied on a later reconcile. This mirrors the already-tolerant VirtualDisk branch. Skip instead of removeDisk — an attached image is finalizer-protected, so a missing entry means the status lagged, not that the image is gone. Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
universal-itengineer
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Reverts #2574 and fixes the same issue with a smaller, builder-only change.
While an image is being hotplugged via VMBDA, KubeVirt adds the volume to KVVM before the
device shows up in the VM
.status.blockDeviceRefs. In that window the builder maps(
viByName/cviByName) do not contain the image yet, andsetVMBDABlockDeviceDiskfailedthe whole reconcile with
... image "<name>" should exist in the cluster; please recreate it.Fix: in the VirtualImage/ClusterVirtualImage branches, skip the disk when the image is not
in the maps yet — the volume is already present and options are applied on a later reconcile.
This mirrors the already-tolerant VirtualDisk branch. Skip (not
removeDisk): an attachedimage is finalizer-protected, so a missing entry means the status lagged, not that the image
is gone.
Why this instead of #2574: #2574 pre-fetched VMBDA-referenced objects into the builder maps
(~120 lines + extra API Gets per reconcile) and relied on the block device status handler
reading the maps only by spec-ref name. This achieves the same result with two guards in the
one function that actually errors — no new API calls, no new coupling.
Why do we need it, and what problem does it solve?
The image exists and is
Ready, but the reconcile still errors during the attach window. Itself-heals, yet spams
errorlogs and causes requeue/backoff churn (and e2e flakiness). Thisremoves those false failures. Attach speed is unchanged.
What is the expected result?
Hotplug an image (VI/CVI) to a running VM: no more
image "<name>" should exist in the clustererrors during the attach; the VMBDA reaches
Attachedand the VM status converges cleanly.Checklist
Changelog entries