Skip to content

fix(dra): skip usbip devices in discovery when vhci_hcd has not fully released them#2122

Merged
yaroslavborbat merged 1 commit into
mainfrom
fix/usb/improve-discovery-usbip-devices
Mar 20, 2026
Merged

fix(dra): skip usbip devices in discovery when vhci_hcd has not fully released them#2122
yaroslavborbat merged 1 commit into
mainfrom
fix/usb/improve-discovery-usbip-devices

Conversation

@yaroslavborbat
Copy link
Copy Markdown
Member

@yaroslavborbat yaroslavborbat commented Mar 20, 2026

Description

During USB device discovery in the DRA plugin, when a USBIP device is detached, there is a race window where the device has already been removed from the USBIP attach info (bus ID set) but is still present in sysfs — because vhci_hcd driver has not fully released it yet.

In this window, the device was incorrectly classified as a regular local USB device and published into the ResourceSlice. It was removed shortly after once vhci_hcd released it, but this caused a brief flap in the ResourceSlice.

The fix detects such devices by resolving the sysfs path symlink and checking whether it goes through the vhci_hcd subsystem. If so, the device is skipped during discovery to prevent the flap.

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

When a USBIP device is detached, there is a brief period during which:

  1. The device is no longer in the USBIP attach info (bus ID set).
  2. But the sysfs entry still exists because vhci_hcd has not finished cleanup.

As a result, the discovery loop incorrectly published the detaching USBIP device as a local USB device into the ResourceSlice. It was immediately removed on the next reconciliation cycle, but the transient publish caused a flap — unnecessary churn in the ResourceSlice and potentially confusing state for the scheduler.

What is the expected result?

  1. Detach a USBIP device from a node while the DRA plugin is running.
  2. Observe the ResourceSlice — the detaching USBIP device should NOT appear as a local USB device at any point during the detach process.
  3. No flap in the ResourceSlice contents during USBIP device lifecycle events.

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: vm
type: fix
summary: "Fixed the detection of USB devices on the host: previously, there was a possibility of duplicate USB devices appearing."

@yaroslavborbat yaroslavborbat changed the title fix fix(dra): skip usbip devices in discovery when vhci_hcd has not fully released them Mar 20, 2026
@yaroslavborbat yaroslavborbat force-pushed the fix/usb/improve-discovery-usbip-devices branch from fa24791 to 1c5a3c6 Compare March 20, 2026 13:33
@yaroslavborbat yaroslavborbat added this to the v1.7.0 milestone Mar 20, 2026
@yaroslavborbat yaroslavborbat force-pushed the fix/usb/improve-discovery-usbip-devices branch from 1c5a3c6 to 6224f6d Compare March 20, 2026 13:33
danilrwx
danilrwx previously approved these changes Mar 20, 2026
… released them

Signed-off-by: Yaroslav Borbat <yaroslav.borbat@flant.com>
@yaroslavborbat yaroslavborbat force-pushed the fix/usb/improve-discovery-usbip-devices branch from 6224f6d to b554d28 Compare March 20, 2026 15:07
@yaroslavborbat yaroslavborbat merged commit 26e50d0 into main Mar 20, 2026
27 of 28 checks passed
@yaroslavborbat yaroslavborbat deleted the fix/usb/improve-discovery-usbip-devices branch March 20, 2026 15:23
This was referenced Mar 30, 2026
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