[VOL-5396]-Remove remote connection check during Reconcile

Change-Id: I4fe55f7d2498656a4aad27936d30da71e9653e4a
Signed-off-by: Akash Soni <akash.soni@radisys.com>
diff --git a/VERSION b/VERSION
index 838c0e7..95d3ab1 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.12.10-dev4
\ No newline at end of file
+2.12.10-dev5
\ No newline at end of file
diff --git a/internal/pkg/core/openonu.go b/internal/pkg/core/openonu.go
index 445257a..9e46c54 100755
--- a/internal/pkg/core/openonu.go
+++ b/internal/pkg/core/openonu.go
@@ -264,17 +264,10 @@
 		return nil, errors.New("nil-device")
 	}
 	logger.Infow(ctx, "reconcile-device", log.Fields{"device-id": device.Id, "parent-id": device.ParentId})
-
-	// Check whether the grpc client in the adapter of the parent device can reach us yet
-	if !oo.isReachableFromRemote(ctx, device.ProxyAddress.AdapterEndpoint, device.ProxyAddress.DeviceId) {
-		return nil, status.Errorf(codes.Unavailable, "adapter-not-reachable-from-parent-%s", device.ProxyAddress.AdapterEndpoint)
-	}
-
 	var handler *deviceHandler
 	if handler = oo.getDeviceHandler(ctx, device.Id, false); handler == nil {
 		handler := newDeviceHandler(ctx, oo.coreClient, oo.eventProxy, device, oo)
 		logger.Infow(ctx, "reconciling-device  skip-onu-config value ", log.Fields{"device-id": device.Id, "parent-id": device.ParentId, "skip-onu-config": oo.skipOnuConfig})
-		oo.addDeviceHandlerToMap(ctx, handler)
 		handler.device = device
 		if err := handler.updateDeviceStateInCore(log.WithSpanFromContext(context.Background(), ctx), &ca.DeviceStateFilter{
 			DeviceId:   device.Id,
@@ -288,7 +281,8 @@
 			// TODO: Cleanup on failure needed
 			return nil, err
 		}
-
+		// Add device handler to map only if adapter and core connections are up
+		oo.addDeviceHandlerToMap(ctx, handler)
 		handler.StartReconciling(log.WithSpanFromContext(context.Background(), ctx), false)
 		go handler.adoptOrReconcileDevice(log.WithSpanFromContext(context.Background(), ctx), handler.device)
 		// reconcilement will be continued after onu-device entry is added
@@ -1030,19 +1024,19 @@
 	oo.reachableFromRemote[endpointHash] = &reachabilityFromRemote{lastKeepAlive: time.Now(), keepAliveInterval: remote.KeepAliveInterval}
 }
 
-func (oo *OpenONUAC) isReachableFromRemote(ctx context.Context, endpoint string, contextInfo string) bool {
-	logger.Debugw(ctx, "checking-remote-reachability", log.Fields{"endpoint": endpoint, "context": contextInfo})
-	oo.lockReachableFromRemote.RLock()
-	defer oo.lockReachableFromRemote.RUnlock()
-	endpointHash := getHash(endpoint, contextInfo)
-	if _, ok := oo.reachableFromRemote[endpointHash]; ok {
-		logger.Debugw(ctx, "endpoint-exists", log.Fields{"last-keep-alive": time.Since(oo.reachableFromRemote[endpointHash].lastKeepAlive)})
-		// Assume the connection is down if we did not receive 2 keep alives in succession
-		maxKeepAliveWait := time.Duration(oo.reachableFromRemote[endpointHash].keepAliveInterval * 2)
-		return time.Since(oo.reachableFromRemote[endpointHash].lastKeepAlive) <= maxKeepAliveWait
-	}
-	return false
-}
+// func (oo *OpenONUAC) isReachableFromRemote(ctx context.Context, endpoint string, contextInfo string) bool {
+// 	logger.Debugw(ctx, "checking-remote-reachability", log.Fields{"endpoint": endpoint, "context": contextInfo})
+// 	oo.lockReachableFromRemote.RLock()
+// 	defer oo.lockReachableFromRemote.RUnlock()
+// 	endpointHash := getHash(endpoint, contextInfo)
+// 	if _, ok := oo.reachableFromRemote[endpointHash]; ok {
+// 		logger.Debugw(ctx, "endpoint-exists", log.Fields{"last-keep-alive": time.Since(oo.reachableFromRemote[endpointHash].lastKeepAlive)})
+// 		// Assume the connection is down if we did not receive 2 keep alives in succession
+// 		maxKeepAliveWait := time.Duration(oo.reachableFromRemote[endpointHash].keepAliveInterval * 2)
+// 		return time.Since(oo.reachableFromRemote[endpointHash].lastKeepAlive) <= maxKeepAliveWait
+// 	}
+// 	return false
+// }
 
 // stopAllGrpcClients stops all grpc clients in use
 func (oo *OpenONUAC) stopAllGrpcClients(ctx context.Context) {