[VOL-5451] delete device error handling

Signed-off-by: mgouda <madhumati.gouda@radisys.com>
Change-Id: I95e83b560d01f266901ba1bc1f1ea59ca55a8cd5
Signed-off-by: mgouda <madhumati.gouda@radisys.com>
diff --git a/internal/pkg/mib/mib_download.go b/internal/pkg/mib/mib_download.go
index 8f1a26d..b05f67b 100755
--- a/internal/pkg/mib/mib_download.go
+++ b/internal/pkg/mib/mib_download.go
@@ -407,9 +407,12 @@
 		// should not happen so far
 		logger.Warnw(ctx, "MibDownload-bridge-init response error", log.Fields{"for device-id": onuDeviceEntry.deviceID})
 		return fmt.Errorf("mibDownloadBridgeInit responseError %s", onuDeviceEntry.deviceID)
-	case <-onuDeviceEntry.baseDeviceHandler.GetDeviceDeleteCommChan(ctx):
-		logger.Warnw(ctx, "Deleting device, do not wait for OMCI response", log.Fields{"device-id": onuDeviceEntry.deviceID})
-		return fmt.Errorf("mibDownloadBridgeInit device deletion in progress! %s", onuDeviceEntry.deviceID)
-
+	case _, ok := <-onuDeviceEntry.baseDeviceHandler.GetDeviceDeleteCommChan(ctx):
+		if !ok {
+			// The channel is closed, so log this and return an appropriate error.
+			logger.Warnw(ctx, "Device deletion channel closed - aborting retry", log.Fields{"device-id": onuDeviceEntry.deviceID})
+			return fmt.Errorf("mibDownloadBridgeInit aborted: device deletion channel closed for device %s", onuDeviceEntry.deviceID)
+		}
+		return nil
 	}
 }