diff --git a/pkg/controller/gpudevice/vgpu_controller.go b/pkg/controller/gpudevice/vgpu_controller.go index 5c77289f..40df2064 100644 --- a/pkg/controller/gpudevice/vgpu_controller.go +++ b/pkg/controller/gpudevice/vgpu_controller.go @@ -8,15 +8,13 @@ import ( "reflect" "sync" + "github.com/google/uuid" + "github.com/sirupsen/logrus" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" kubevirtv1 "kubevirt.io/api/core/v1" - "github.com/google/uuid" - "github.com/sirupsen/logrus" - "github.com/harvester/pcidevices/pkg/apis/devices.harvesterhci.io/v1beta1" "github.com/harvester/pcidevices/pkg/deviceplugins" "github.com/harvester/pcidevices/pkg/util/gpuhelper" diff --git a/pkg/controller/pcideviceclaim/pcideviceclaim_controller.go b/pkg/controller/pcideviceclaim/pcideviceclaim_controller.go index 8a8f7dfd..1f1ce4c8 100644 --- a/pkg/controller/pcideviceclaim/pcideviceclaim_controller.go +++ b/pkg/controller/pcideviceclaim/pcideviceclaim_controller.go @@ -424,17 +424,14 @@ func (h *Handler) startDevicePlugin( if dp.Started() { return nil } - // Start the plugin - stop := make(chan struct{}) + go func() { - err := dp.Start(stop) + err := dp.Start() if err != nil { logrus.Errorf("error starting %s device plugin: %s", dp.GetDeviceName(), err) } - // TODO: test if deleting this stops the DevicePlugin - <-stop }() - dp.SetStarted(stop) + dp.SetStarted() return nil } diff --git a/pkg/deviceplugins/device_manager.go b/pkg/deviceplugins/device_manager.go index b45434d3..d0533c48 100644 --- a/pkg/deviceplugins/device_manager.go +++ b/pkg/deviceplugins/device_manager.go @@ -60,7 +60,6 @@ type PCIDevicePlugin struct { devs []*pluginapi.Device server *grpc.Server socketPath string - stop <-chan struct{} health chan deviceHealth devicePath string resourceName string @@ -150,9 +149,8 @@ func constructDPIdevices(pciDevices []*PCIDevice, iommuToPCIMap map[string]strin var defaultBackoffTime = []time.Duration{1 * time.Second, 2 * time.Second, 5 * time.Second, 10 * time.Second} // Set Started is used after a call to Start. It's purpose is to set the private starter properly -func (dp *PCIDevicePlugin) SetStarted(stop chan struct{}) { +func (dp *PCIDevicePlugin) SetStarted() { c := dp.starter - c.stopChan = stop c.started = true logrus.Infof("Started DevicePlugin: %s", dp.resourceName) } @@ -166,9 +164,8 @@ func (dp *PCIDevicePlugin) Stop() error { } // Start starts the device plugin -func (dp *PCIDevicePlugin) Start(stop <-chan struct{}) (err error) { +func (dp *PCIDevicePlugin) Start() (err error) { logger := log.DefaultLogger() - dp.stop = stop dp.done = make(chan struct{}) dp.deregistered = make(chan struct{}) @@ -235,8 +232,6 @@ func (dp *PCIDevicePlugin) ListAndWatch(_ *pluginapi.Empty, s pluginapi.DevicePl return err } logrus.Debugf("Sending ListAndWatchResponse for device with dpi.devs = %v", dp.devs) - case <-dp.stop: - done = true case <-dp.done: done = true } @@ -350,8 +345,6 @@ func (dp *PCIDevicePlugin) healthCheck() error { for { select { - case <-dp.stop: - return nil case err := <-watcher.Errors: logger.Reason(err).Errorf("error watching devices and device plugin directory") case event := <-watcher.Events: