From 27d9ea5fcb08a7d08bb9558c1b5dc33c39a199a5 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Thu, 11 Jul 2024 18:41:39 +0800 Subject: [PATCH] fix: initial reconcile should use client instead of cache Signed-off-by: Jack Yu --- pkg/controller/usbdevice/usbdevice_controller.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/controller/usbdevice/usbdevice_controller.go b/pkg/controller/usbdevice/usbdevice_controller.go index 4208ed9..9fb37e5 100644 --- a/pkg/controller/usbdevice/usbdevice_controller.go +++ b/pkg/controller/usbdevice/usbdevice_controller.go @@ -132,16 +132,16 @@ func (h *DevHandler) reconcile() error { return err } - storedUSBDevices, err := h.usbCache.List(labels.SelectorFromSet(cl.labels())) + list, err := h.usbClient.List(metav1.ListOptions{LabelSelector: labels.Set(cl.labels()).String()}) if err != nil { logrus.Errorf("failed to list USB devices: %v\n", err) return err } mapStoredUSBDevices := make(map[string]*v1beta1.USBDevice) - for _, storedUSBDevice := range storedUSBDevices { + for _, storedUSBDevice := range list.Items { storedUSBDevice := storedUSBDevice - mapStoredUSBDevices[storedUSBDevice.Status.DevicePath] = storedUSBDevice + mapStoredUSBDevices[storedUSBDevice.Status.DevicePath] = &storedUSBDevice } err = h.handleList(h.getList(localUSBDevices, mapStoredUSBDevices, nodeName))