[VOL-1974] ONUs can not be discovered after hard rebooting the OLT
When the OLT is rebooted, it starts to send ONU discover indications
again and to process them the discovered onu cache should be cleared.
Also necessary lock mechanism added.
Change-Id: Iaf31bdec06ed24605aa5879d1246c38dcdf3cb25
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index ab30edd..9ad9941 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -382,6 +382,8 @@
// doStateDown handle the olt down indication
func (dh *DeviceHandler) doStateDown() error {
+ dh.lockDevice.Lock()
+ defer dh.lockDevice.Unlock()
log.Debug("do-state-down-start")
device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
@@ -424,9 +426,12 @@
if er != nil {
log.Errorw("Failed to send inter-adapter-message", log.Fields{"OnuInd": onuInd,
"From Adapter": "openolt", "DevieType": onuDevice.Type, "DeviceID": onuDevice.Id})
- return er
+ //Do not return here and continue to process other ONUs
}
}
+ /* Discovered ONUs entries need to be cleared , since after OLT
+ is up, it starts sending discovery indications again*/
+ dh.discOnus = make(map[string]bool)
log.Debugw("do-state-down-end", log.Fields{"deviceID": device.Id})
return nil
}
diff --git a/adaptercore/openolt_flowmgr.go b/adaptercore/openolt_flowmgr.go
index e99d36e..7baabb1 100644
--- a/adaptercore/openolt_flowmgr.go
+++ b/adaptercore/openolt_flowmgr.go
@@ -29,6 +29,7 @@
tp "github.com/opencord/voltha-go/common/techprofile"
"github.com/opencord/voltha-go/rw_core/utils"
rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
+ "github.com/opencord/voltha-protos/go/common"
ic "github.com/opencord/voltha-protos/go/inter_container"
ofp "github.com/opencord/voltha-protos/go/openflow_13"
openoltpb2 "github.com/opencord/voltha-protos/go/openolt"
@@ -1017,8 +1018,14 @@
log.Debugw("Sending flow to device via grpc", log.Fields{"flow": *deviceFlow})
_, err := f.deviceHandler.Client.FlowRemove(context.Background(), deviceFlow)
if err != nil {
+ if f.deviceHandler.device.ConnectStatus == common.ConnectStatus_UNREACHABLE {
+ log.Warnw("Can not remove flow from device since it's unreachable", log.Fields{"err": err, "deviceFlow": deviceFlow})
+ //Assume the flow is removed
+ return true
+ }
log.Errorw("Failed to Remove flow from device", log.Fields{"err": err, "deviceFlow": deviceFlow})
return false
+
}
log.Debugw("Flow removed from device successfully ", log.Fields{"flow": *deviceFlow})
return true