Skip to content

Commit 0c61faa

Browse files
check containerDisk
Signed-off-by: Yaroslav Borbat <[email protected]>
1 parent c6003e7 commit 0c61faa

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

images/virtualization-artifact/pkg/controller/service/attachment_service.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,17 @@ func (s AttachmentService) CanHotPlug(ad *AttachmentDisk, vm *v1alpha2.VirtualMa
104104
if kvvm.Spec.Template != nil {
105105
for _, vs := range kvvm.Spec.Template.Spec.Volumes {
106106
if vs.Name == name {
107-
if vs.PersistentVolumeClaim == nil {
108-
return false, fmt.Errorf("kvvm %s/%s spec volume %s does not have a pvc reference", kvvm.Namespace, kvvm.Name, vs.Name)
109-
}
110-
111-
if !vs.PersistentVolumeClaim.Hotpluggable {
112-
return false, fmt.Errorf("%w: virtual machine has a block device reference, but it is not a hot-plugged volume", ErrBlockDeviceIsSpecAttached)
107+
switch {
108+
case vs.PersistentVolumeClaim != nil:
109+
if !vs.PersistentVolumeClaim.Hotpluggable {
110+
return false, fmt.Errorf("%w: virtual machine has a block device reference, but it is not a hot-plugged volume", ErrBlockDeviceIsSpecAttached)
111+
}
112+
case vs.ContainerDisk != nil:
113+
if !vs.ContainerDisk.Hotpluggable {
114+
return false, fmt.Errorf("%w: virtual machine has a block device reference, but it is not a hot-plugged volume", ErrBlockDeviceIsSpecAttached)
115+
}
116+
default:
117+
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)
113118
}
114119

115120
return false, ErrHotPlugRequestAlreadySent

0 commit comments

Comments
 (0)