Skip to content

Conversation

hardcoretime
Copy link
Contributor

@hardcoretime hardcoretime commented Oct 7, 2025

Description

  • Use Hotpluggable field for validation
  • Remove deprecated API

Why do we need it, and what problem does it solve?

When a VMBDA with a VirtualImage BlockDeviceRef is deleted, it remains in the Terminating phase because this block device cannot pass the Hotpluggable check.

What is the expected result?

When a VMBDA deletion request is performed, the VMBDA should be deleted.

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: vmbda
type: fix
summary: "The VMBDA with a VirtualImage BlockDeviceRef will now be deleted successfully when requested."

Copy link
Contributor

sourcery-ai bot commented Oct 7, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactor hotplug detection to leverage the new Hotpluggable field and remove deprecated inference APIs, propagate the flag through the KVVM builder, and update tests and dependencies to resolve VMBDA terminating state.

Class diagram for updated BlockDeviceHandler hotplug logic

classDiagram
class BlockDeviceHandler {
  +getBlockDeviceStatusRefs(ctx, s)
  +getBlockDeviceTarget(volume, kvvmiVolumeStatusByName)
  +isHotplugged(volume, kvvmiVolumeStatusByName) bool
  +getBlockDeviceAttachmentName(ctx, kind, bdName, s)
}

class Volume {
  +Name
  +PersistentVolumeClaim
  +ContainerDisk
}

class PersistentVolumeClaim {
  +Hotpluggable: bool
}

class ContainerDiskSource {
  +Image
  +Hotpluggable: bool
}

BlockDeviceHandler --> Volume
Volume --> PersistentVolumeClaim
Volume --> ContainerDiskSource
Loading

Class diagram for KVVM builder changes with Hotpluggable propagation

classDiagram
class KVVM {
  +SetDisk(name, opts)
}

class SetDiskOptions {
  +ContainerDisk: string
  +IsHotplugged: bool
}

class ContainerDiskSource {
  +Image: string
  +Hotpluggable: bool
}

KVVM --> SetDiskOptions
SetDiskOptions --> ContainerDiskSource
Loading

File-Level Changes

Change Details Files
Refactor hotplug validation to use the Hotpluggable field
  • Simplified isHotplugged signature to return a bool and dropped error handling
  • Updated getBlockDeviceStatusRefs to assign ref.Hotplugged directly
  • Replaced legacy checks in ApplyVirtualMachineSpec with volume.ContainerDisk.Hotpluggable
images/virtualization-artifact/pkg/controller/vm/internal/block_device_status.go
images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go
Remove legacy hotplug inference APIs
  • Deleted canBeHotPlugged and its invocations
  • Removed standalone isHotplugged helper in kvbuilder
  • Removed the obsolete kvapi.go file
images/virtualization-artifact/pkg/controller/vm/internal/block_device_status.go
images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go
images/virtualization-artifact/pkg/controller/kvapi/kvapi.go
Propagate Hotpluggable flag in KVVM disk builder
  • Added Hotpluggable field to ContainerDisk spec in SetDisk
  • Adjusted struct initialization to pass opts.IsHotplugged
images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go
Update tests and module dependencies
  • Re-enabled vmbda-vi.yaml entry in e2e test kustomization
  • Bumped kubevirt.io/api replace directive in go.mod
tests/e2e/testdata/vm-restore-force/vm/base/kustomization.yaml
images/virtualization-artifact/go.mod

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hardcoretime hardcoretime added this to the v1.2.0 milestone Oct 7, 2025
@hardcoretime hardcoretime force-pushed the fix/vmbda/fix-terminating-problem branch 2 times, most recently from 29c9560 to f2e57ec Compare October 7, 2025 10:08
@hardcoretime hardcoretime added the e2e/run Run e2e test on cluster of PR author label Oct 7, 2025
@deckhouse-BOaTswain
Copy link
Contributor

deckhouse-BOaTswain commented Oct 7, 2025

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: success.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Oct 7, 2025
@hardcoretime hardcoretime force-pushed the fix/vmbda/fix-terminating-problem branch from f2e57ec to 828b5bc Compare October 10, 2025 15:22
@hardcoretime hardcoretime changed the title fix(vmbda): fix terminating status problem fix(vmbda): resolve terminating status issue Oct 13, 2025
@hardcoretime hardcoretime force-pushed the fix/vmbda/fix-terminating-problem branch from 828b5bc to e3be361 Compare October 13, 2025 10:31
@hardcoretime hardcoretime added the e2e/run Run e2e test on cluster of PR author label Oct 13, 2025
@deckhouse-BOaTswain
Copy link
Contributor

deckhouse-BOaTswain commented Oct 13, 2025

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@hardcoretime hardcoretime marked this pull request as ready for review October 13, 2025 11:15
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Oct 13, 2025
@hardcoretime hardcoretime merged commit 7b79710 into main Oct 13, 2025
81 of 87 checks passed
@hardcoretime hardcoretime deleted the fix/vmbda/fix-terminating-problem branch October 13, 2025 17:23
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.

4 participants