[VOL-1890] Flow decomposition fails after a core switch over

This commit fixes the issue reported in VOL-1890 by doing
the following:
1) Update the device graph if the device graph was built
with an older logical device topology (this can happen in
the standby by core as currently the model does not trigger
a core callback after it updates its data in memory following
a watch event from the KV store - this is a TODO item).
2) Update flows in a logical device without using the data
model proxy to flows directly.
3) Reconcile the list of devices and logical devices in the
core memory after a restart upon receive a reconcile request
from the api server.

After first review:
1) Update the code as per the comments
2) Change the device loading channel to have two simultaneous
routines invoking the device loading for the same device to
return the same result (i.e. if it's a success then both
should return success and conversely in the failure case)

After second review:
Change the sync map controlling the device in loading state
to regular map.

Change-Id: I4331ac2a8f87a7de272e919a31dfe4bbaaf327a0
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index a61ca25..89b1fe9 100755
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -95,18 +95,19 @@
 			log.Errorw("failed-to-load-device", log.Fields{"deviceId": agent.deviceId})
 			return status.Errorf(codes.NotFound, "device-%s", agent.deviceId)
 		}
-		log.Debugw("device-loaded-from-dB", log.Fields{"device": agent.lastData})
+		log.Debugw("device-loaded-from-dB", log.Fields{"deviceId": agent.deviceId})
 	} else {
 		// Add the initial device to the local model
 		if added := agent.clusterDataProxy.AddWithID(ctx, "/devices", agent.deviceId, agent.lastData, ""); added == nil {
 			log.Errorw("failed-to-add-device", log.Fields{"deviceId": agent.deviceId})
+			return status.Errorf(codes.Aborted, "failed-adding-device-%s", agent.deviceId)
 		}
 	}
 
 	agent.deviceProxy = agent.clusterDataProxy.CreateProxy(ctx, "/devices/"+agent.deviceId, false)
 	agent.deviceProxy.RegisterCallback(model.POST_UPDATE, agent.processUpdate)
 
-	log.Debug("device-agent-started")
+	log.Debugw("device-agent-started", log.Fields{"deviceId": agent.deviceId})
 	return nil
 }