Skip to content

feat(usb): NodeUSBDevice controller#1913

Open
danilrwx wants to merge 3 commits intofeat/dra-usbipfrom
feat/node-usb-device
Open

feat(usb): NodeUSBDevice controller#1913
danilrwx wants to merge 3 commits intofeat/dra-usbipfrom
feat/node-usb-device

Conversation

@danilrwx
Copy link
Contributor

@danilrwx danilrwx commented Jan 23, 2026

Description

Added a new CRD NodeUSBDevice and controller for managing USB devices at the node level in the cluster.

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

The DRA (Dynamic Resource Allocation) system automatically discovers USB devices on cluster nodes and creates ResourceSlice resources. However, there was no convenient mechanism for managing these devices at the Kubernetes level:

  • No way to see all USB devices discovered on cluster nodes in a unified view
  • No ability to assign devices to specific namespaces for use in virtual machines
  • No automatic synchronization between devices on nodes and USBDevice resources in namespaces

Solution:

NodeUSBDevice provides an abstraction layer between physical USB devices on nodes (represented via ResourceSlice) and logical USBDevice resources in namespaces. This enables:

  • Administrators to see all available USB devices in the cluster via kubectl get nodeusbdevices
  • Assigning devices to specific namespaces by setting spec.assignedNamespace
  • Automatic creation of USBDevice resources in namespaces upon assignment, simplifying device usage in virtual machines

What is the expected result?

  • NodeUSBDevice resources are automatically created for all USB devices discovered by the DRA system
  • The Ready condition correctly reflects device presence on the node
  • When assignedNamespace is set, a USBDevice is automatically created in the specified namespace
  • When assignedNamespace is changed or cleared, corresponding USBDevice resources are correctly deleted
  • All device attributes (vendorID, productID, manufacturer, product, etc.) are correctly synchronized from ResourceSlice

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: api
type: feature
summary: Add NodeUSBDevice and USBDevice.

@danilrwx danilrwx changed the base branch from main to feat/dra-usbip January 23, 2026 16:52
@danilrwx danilrwx force-pushed the feat/node-usb-device branch from 29be831 to b276ce0 Compare January 23, 2026 16:57
@danilrwx danilrwx changed the base branch from feat/dra-usbip to feat/dra-hotplug-claims January 23, 2026 16:57
@danilrwx danilrwx changed the base branch from feat/dra-hotplug-claims to feat/dra January 23, 2026 16:57
@danilrwx danilrwx changed the base branch from feat/dra to feat/dra-usbip January 23, 2026 16:58
@danilrwx danilrwx force-pushed the feat/node-usb-device branch from b276ce0 to 9b7436f Compare January 23, 2026 16:58
@danilrwx danilrwx added this to the v1.6.0 milestone Jan 26, 2026
@danilrwx danilrwx force-pushed the feat/node-usb-device branch 7 times, most recently from 127101a to 7dadda9 Compare February 2, 2026 15:36
@danilrwx danilrwx force-pushed the feat/node-usb-device branch 5 times, most recently from fc3f7d8 to 3a040c2 Compare February 4, 2026 17:39
@yaroslavborbat yaroslavborbat force-pushed the feat/dra-usbip branch 7 times, most recently from dd2ef4f to fce3c4d Compare February 6, 2026 14:34
@danilrwx danilrwx force-pushed the feat/node-usb-device branch 4 times, most recently from a3a9f61 to bdca1c1 Compare February 9, 2026 16:36
@danilrwx danilrwx force-pushed the feat/node-usb-device branch 4 times, most recently from d644166 to aec501d Compare February 19, 2026 11:11
@danilrwx danilrwx marked this pull request as ready for review February 19, 2026 12:09
@danilrwx danilrwx force-pushed the feat/node-usb-device branch from 39c0a2b to 60c1742 Compare February 19, 2026 12:59
@Isteb4k Isteb4k assigned Isteb4k and danilrwx and unassigned Isteb4k Feb 19, 2026
@danilrwx danilrwx force-pushed the feat/node-usb-device branch from 60c1742 to ef60a2f Compare February 19, 2026 13:05
@z9r5 z9r5 requested a review from prismagod February 19, 2026 13:39

// validateUSBDevicesUnique checks that each USB device is not used by another VM.
// currentVMName is empty for Create (no VM to exclude), or VM name for Update (exclude current VM from conflict check).
func (v *USBDevicesValidator) validateUSBDevicesUnique(ctx context.Context, vm *v1alpha2.VirtualMachine, currentVMName string) (admission.Warnings, error) {
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to check all USB devices, only the ones that are being added.

Copy link
Member

Choose a reason for hiding this comment

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

Rename the function to reflect that

@danilrwx danilrwx force-pushed the feat/node-usb-device branch 2 times, most recently from 086afa3 to f2929ed Compare February 19, 2026 19:08
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>

fix

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx force-pushed the feat/node-usb-device branch from f2929ed to 6691b27 Compare February 19, 2026 19:09
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.

3 participants

Comments