[VOL-2835] Fix adapter reconcile for multiple adapters
Change-Id: Ib2c94ed757bc349a9984eb0108cd3b530999c68f
diff --git a/VERSION b/VERSION
index a724a9c..197c4d5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4.0-dev
+2.4.0
diff --git a/rw_core/core/adapter_manager.go b/rw_core/core/adapter_manager.go
index faece55..889ad74 100644
--- a/rw_core/core/adapter_manager.go
+++ b/rw_core/core/adapter_manager.go
@@ -94,7 +94,7 @@
clusterDataProxy: cdProxy,
deviceTypes: make(map[string]*voltha.DeviceType),
adapterAgents: make(map[string]*AdapterAgent),
- deviceMgr: deviceMgr,
+ deviceMgr: deviceMgr,
}
kafkaClient.SubscribeForMetadata(aMgr.updateLastAdapterCommunication)
return aMgr
diff --git a/rw_core/core/device_manager.go b/rw_core/core/device_manager.go
index 18593d8..8f9847b 100755
--- a/rw_core/core/device_manager.go
+++ b/rw_core/core/device_manager.go
@@ -615,7 +615,12 @@
responses := make([]utils.Response, 0)
for rootDeviceID := range dMgr.rootDevices {
if rootDevice, _ := dMgr.getDeviceFromModel(ctx, rootDeviceID); rootDevice != nil {
- if rootDevice.Adapter == adapter.Id {
+ isDeviceOwnedByService, err := dMgr.adapterProxy.endpointManager.IsDeviceOwnedByService(rootDeviceID, adapter.Type, adapter.CurrentReplica)
+ if err != nil {
+ logger.Warnw("is-device-owned-by-service", log.Fields{"error": err, "root-device-id": rootDeviceID, "adapterType": adapter.Type, "replica-number": adapter.CurrentReplica})
+ continue
+ }
+ if isDeviceOwnedByService {
if isOkToReconcile(rootDevice) {
logger.Debugw("reconciling-root-device", log.Fields{"rootId": rootDevice.Id})
responses = append(responses, dMgr.sendReconcileDeviceRequest(ctx, rootDevice))
@@ -627,12 +632,16 @@
for _, port := range rootDevice.Ports {
for _, peer := range port.Peers {
if childDevice, _ := dMgr.getDeviceFromModel(ctx, peer.DeviceId); childDevice != nil {
- if childDevice.Adapter == adapter.Id {
+ isDeviceOwnedByService, err := dMgr.adapterProxy.endpointManager.IsDeviceOwnedByService(childDevice.Id, adapter.Type, adapter.CurrentReplica)
+ if err != nil {
+ logger.Warnw("is-device-owned-by-service", log.Fields{"error": err, "child-device-id": childDevice.Id, "adapterType": adapter.Type, "replica-number": adapter.CurrentReplica})
+ }
+ if isDeviceOwnedByService {
if isOkToReconcile(childDevice) {
- logger.Debugw("reconciling-child-device", log.Fields{"childId": childDevice.Id})
+ logger.Debugw("reconciling-child-device", log.Fields{"child-device-id": childDevice.Id})
responses = append(responses, dMgr.sendReconcileDeviceRequest(ctx, childDevice))
} else {
- logger.Debugw("not-reconciling-child-device", log.Fields{"childId": childDevice.Id, "state": childDevice.AdminState})
+ logger.Debugw("not-reconciling-child-device", log.Fields{"child-device-id": childDevice.Id, "state": childDevice.AdminState})
}
} else {
// All child devices under a parent device are typically managed by the same adapter type.