[VOL-5443] Fix for ONU activation issue due to device exist in core

Change-Id: Ife51a924d7fec138fabee652741365e7d1bfda5a
Signed-off-by: bseeniva <balaji.seenivasan@radisys.com>
diff --git a/VERSION b/VERSION
index e152b49..2975971 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.5.14
+4.5.15
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 918d918..9c82a8c 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -1788,29 +1788,34 @@
 	})
 }
 
+func (dh *DeviceHandler) handleOnuDiscoveryProcessingError(ctx context.Context, err error, sn string, tpInstExists bool) {
+	if err != nil || tpInstExists {
+		logger.Infow(ctx, "onu-processing-errored-out-not-adding-to-discovery-map", log.Fields{"sn": sn})
+	} else {
+		// once the function completes set the value to false so that
+		// we know the processing has inProcess.
+		// Note that this is done after checking if we are already processing
+		// to avoid changing the value from a different thread
+		logger.Infow(ctx, "onu-processing-completed", log.Fields{"sn": sn})
+		dh.discOnus.Store(sn, false)
+	}
+}
+
 func (dh *DeviceHandler) onuDiscIndication(ctx context.Context, onuDiscInd *oop.OnuDiscIndication) error {
 	var error error
+	var tpInstExists bool
 
 	channelID := onuDiscInd.GetIntfId()
 	parentPortNo := plt.IntfIDToPortNo(onuDiscInd.GetIntfId(), voltha.Port_PON_OLT)
 
 	sn := dh.stringifySerialNumber(onuDiscInd.SerialNumber)
 	defer func() {
-		if error != nil {
-			logger.Infow(ctx, "onu-processing-errored-out-not-adding-to-discovery-map", log.Fields{"sn": sn})
-		} else {
-			// once the function completes set the value to false so that
-			// we know the processing has inProcess.
-			// Note that this is done after checking if we are already processing
-			// to avoid changing the value from a different thread
-			logger.Infow(ctx, "onu-processing-completed", log.Fields{"sn": sn})
-			dh.discOnus.Store(sn, false)
-		}
+		dh.handleOnuDiscoveryProcessingError(ctx, error, sn, tpInstExists)
 	}()
 
 	logger.Infow(ctx, "new-discovery-indication", log.Fields{"sn": sn})
 
-	tpInstExists, error := dh.checkForResourceExistance(ctx, onuDiscInd, sn)
+	tpInstExists, error = dh.checkForResourceExistance(ctx, onuDiscInd, sn)
 	if error != nil {
 		return error
 	}