Skip to content

Commit

Permalink
feat: remove orphaned USB device automatically and add reconcile afte…
Browse files Browse the repository at this point in the history
…r deleting claim

Signed-off-by: Jack Yu <[email protected]>
  • Loading branch information
Yu-Jack committed Oct 8, 2024
1 parent b84ac9a commit c63833e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/usbdevice/usbdevice_claim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ type DevClaimHandler struct {
lock *sync.Mutex
usbDeviceCache ctldevicerv1beta1.USBDeviceCache
managedDevicePlugins map[string]*deviceplugins.USBDevicePlugin
reconcileUSBDevice chan struct{}
reconcileUSBDevice chan<- struct{}
}

func NewClaimHandler(
usbDeviceCache ctldevicerv1beta1.USBDeviceCache,
usbClaimClient ctldevicerv1beta1.USBDeviceClaimClient,
usbClient ctldevicerv1beta1.USBDeviceClient,
virtClient ctlkubevirtv1.KubeVirtClient,
reconcileUSBDevice chan struct{},
reconcileUSBDevice chan<- struct{},
) *DevClaimHandler {
return &DevClaimHandler{
usbDeviceCache: usbDeviceCache,
Expand Down
2 changes: 2 additions & 0 deletions pkg/webhook/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func RegisterIndexers(clients *Clients) {
vmCache := clients.KubevirtFactory.Kubevirt().V1().VirtualMachine().Cache()
vmCache.AddIndexer(VMByName, vmByName)
vmCache.AddIndexer(VMByPCIDeviceClaim, common.VMByHostDeviceName)
// Because USB device don't have same problem which vGPU and PCI device have,
// so we just need to use a simple way to collect the host device names.
vmCache.AddIndexer(VMByUSBDeviceClaim, common.VMBySpecHostDeviceName)
vmCache.AddIndexer(VMByVGPU, common.VMByVGPUDevice)
deviceCache := clients.DeviceFactory.Devices().V1beta1().PCIDevice().Cache()
Expand Down

0 comments on commit c63833e

Please sign in to comment.