From 0c61faa5f9fd54486ad6930e4898624a666871bd Mon Sep 17 00:00:00 2001 From: Yaroslav Borbat Date: Wed, 15 Oct 2025 14:40:21 +0300 Subject: [PATCH] check containerDisk Signed-off-by: Yaroslav Borbat --- .../controller/service/attachment_service.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/images/virtualization-artifact/pkg/controller/service/attachment_service.go b/images/virtualization-artifact/pkg/controller/service/attachment_service.go index 6fda25d52c..03bce5f028 100644 --- a/images/virtualization-artifact/pkg/controller/service/attachment_service.go +++ b/images/virtualization-artifact/pkg/controller/service/attachment_service.go @@ -104,12 +104,17 @@ func (s AttachmentService) CanHotPlug(ad *AttachmentDisk, vm *v1alpha2.VirtualMa if kvvm.Spec.Template != nil { for _, vs := range kvvm.Spec.Template.Spec.Volumes { if vs.Name == name { - if vs.PersistentVolumeClaim == nil { - return false, fmt.Errorf("kvvm %s/%s spec volume %s does not have a pvc reference", kvvm.Namespace, kvvm.Name, vs.Name) - } - - if !vs.PersistentVolumeClaim.Hotpluggable { - return false, fmt.Errorf("%w: virtual machine has a block device reference, but it is not a hot-plugged volume", ErrBlockDeviceIsSpecAttached) + switch { + case vs.PersistentVolumeClaim != nil: + if !vs.PersistentVolumeClaim.Hotpluggable { + return false, fmt.Errorf("%w: virtual machine has a block device reference, but it is not a hot-plugged volume", ErrBlockDeviceIsSpecAttached) + } + case vs.ContainerDisk != nil: + if !vs.ContainerDisk.Hotpluggable { + return false, fmt.Errorf("%w: virtual machine has a block device reference, but it is not a hot-plugged volume", ErrBlockDeviceIsSpecAttached) + } + default: + return false, fmt.Errorf("kvvm %s/%s spec volume %s does not have a pvc or container disk reference", kvvm.Namespace, kvvm.Name, vs.Name) } return false, ErrHotPlugRequestAlreadySent