[VOL-2638] Returning error when storing data for new ONU
Change-Id: I6841fe77e5153bd1a8129d7cd1f45445f8ccbf8b
diff --git a/VERSION b/VERSION
index eef2640..a724a9c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4.0-dev0
+2.4.0-dev
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 7304b9a..1390e1d 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -981,7 +981,9 @@
func (dh *DeviceHandler) activateONU(ctx context.Context, intfID uint32, onuID int64, serialNum *oop.SerialNumber, serialNumber string) error {
logger.Debugw("activate-onu", log.Fields{"intfID": intfID, "onuID": onuID, "serialNum": serialNum, "serialNumber": serialNumber})
- dh.flowMgr.UpdateOnuInfo(ctx, intfID, uint32(onuID), serialNumber)
+ if err := dh.flowMgr.UpdateOnuInfo(ctx, intfID, uint32(onuID), serialNumber); err != nil {
+ return olterrors.NewErrAdapter("onu-activate-failed", log.Fields{"onu": onuID, "intfID": intfID}, err)
+ }
// TODO: need resource manager
var pir uint32 = 1000000
Onu := oop.Onu{IntfId: intfID, OnuId: uint32(onuID), SerialNumber: serialNum, Pir: pir}
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 451485f..3522ebd 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -2218,18 +2218,17 @@
}
//UpdateOnuInfo function adds onu info to cache and kvstore
-func (f *OpenOltFlowMgr) UpdateOnuInfo(ctx context.Context, intfID uint32, onuID uint32, serialNum string) {
+func (f *OpenOltFlowMgr) UpdateOnuInfo(ctx context.Context, intfID uint32, onuID uint32, serialNum string) error {
f.lockCache.Lock()
defer f.lockCache.Unlock()
onu := rsrcMgr.OnuGemInfo{OnuID: onuID, SerialNumber: serialNum, IntfID: intfID}
f.onuGemInfo[intfID] = append(f.onuGemInfo[intfID], onu)
if err := f.resourceMgr.AddOnuGemInfo(ctx, intfID, onu); err != nil {
- // TODO: VOL-2638
- logger.Errorw("failed to add onu info", log.Fields{"onu": onu})
- return
+ return err
}
logger.Debugw("Updated onuinfo", log.Fields{"intfID": intfID, "onuID": onuID, "serialNum": serialNum})
+ return nil
}
//addGemPortToOnuInfoMap function adds GEMport to ONU map
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index 1db98b9..d3a9789 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -22,6 +22,7 @@
"encoding/json"
"errors"
"fmt"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
"strconv"
"strings"
@@ -1037,17 +1038,19 @@
if err = RsrcMgr.ResourceMgrs[IntfID].GetOnuGemInfo(ctx, IntfID, &onuGemData); err != nil {
logger.Errorf("failed to get onuifo for intfid %d", IntfID)
- return err
+ return olterrors.NewErrPersistence("get", "OnuGemInfo", IntfID,
+ log.Fields{"onuGem": onuGem, "intfID": IntfID}, err)
}
onuGemData = append(onuGemData, onuGem)
err = RsrcMgr.ResourceMgrs[IntfID].AddOnuGemInfo(ctx, IntfID, onuGemData)
if err != nil {
logger.Error("Failed to add onugem to kv store")
- return err
+ return olterrors.NewErrPersistence("set", "OnuGemInfo", IntfID,
+ log.Fields{"onuGemData": onuGemData, "intfID": IntfID}, err)
}
logger.Debugw("added onu to onugeminfo", log.Fields{"intf": IntfID, "onugem": onuGem})
- return err
+ return nil
}
// UpdateOnuGemInfo updates Onuinfo on the kvstore per interface