Skip to content

fix(vm): tolerate missing hotplug image during attach (revert #2574)#2582

Merged
danilrwx merged 2 commits into
mainfrom
fix/hotplug-image-tolerate-missing-v2
Jul 2, 2026
Merged

fix(vm): tolerate missing hotplug image during attach (revert #2574)#2582
danilrwx merged 2 commits into
mainfrom
fix/hotplug-image-tolerate-missing-v2

Conversation

@danilrwx

@danilrwx danilrwx commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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, and setVMBDABlockDeviceDisk failed
the 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 attached
image 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. It
self-heals, yet spams error logs and causes requeue/backoff churn (and e2e flakiness). This
removes 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 cluster
errors during the attach; the VMBDA reaches Attached and the VM status converges cleanly.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: core
type: fix
summary: Do not fail VM reconcile while a hotplug image is being attached via VMBDA.
impact_level: low

danilrwx added 2 commits July 2, 2026 17:18
…2574)"

This reverts commit c25700b.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
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>
@danilrwx danilrwx added this to the v1.10.0 milestone Jul 2, 2026
@danilrwx danilrwx marked this pull request as ready for review July 2, 2026 15:30
@danilrwx danilrwx merged commit 6ca76f5 into main Jul 2, 2026
33 of 36 checks passed
@danilrwx danilrwx deleted the fix/hotplug-image-tolerate-missing-v2 branch July 2, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants