Skip to content

Commit bd2a95c

Browse files
committed
fix(usb): check ports only for new device attachments
Check USBIP port availability only when device is added for the first time (existingStatus == nil). Once a device has a status, the attach request was already sent and ports were available at that time. This prevents devices from getting stuck if ports are exhausted mid-flight while DRA processes the request. Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
1 parent 0c92718 commit bd2a95c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

images/virtualization-artifact/pkg/controller/vm/internal/usb_device_attach_handler.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,10 @@ func (h *USBDeviceAttachHandler) Handle(ctx context.Context, s state.VirtualMach
163163
continue
164164
}
165165

166-
// 4) Check free USBIP ports for new attachments from other nodes.
167-
// Skip this check if the device is already being processed (request already sent).
168-
// A device is considered "in progress" when Ready=true but not yet Attached in KVVMI.
169-
// Re-checking would cause devices to get stuck when ports are exhausted mid-flight.
170-
isInProgress := existingStatus != nil && existingStatus.Ready && !existingStatus.Attached
171-
if !isInProgress && usbDevice.Status.NodeName != "" && vm.Status.Node != "" && usbDevice.Status.NodeName != vm.Status.Node {
166+
// 4) Check free USBIP ports only for NEW attachments from other nodes.
167+
// If device already has a status (existingStatus != nil), the request was already sent.
168+
// Skip re-checking to avoid stuck devices when ports are exhausted mid-flight.
169+
if existingStatus == nil && usbDevice.Status.NodeName != "" && vm.Status.Node != "" && usbDevice.Status.NodeName != vm.Status.Node {
172170
node := &corev1.Node{}
173171
if err := h.client.Get(ctx, client.ObjectKey{Name: vm.Status.Node}, node); err != nil {
174172
if !apierrors.IsNotFound(err) {

0 commit comments

Comments
 (0)