[VOL-2612] Remove error log when returning error from methods
Change-Id: If07af8337a55e0d5d729fc76092590f697ee8276
diff --git a/VERSION b/VERSION
index ed09221..81e9469 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.16
+2.3.17
diff --git a/cmd/openolt-adapter/main.go b/cmd/openolt-adapter/main.go
index 2f7b235..79ce363 100644
--- a/cmd/openolt-adapter/main.go
+++ b/cmd/openolt-adapter/main.go
@@ -128,14 +128,13 @@
a.eventProxy = com.NewEventProxy(com.MsgClient(a.kafkaClient), com.MsgTopic(kafka.Topic{Name: a.config.EventTopic}))
// Create the open OLT adapter
- if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.eventProxy,
- a.config); err != nil {
- log.Fatal("error-starting-inter-container-proxy")
+ if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.eventProxy, a.config); err != nil {
+ log.Fatalw("error-starting-openolt", log.Fields{"error": err})
}
// Register the core request handler
if err = a.setupRequestHandler(ctx, a.instanceID, a.iAdapter); err != nil {
- log.Fatal("error-setting-core-request-handler")
+ log.Fatalw("error-setting-core-request-handler", log.Fields{"error": err})
}
// Register this adapter to the Core - retries indefinitely
@@ -356,7 +355,6 @@
sOLT := ac.NewOpenOLT(ctx, a.kip, cp, ap, ep, cfg)
if err = sOLT.Start(ctx); err != nil {
- log.Fatalw("error-starting-messaging-proxy", log.Fields{"error": err})
return nil, err
}
@@ -368,7 +366,6 @@
log.Info("setting-request-handler")
requestProxy := com.NewRequestHandlerProxy(coreInstanceID, iadapter, a.coreProxy)
if err := a.kip.SubscribeWithRequestHandlerInterface(kafka.Topic{Name: a.config.Topic}, requestProxy); err != nil {
- log.Errorw("request-handler-setup-failed", log.Fields{"error": err})
return err
}
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 67b852a..0e8d460 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -181,13 +181,13 @@
if ips, err = net.LookupHost(host); err == nil {
log.Debugw("dns-result-ips", log.Fields{"ips": ips})
if addr = net.ParseIP(ips[0]); addr == nil {
- return "", olterrors.NewErrInvalidValue(log.Fields{"ip": ips[0]}, nil).Log()
+ return "", olterrors.NewErrInvalidValue(log.Fields{"ip": ips[0]}, nil)
}
genmac = macifyIP(addr)
log.Debugw("using-ip-as-mac", log.Fields{"host": ips[0], "mac": genmac})
return genmac, nil
}
- return "", olterrors.NewErrAdapter("cannot-resolve-hostname-to-ip", nil, err).Log()
+ return "", olterrors.NewErrAdapter("cannot-resolve-hostname-to-ip", log.Fields{"host": host}, err)
}
genmac = macifyIP(addr)
@@ -219,7 +219,7 @@
return fmt.Sprintf("pon-%d", portNum), nil
}
- return "", olterrors.NewErrInvalidValue(log.Fields{"port-type": portType}, nil).Log()
+ return "", olterrors.NewErrInvalidValue(log.Fields{"port-type": portType}, nil)
}
func (dh *DeviceHandler) addPort(intfID uint32, portType voltha.Port_PortType, state string) error {
@@ -235,12 +235,12 @@
portNum := IntfIDToPortNo(intfID, portType)
label, err := GetportLabel(portNum, portType)
if err != nil {
- return olterrors.NewErrNotFound("port-label", log.Fields{"port-number": portNum, "port-type": portType}, nil).Log()
+ return olterrors.NewErrNotFound("port-label", log.Fields{"port-number": portNum, "port-type": portType}, err)
}
device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
if err != nil || device == nil {
- return olterrors.NewErrNotFound("device", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrNotFound("device", log.Fields{"device-id": dh.device.Id}, err)
}
if device.Ports != nil {
for _, dPort := range device.Ports {
@@ -251,7 +251,7 @@
"device-id": dh.device.Id,
"port-type": portType,
"port-number": portNum,
- "oper-status": operStatus}, err).Log()
+ "oper-status": operStatus}, err)
}
return nil
@@ -268,9 +268,9 @@
log.Debugw("Sending-port-update-to-core", log.Fields{"port": port})
// Synchronous call to update device - this method is run in its own go routine
if err := dh.coreProxy.PortCreated(context.TODO(), dh.device.Id, port); err != nil {
- return olterrors.NewErrAdapter("Error-creating-port", log.Fields{
+ return olterrors.NewErrAdapter("error-creating-port", log.Fields{
"device-id": dh.device.Id,
- "port-type": portType}, err).Log()
+ "port-type": portType}, err)
}
return nil
}
@@ -280,16 +280,16 @@
defer log.Debugw("indications-ended", log.Fields{"device-id": dh.device.Id})
indications, err := dh.Client.EnableIndication(ctx, new(oop.Empty))
if err != nil {
- return olterrors.NewErrCommunication("fail-to-read-indications", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrCommunication("fail-to-read-indications", log.Fields{"device-id": dh.device.Id}, err)
}
if indications == nil {
- return olterrors.NewErrInvalidValue(log.Fields{"indications": nil, "device-id": dh.device.Id}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"indications": nil, "device-id": dh.device.Id}, nil)
}
/* get device state */
device, err := dh.coreProxy.GetDevice(ctx, dh.device.Id, dh.device.Id)
if err != nil || device == nil {
/*TODO: needs to handle error scenarios */
- return olterrors.NewErrNotFound("device", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrNotFound("device", log.Fields{"device-id": dh.device.Id}, err)
}
// When the device is in DISABLED and Adapter container restarts, we need to
// rebuild the locally maintained admin state.
@@ -322,7 +322,7 @@
time.Sleep(indicationBackoff.NextBackOff())
indications, err = dh.Client.EnableIndication(ctx, new(oop.Empty))
if err != nil {
- return olterrors.NewErrCommunication("indication-read-failure", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrCommunication("indication-read-failure", log.Fields{"device-id": dh.device.Id}, err)
}
continue
}
@@ -334,7 +334,7 @@
}
dh.transitionMap.Handle(ctx, DeviceDownInd)
dh.transitionMap.Handle(ctx, DeviceInit)
- return olterrors.NewErrCommunication("indication-read-failure", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrCommunication("indication-read-failure", log.Fields{"device-id": dh.device.Id}, err)
}
// Reset backoff if we have a successful receive
indicationBackoff.Reset()
@@ -365,7 +365,7 @@
return olterrors.NewErrAdapter("failed-indication", log.Fields{
"device_id": dh.deviceID,
"indication": oltIndication,
- "timestamp": raisedTs}, err).Log()
+ "timestamp": raisedTs}, err)
}
return nil
}
@@ -457,7 +457,7 @@
// Synchronous call to update device state - this method is run in its own go routine
if err := dh.coreProxy.DeviceStateUpdate(ctx, dh.device.Id, voltha.ConnectStatus_REACHABLE,
voltha.OperStatus_ACTIVE); err != nil {
- return olterrors.NewErrAdapter("device-update-failed", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrAdapter("device-update-failed", log.Fields{"device-id": dh.device.Id}, err)
}
return nil
}
@@ -471,13 +471,13 @@
device, err := dh.coreProxy.GetDevice(ctx, dh.device.Id, dh.device.Id)
if err != nil || device == nil {
/*TODO: needs to handle error scenarios */
- return olterrors.NewErrNotFound("device", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrNotFound("device", log.Fields{"device-id": dh.device.Id}, err)
}
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to disable
if err = dh.coreProxy.PortsStateUpdate(ctx, cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
- return olterrors.NewErrAdapter("port-update-failed", log.Fields{"device-id": device.Id}, err).Log()
+ return olterrors.NewErrAdapter("port-update-failed", log.Fields{"device-id": device.Id}, err)
}
//Update the device oper state and connection status
@@ -486,13 +486,13 @@
dh.device = cloned
if err = dh.coreProxy.DeviceStateUpdate(ctx, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
- return olterrors.NewErrAdapter("state-update-failed", log.Fields{"device-id": device.Id}, err).Log()
+ return olterrors.NewErrAdapter("state-update-failed", log.Fields{"device-id": device.Id}, err)
}
//get the child device for the parent device
onuDevices, err := dh.coreProxy.GetChildDevices(ctx, dh.device.Id)
if err != nil {
- return olterrors.NewErrAdapter("child-device-fetch-failed", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrAdapter("child-device-fetch-failed", log.Fields{"device-id": dh.device.Id}, err)
}
for _, onuDevice := range onuDevices.Items {
@@ -523,7 +523,7 @@
if dh.clientCon, err = grpc.Dial(dh.device.GetHostAndPort(), grpc.WithInsecure(), grpc.WithBlock()); err != nil {
return olterrors.NewErrCommunication("dial-failure", log.Fields{
"device-id": dh.deviceID,
- "host-and-port": dh.device.GetHostAndPort()}, err).Log()
+ "host-and-port": dh.device.GetHostAndPort()}, err)
}
return nil
}
@@ -573,27 +573,27 @@
deviceInfo, err := dh.populateDeviceInfo()
if err != nil {
- return olterrors.NewErrAdapter("populate-device-info-failed", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrAdapter("populate-device-info-failed", log.Fields{"device-id": dh.device.Id}, err)
}
device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
if err != nil || device == nil {
/*TODO: needs to handle error scenarios */
- return olterrors.NewErrAdapter("fetch-device-failed", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrAdapter("fetch-device-failed", log.Fields{"device-id": dh.device.Id}, err)
}
dh.populateActivePorts(device)
if err := dh.disableAdminDownPorts(device); err != nil {
- return olterrors.NewErrAdapter("port-status-update-failed", log.Fields{"device": device}, err).Log()
+ return olterrors.NewErrAdapter("port-status-update-failed", log.Fields{"device": device}, err)
}
KVStoreHostPort := fmt.Sprintf("%s:%d", dh.openOLT.KVStoreHost, dh.openOLT.KVStorePort)
// Instantiate resource manager
if dh.resourceMgr = rsrcMgr.NewResourceMgr(ctx, dh.deviceID, KVStoreHostPort, dh.openOLT.KVStoreType, dh.deviceType, deviceInfo); dh.resourceMgr == nil {
- return olterrors.ErrResourceManagerInstantiating.Log()
+ return olterrors.ErrResourceManagerInstantiating
}
// Instantiate flow manager
if dh.flowMgr = NewFlowManager(ctx, dh, dh.resourceMgr); dh.flowMgr == nil {
- return olterrors.ErrResourceManagerInstantiating.Log()
+ return olterrors.ErrResourceManagerInstantiating
}
/* TODO: Instantiate Alarm , stats , BW managers */
/* Instantiating Event Manager to handle Alarms and KPIs */
@@ -617,10 +617,10 @@
deviceInfo, err = dh.Client.GetDeviceInfo(context.Background(), new(oop.Empty))
if err != nil {
- return nil, olterrors.NewErrPersistence("get", "device", 0, nil, err).Log()
+ return nil, olterrors.NewErrPersistence("get", "device", 0, nil, err)
}
if deviceInfo == nil {
- return nil, olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil).Log()
+ return nil, olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
}
log.Debugw("Fetched device info", log.Fields{"deviceInfo": deviceInfo})
@@ -636,7 +636,7 @@
host := strings.Split(dh.device.GetHostAndPort(), ":")[0]
genmac, err := generateMacFromHost(host)
if err != nil {
- return nil, olterrors.NewErrAdapter("failed-to-generate-mac-host", log.Fields{"host": host}, err).Log()
+ return nil, olterrors.NewErrAdapter("failed-to-generate-mac-host", log.Fields{"host": host}, err)
}
log.Debugw("using-host-for-mac-address", log.Fields{"host": host, "mac": genmac})
dh.device.MacAddress = genmac
@@ -646,7 +646,7 @@
// Synchronous call to update device - this method is run in its own go routine
if err := dh.coreProxy.DeviceUpdate(context.TODO(), dh.device); err != nil {
- return nil, olterrors.NewErrAdapter("device-update-failed", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return nil, olterrors.NewErrAdapter("device-update-failed", log.Fields{"device-id": dh.device.Id}, err)
}
return deviceInfo, nil
@@ -763,7 +763,7 @@
if err != nil {
return olterrors.NewErrNotFound("onu", log.Fields{
"interface-id": omciInd.IntfId,
- "onu-id": omciInd.OnuId}, err).Log()
+ "onu-id": omciInd.OnuId}, err)
}
deviceType = onuDevice.Type
deviceID = onuDevice.Id
@@ -786,7 +786,7 @@
"source": dh.deviceType,
"destination": deviceType,
"onu-id": deviceID,
- "proxy-device-id": proxyDeviceID}, err).Log()
+ "proxy-device-id": proxyDeviceID}, err)
}
return nil
}
@@ -809,8 +809,7 @@
omciMsg := &ic.InterAdapterOmciMessage{}
if err := ptypes.UnmarshalAny(msgBody, omciMsg); err != nil {
- log.Warnw("cannot-unmarshal-omci-msg-body", log.Fields{"error": err})
- return err
+ return olterrors.NewErrAdapter("cannot-unmarshal-omci-msg-body", log.Fields{"msgbody": msgBody}, err)
}
if omciMsg.GetProxyAddress() == nil {
@@ -818,25 +817,25 @@
if err != nil {
return olterrors.NewErrNotFound("onu", log.Fields{
"device-id": dh.device.Id,
- "onu-device-id": toDeviceID}, err).Log()
+ "onu-device-id": toDeviceID}, err)
}
log.Debugw("device retrieved from core", log.Fields{"msgID": msgID, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceID": toDeviceID, "proxyDeviceID": proxyDeviceID})
if err := dh.sendProxiedMessage(onuDevice, omciMsg); err != nil {
return olterrors.NewErrCommunication("send-failed", log.Fields{
"device-id": dh.device.Id,
- "onu-device-id": toDeviceID}, err).Log()
+ "onu-device-id": toDeviceID}, err)
}
} else {
log.Debugw("Proxy Address found in omci message", log.Fields{"msgID": msgID, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceID": toDeviceID, "proxyDeviceID": proxyDeviceID})
if err := dh.sendProxiedMessage(nil, omciMsg); err != nil {
return olterrors.NewErrCommunication("send-failed", log.Fields{
"device-id": dh.device.Id,
- "onu-device-id": toDeviceID}, err).Log()
+ "onu-device-id": toDeviceID}, err)
}
}
} else {
- return olterrors.NewErrInvalidValue(log.Fields{"inter-adapter-message-type": msg.Header.Type}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"inter-adapter-message-type": msg.Header.Type}, nil)
}
return nil
}
@@ -859,7 +858,7 @@
return olterrors.NewErrCommunication("unreachable", log.Fields{
"interface-id": intfID,
- "onu-id": onuID}, nil).Log()
+ "onu-id": onuID}, nil)
}
// TODO: Once we are sure openonu/openomci is sending only binary in omciMsg.Message, we can remove this check
@@ -884,7 +883,7 @@
return olterrors.NewErrCommunication("omci-send-failed", log.Fields{
"interface-id": intfID,
"onu-id": onuID,
- "message": omciMessage}, err).Log()
+ "message": omciMessage}, err)
}
log.Debugw("Sent Omci message", log.Fields{"intfID": intfID, "onuID": onuID, "omciMsg": hex.EncodeToString(omciMsg.Message)})
return nil
@@ -901,7 +900,7 @@
if st.Code() == codes.AlreadyExists {
log.Debug("ONU activation is in progress", log.Fields{"SerialNumber": serialNumber})
} else {
- return olterrors.NewErrAdapter("onu-activate-failed", log.Fields{"onu": Onu}, err).Log()
+ return olterrors.NewErrAdapter("onu-activate-failed", log.Fields{"onu": Onu}, err)
}
} else {
log.Infow("activated-onu", log.Fields{"SerialNumber": serialNumber})
@@ -920,7 +919,7 @@
if sn != "" {
kwargs["serial_number"] = sn
} else {
- return olterrors.NewErrInvalidValue(log.Fields{"serial-number": sn}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"serial-number": sn}, nil)
}
if _, loaded := dh.discOnus.LoadOrStore(sn, true); loaded {
@@ -945,7 +944,7 @@
case codes.DeadlineExceeded:
// if the call times out, cleanup and exit
dh.discOnus.Delete(sn)
- return olterrors.NewErrTimeout("get-child-device", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrTimeout("get-child-device", log.Fields{"device-id": dh.device.Id}, err)
}
}
}
@@ -965,9 +964,9 @@
// if we can't create an ID in resource manager,
// cleanup and exit
dh.discOnus.Delete(sn)
- return olterrors.NewErrAdapter("resource-manage-get-onu-id-failed", log.Fields{
+ return olterrors.NewErrAdapter("resource-manager-get-onu-id-failed", log.Fields{
"pon-interface-id": ponintfid,
- "serial-number": sn}, err).Log()
+ "serial-number": sn}, err)
}
if onuDevice, err = dh.coreProxy.ChildDeviceDetected(context.TODO(), dh.device.Id, int(parentPortNo),
@@ -976,7 +975,7 @@
dh.resourceMgr.FreeonuID(ctx, ponintfid, []uint32{onuID}) // NOTE I'm not sure this method is actually cleaning up the right thing
return olterrors.NewErrAdapter("core-proxy-child-device-detected-failed", log.Fields{
"pon-interface-id": ponintfid,
- "serial-number": sn}, err).Log()
+ "serial-number": sn}, err)
}
dh.eventMgr.OnuDiscoveryIndication(onuDiscInd, onuDevice.Id, onuID, sn, time.Now().UnixNano())
log.Infow("onu-child-device-added", log.Fields{"onuDevice": onuDevice, "sn": sn})
@@ -997,13 +996,13 @@
if err = dh.coreProxy.DeviceStateUpdate(ctx, onuDevice.Id, common.ConnectStatus_REACHABLE, common.OperStatus_DISCOVERED); err != nil {
return olterrors.NewErrAdapter("failed-to-update-device-state", log.Fields{
"device-id": onuDevice.Id,
- "serial-number": sn}, err).Log()
+ "serial-number": sn}, err)
}
log.Infow("onu-discovered-reachable", log.Fields{"deviceId": onuDevice.Id, "sn": sn})
if err = dh.activateONU(ctx, onuDiscInd.IntfId, int64(onuID), onuDiscInd.SerialNumber, sn); err != nil {
return olterrors.NewErrAdapter("onu-activation-failed", log.Fields{
"device-id": onuDevice.Id,
- "serial-number": sn}, err).Log()
+ "serial-number": sn}, err)
}
return nil
}
@@ -1043,7 +1042,7 @@
}
if err != nil || onuDevice == nil {
- return olterrors.NewErrNotFound("onu-device", errFields, err).Log()
+ return olterrors.NewErrNotFound("onu-device", errFields, err)
}
if onuDevice.ParentPortNo != ponPort {
@@ -1064,7 +1063,7 @@
}
if err := dh.updateOnuStates(onuDevice, onuInd); err != nil {
- return olterrors.NewErrCommunication("state-update-failed", errFields, err).Log()
+ return olterrors.NewErrCommunication("state-update-failed", errFields, err)
}
return nil
}
@@ -1091,7 +1090,7 @@
"onu-indicator": onuInd,
"source": "openolt",
"device-type": onuDevice.Type,
- "device-id": onuDevice.Id}, err).Log()
+ "device-id": onuDevice.Id}, err)
}
case "up":
log.Debugw("sending-interadapter-onu-indication", log.Fields{"onuIndication": onuInd, "DeviceId": onuDevice.Id, "operStatus": onuDevice.OperStatus, "adminStatus": onuDevice.AdminState})
@@ -1103,10 +1102,10 @@
"onu-indicator": onuInd,
"source": "openolt",
"device-type": onuDevice.Type,
- "device-id": onuDevice.Id}, err).Log()
+ "device-id": onuDevice.Id}, err)
}
default:
- return olterrors.NewErrInvalidValue(log.Fields{"oper-state": onuInd.OperState}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"oper-state": onuInd.OperState}, nil)
}
return nil
}
@@ -1153,9 +1152,9 @@
kwargs["parent_port_no"] = parentPort
onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
if err != nil {
- return nil, olterrors.NewErrNotFound("onu", log.Fields{
+ return nil, olterrors.NewErrNotFound("onu-device", log.Fields{
"interface-id": parentPort,
- "onu-id": onuID}, err).Log()
+ "onu-id": onuID}, err)
}
log.Debugw("Successfully received child device from core", log.Fields{"child_device": *onuDevice})
return onuDevice, nil
@@ -1175,7 +1174,7 @@
"destination": "core",
"device-id": dh.device.Id,
"logical-port": logicalPort,
- "packet": hex.EncodeToString(packetPayload)}, err).Log()
+ "packet": hex.EncodeToString(packetPayload)}, err)
}
log.Debugw("Sent packet-in to core successfully", log.Fields{
"packet": hex.EncodeToString(packetPayload),
@@ -1264,7 +1263,7 @@
dh.lockDevice.Lock()
dh.adminState = "up"
dh.lockDevice.Unlock()
- return olterrors.NewErrAdapter("olt-disable-failed", log.Fields{"device-id": device.Id}, err).Log()
+ return olterrors.NewErrAdapter("olt-disable-failed", log.Fields{"device-id": device.Id}, err)
}
}
}
@@ -1282,7 +1281,7 @@
if port.GetType() == voltha.Port_PON_OLT {
if err := dh.coreProxy.PortStateUpdate(context.TODO(), cloned.Id,
voltha.Port_PON_OLT, port.GetPortNo(), voltha.OperStatus_UNKNOWN); err != nil {
- return err
+ return olterrors.NewErrAdapter("port-state-update-failed", log.Fields{"device-id": device.Id, "port-number": port.GetPortNo()}, err)
}
}
}
@@ -1330,7 +1329,7 @@
dh.lockDevice.Lock()
dh.adminState = "down"
dh.lockDevice.Unlock()
- return olterrors.NewErrAdapter("olt-reenable-failed", log.Fields{"device-id": dh.device.Id}, err).Log()
+ return olterrors.NewErrAdapter("olt-reenable-failed", log.Fields{"device-id": dh.device.Id}, err)
}
}
log.Debug("olt-reenabled")
@@ -1339,7 +1338,7 @@
// Update the all ports state on that device to enable
if err := dh.disableAdminDownPorts(device); err != nil {
- return olterrors.NewErrAdapter("port-status-update-failed-after-olt-reenable", log.Fields{"device": device}, err).Log()
+ return olterrors.NewErrAdapter("port-status-update-failed-after-olt-reenable", log.Fields{"device": device}, err)
}
//Update the device oper status as ACTIVE
cloned.OperStatus = voltha.OperStatus_ACTIVE
@@ -1349,7 +1348,7 @@
return olterrors.NewErrAdapter("state-update-failed", log.Fields{
"device-id": device.Id,
"connect-status": cloned.ConnectStatus,
- "oper-status": cloned.OperStatus}, err).Log()
+ "oper-status": cloned.OperStatus}, err)
}
log.Debugw("ReEnableDevice-end", log.Fields{"deviceID": device.Id})
@@ -1400,12 +1399,12 @@
nniOnuID := -1
if dh.resourceMgr == nil {
- return fmt.Errorf("no resource manager for deviceID %s", dh.deviceID)
+ return olterrors.NewErrNotFound("resource-manager", log.Fields{"device-id": dh.deviceID}, nil)
}
//Free the flow-ids for the NNI port
nni, err := dh.resourceMgr.GetNNIFromKVStore(ctx)
if err != nil {
- return olterrors.NewErrPersistence("get", "nni", 0, nil, err).Log()
+ return olterrors.NewErrPersistence("get", "nni", 0, nil, err)
}
log.Debugw("NNI are ", log.Fields{"nni": nni})
for _, nniIntfID := range nni {
@@ -1417,7 +1416,7 @@
dh.resourceMgr.RemoveResourceMap(ctx, nniIntfID, int32(nniOnuID), int32(nniUniID))
}
if err = dh.resourceMgr.DelNNiFromKVStore(ctx); err != nil {
- return olterrors.NewErrPersistence("clear", "nni", 0, nil, err).Log()
+ return olterrors.NewErrPersistence("clear", "nni", 0, nil, err)
}
return nil
}
@@ -1445,7 +1444,7 @@
if err != nil {
return olterrors.NewErrNotFound("onu", log.Fields{
"device-id": dh.device.Id,
- "pon-port": ponPort}, err).Log()
+ "pon-port": ponPort}, err)
}
for _, onu := range onuGemData {
onuID := make([]uint32, 1)
@@ -1492,7 +1491,7 @@
//Reset the state
if dh.Client != nil {
if _, err := dh.Client.Reboot(ctx, new(oop.Empty)); err != nil {
- return olterrors.NewErrAdapter("olt-reboot-failed", log.Fields{"device-id": dh.deviceID}, err).Log()
+ return olterrors.NewErrAdapter("olt-reboot-failed", log.Fields{"device-id": dh.deviceID}, err)
}
}
cloned := proto.Clone(device).(*voltha.Device)
@@ -1502,7 +1501,7 @@
return olterrors.NewErrAdapter("device-state-update-failed", log.Fields{
"device-id": device.Id,
"connect-status": cloned.ConnectStatus,
- "oper-status": cloned.OperStatus}, err).Log()
+ "oper-status": cloned.OperStatus}, err)
}
return nil
}
@@ -1510,7 +1509,7 @@
//RebootDevice reboots the given device
func (dh *DeviceHandler) RebootDevice(device *voltha.Device) error {
if _, err := dh.Client.Reboot(context.Background(), new(oop.Empty)); err != nil {
- return olterrors.NewErrAdapter("olt-reboot-failed", log.Fields{"device-id": dh.deviceID}, err).Log()
+ return olterrors.NewErrAdapter("olt-reboot-failed", log.Fields{"device-id": dh.deviceID}, err)
}
log.Debugw("rebooted-device-successfully", log.Fields{"deviceID": device.Id})
return nil
@@ -1523,7 +1522,7 @@
})
logicalPortNum, err := dh.flowMgr.GetLogicalPortFromPacketIn(ctx, packetIn)
if err != nil {
- return olterrors.NewErrNotFound("logical-port", log.Fields{"packet": hex.EncodeToString(packetIn.Pkt)}, err).Log()
+ return olterrors.NewErrNotFound("logical-port", log.Fields{"packet": hex.EncodeToString(packetIn.Pkt)}, err)
}
log.Debugw("sending packet-in to core", log.Fields{
"logicalPortNum": logicalPortNum,
@@ -1533,7 +1532,7 @@
return olterrors.NewErrCommunication("send-packet-in", log.Fields{
"destination": "core",
"source": dh.deviceType,
- "packet": hex.EncodeToString(packetIn.Pkt)}, err).Log()
+ "packet": hex.EncodeToString(packetIn.Pkt)}, err)
}
log.Debugw("Success sending packet-in to core!", log.Fields{
"packet": hex.EncodeToString(packetIn.Pkt),
@@ -1604,12 +1603,12 @@
"oni-id": onuID,
"uni-id": uniID,
"gem-port-id": gemPortID,
- "packet": hex.EncodeToString(packet.Data)}, err).Log()
+ "packet": hex.EncodeToString(packet.Data)}, err)
}
} else if egressPortType == voltha.Port_ETHERNET_NNI {
nniIntfID, err := IntfIDFromNniPortNum(uint32(egressPortNo))
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"egress-nni-port": egressPortNo}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"egress-nni-port": egressPortNo}, err)
}
uplinkPkt := oop.UplinkPacket{IntfId: nniIntfID, Pkt: packet.Data}
@@ -1619,7 +1618,7 @@
})
if _, err := dh.Client.UplinkPacketOut(ctx, &uplinkPkt); err != nil {
- return olterrors.NewErrCommunication("packet-out-to-nni", log.Fields{"packet": hex.EncodeToString(packet.Data)}, err).Log()
+ return olterrors.NewErrCommunication("packet-out-to-nni", log.Fields{"packet": hex.EncodeToString(packet.Data)}, err)
}
} else {
log.Warnw("Packet-out-to-this-interface-type-not-implemented", log.Fields{
@@ -1705,7 +1704,7 @@
log.Fields{"Device": dh.device, "port": port})
return olterrors.NewErrAdapter("illegal-port-request", log.Fields{
"port-type": port.GetType,
- "enable-state": enablePort}, nil).Log()
+ "enable-state": enablePort}, nil)
}
// fetch interfaceid from PortNo
ponID := PortNoToIntfID(port.GetPortNo(), voltha.Port_PON_OLT)
@@ -1718,7 +1717,7 @@
if err != nil {
return olterrors.NewErrAdapter("pon-port-enable-failed", log.Fields{
"device-id": dh.device.Id,
- "port": port}, err).Log()
+ "port": port}, err)
}
// updating interface local cache for collecting stats
dh.activePorts.Store(ponID, true)
@@ -1729,7 +1728,7 @@
if err != nil {
return olterrors.NewErrAdapter("pon-port-disable-failed", log.Fields{
"device-id": dh.device.Id,
- "port": port}, err).Log()
+ "port": port}, err)
}
// updating interface local cache for collecting stats
dh.activePorts.Store(ponID, false)
@@ -1738,7 +1737,7 @@
if err := dh.coreProxy.PortStateUpdate(ctx, dh.deviceID, voltha.Port_PON_OLT, port.PortNo, operStatus); err != nil {
return olterrors.NewErrAdapter("port-state-update-failed", log.Fields{
"device-id": dh.deviceID,
- "port": port.PortNo}, err).Log()
+ "port": port.PortNo}, err)
}
return nil
}
@@ -1753,7 +1752,7 @@
if err := dh.DisablePort(port); err != nil {
return olterrors.NewErrAdapter("port-disable-failed", log.Fields{
"device-id": dh.deviceID,
- "port": port}, err).Log()
+ "port": port}, err)
}
}
}
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index 8ad7c75..3b27643 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -131,8 +131,7 @@
deviceTopic := kafka.Topic{Name: defaultTopic.Name + "_" + device.Id}
// TODO for the offset
if err := oo.kafkaICProxy.SubscribeWithDefaultRequestHandler(deviceTopic, 0); err != nil {
- log.Infow("create-device-topic-failed", log.Fields{"deviceId": device.Id, "error": err})
- return err
+ return olterrors.NewErrAdapter("subscribe-for-device-topic-failed", log.Fields{"device-topic": deviceTopic}, err)
}
return nil
}
@@ -161,7 +160,7 @@
if handler := oo.getDeviceHandler(device.Id); handler != nil {
return handler.GetOfpDeviceInfo(device)
}
- return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil).Log()
+ return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
}
//Get_ofp_port_info returns OFP port information for the given device
@@ -170,7 +169,7 @@
if handler := oo.getDeviceHandler(device.Id); handler != nil {
return handler.GetOfpPortInfo(device, portNo)
}
- return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil).Log()
+ return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
}
//Process_inter_adapter_message sends messages to a target device (between adapters)
@@ -184,7 +183,7 @@
if handler := oo.getDeviceHandler(targetDevice); handler != nil {
return handler.ProcessInterAdapterMessage(msg)
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": targetDevice}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": targetDevice}, nil)
}
//Adapter_descriptor not implemented
@@ -206,7 +205,7 @@
func (oo *OpenOLT) Reconcile_device(device *voltha.Device) error {
ctx := context.Background()
if device == nil {
- return olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
}
log.Infow("reconcile-device", log.Fields{"deviceId": device.Id})
var handler *DeviceHandler
@@ -230,7 +229,7 @@
if handler := oo.getDeviceHandler(device.Id); handler != nil {
return handler.DisableDevice(device)
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
}
//Reenable_device enables the olt device after disable
@@ -239,7 +238,7 @@
if handler := oo.getDeviceHandler(device.Id); handler != nil {
return handler.ReenableDevice(device)
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
}
//Reboot_device reboots the given device
@@ -248,7 +247,7 @@
if handler := oo.getDeviceHandler(device.Id); handler != nil {
return handler.RebootDevice(device)
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
}
//Self_test_device unimplented
@@ -267,7 +266,7 @@
oo.deleteDeviceHandlerToMap(handler)
return nil
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
}
//Get_device_details unimplemented
@@ -287,7 +286,7 @@
if handler := oo.getDeviceHandler(device.Id); handler != nil {
return handler.UpdateFlowsIncrementally(ctx, device, flows, groups, flowMetadata)
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
}
//Update_pm_config returns PmConfigs nil or error
@@ -302,7 +301,7 @@
if handler := oo.getDeviceHandler(deviceID); handler != nil {
return handler.PacketOut(ctx, egressPortNo, packet)
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": deviceID}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": deviceID}, nil)
}
//Suppress_event unimplemented
@@ -359,19 +358,17 @@
return olterrors.NewErrInvalidValue(log.Fields{
"reason": "port cannot be nil",
"device-id": deviceID,
- "port": nil}, nil).Log()
+ "port": nil}, nil)
}
if handler := oo.getDeviceHandler(deviceID); handler != nil {
log.Debugw("Enable_Disable_Port", log.Fields{"deviceId": deviceID, "port": port})
if enablePort {
if err := handler.EnablePort(port); err != nil {
- log.Errorw("error-occurred-during-enable-port", log.Fields{"deviceID": deviceID, "port": port, "error": err})
- return err
+ return olterrors.NewErrAdapter("error-occurred-during-enable-port", log.Fields{"deviceID": deviceID, "port": port}, err)
}
} else {
if err := handler.DisablePort(port); err != nil {
- log.Errorw("error-occurred-during-disable-port", log.Fields{"Device": deviceID, "port": port})
- return err
+ return olterrors.NewErrAdapter("error-occurred-during-disable-port", log.Fields{"deviceID": deviceID, "port": port}, err)
}
}
}
diff --git a/internal/pkg/core/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
index 873bc44..a44d639 100644
--- a/internal/pkg/core/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -180,8 +180,7 @@
}
/* Send event to KAFKA */
if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil {
- log.Errorw("Failed to send OLT event", log.Fields{"err": err})
- return err
+ return olterrors.NewErrCommunication("send-olt-event", log.Fields{"device-id": deviceID}, err)
}
log.Infow("OLT UpDown event sent to KAFKA", log.Fields{})
return nil
@@ -201,8 +200,7 @@
de.DeviceEventName = fmt.Sprintf("%s_%s", onuDiscoveryEvent, "RAISE_EVENT")
/* Send event to KAFKA */
if err := em.eventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil {
- log.Errorw("Failed to send ONU discovery event", log.Fields{"serial-number": serialNumber, "intf-id": onuDisc.IntfId})
- return err
+ return olterrors.NewErrCommunication("send-onu-discovery-event", log.Fields{"serial-number": serialNumber, "intf-id": onuDisc.IntfId}, err)
}
log.Infow("ONU discovery event sent to KAFKA", log.Fields{"serial-number": serialNumber, "intf-id": onuDisc.IntfId})
return nil
@@ -471,6 +469,7 @@
device, err := em.handler.coreProxy.GetDevice(ctx.Background(), deviceID, deviceID)
if err != nil {
log.Errorw("Error while fetching Device object", log.Fields{"DeviceId": deviceID})
+ return
}
for _, port := range device.Ports {
if port.PortNo == portID {
@@ -495,7 +494,7 @@
}
/* Send event to KAFKA */
if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil {
- log.Errorw("failed-to-send-olt-intf-oper-status-event", log.Fields{"err": err})
+ olterrors.NewErrCommunication("send-olt-intf-oper-status-event", log.Fields{"device-id": deviceID, "intf-id": ifindication.IntfId, "oper-state": ifindication.OperState}, err).Log()
}
log.Info("sent-olt-intf-oper-status-event-to-kafka")
}
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index dd33760..b229f82 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -22,7 +22,6 @@
"crypto/md5"
"encoding/hex"
"encoding/json"
- "errors"
"fmt"
"math/big"
"strings"
@@ -236,7 +235,7 @@
flowMgr.resourceMgr = rMgr
flowMgr.techprofile = make(map[uint32]tp.TechProfileIf)
if err = flowMgr.populateTechProfilePerPonPort(); err != nil {
- log.Error("Error while populating tech profile mgr\n")
+ log.Errorw("Error while populating tech profile mgr", log.Fields{"error": err})
return nil
}
flowMgr.onuIdsLock = sync.RWMutex{}
@@ -358,9 +357,9 @@
var SchedCfg *tp_pb.SchedulerConfig
KvStoreMeter, err := f.resourceMgr.GetMeterIDForOnu(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID)
if err != nil {
- log.Error("Failed to get meter for intf %d, onuid %d, uniid %d", sq.intfID, sq.onuID, sq.uniID)
- return err
+ return olterrors.NewErrNotFound("meter", log.Fields{"intfId": sq.intfID, "onuId": sq.onuID, "uniId": sq.uniID}, err)
}
+
if KvStoreMeter != nil {
if KvStoreMeter.MeterId == sq.meterID {
log.Debug("Scheduler already created for upstream")
@@ -369,7 +368,7 @@
return olterrors.NewErrInvalidValue(log.Fields{
"unsupported": "meter-id",
"kv-store-meter-id": KvStoreMeter.MeterId,
- "meter-id-in-flow": sq.meterID}, nil).Log()
+ "meter-id-in-flow": sq.meterID}, nil)
}
log.Debugw("Meter-does-not-exist-Creating-new", log.Fields{"MeterID": sq.meterID, "Direction": Direction})
@@ -381,8 +380,7 @@
}
if err != nil {
- log.Errorw("Unable to get Scheduler config", log.Fields{"IntfID": sq.intfID, "Direction": sq.direction, "Error": err})
- return err
+ return olterrors.NewErrNotFound("scheduler-config", log.Fields{"IntfID": sq.intfID, "Direction": sq.direction, "tpInst": sq.tpInst}, err)
}
var meterConfig *ofp.OfpMeterConfig
@@ -401,14 +399,14 @@
return olterrors.NewErrNotFound("meterbands", log.Fields{
"reason": "Could-not-get-meterbands-from-flowMetadata",
"flow-metadata": sq.flowMetadata,
- "meter-id": sq.meterID}, nil).Log()
+ "meter-id": sq.meterID}, nil)
} else if len(meterConfig.Bands) < MaxMeterBand {
log.Errorw("Invalid-number-of-bands-in-meter", log.Fields{"Bands": meterConfig.Bands, "MeterID": sq.meterID})
return olterrors.NewErrInvalidValue(log.Fields{
"reason": "Invalid-number-of-bands-in-meter",
"meterband-count": len(meterConfig.Bands),
"metabands": meterConfig.Bands,
- "meter-id": sq.meterID}, nil).Log()
+ "meter-id": sq.meterID}, nil)
}
cir := meterConfig.Bands[0].Rate
cbs := meterConfig.Bands[0].BurstSize
@@ -421,16 +419,14 @@
TrafficSched := []*tp_pb.TrafficScheduler{f.techprofile[sq.intfID].GetTrafficScheduler(sq.tpInst, SchedCfg, TrafficShaping)}
if err := f.pushSchedulerQueuesToDevice(ctx, sq, TrafficShaping, TrafficSched); err != nil {
- log.Errorw("Failed to push traffic scheduler and queues to device", log.Fields{"intfID": sq.intfID, "direction": sq.direction})
- return err
+ return olterrors.NewErrAdapter("failure-pushing-traffic-scheduler-and-queues-to-device", log.Fields{"intfID": sq.intfID, "direction": sq.direction}, err)
}
/* After we successfully applied the scheduler configuration on the OLT device,
* store the meter id on the KV store, for further reference.
*/
if err := f.resourceMgr.UpdateMeterIDForOnu(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID, meterConfig); err != nil {
- log.Error("Failed to update meter id for onu %d, meterid %d", sq.onuID, sq.meterID)
- return err
+ return olterrors.NewErrAdapter("failed-updating-meter-id", log.Fields{"onu-id": sq.onuID, "meter-id": sq.meterID}, err)
}
log.Debugw("updated-meter-info into KV store successfully", log.Fields{"Direction": Direction,
"Meter": meterConfig})
@@ -442,8 +438,7 @@
trafficQueues, err := f.techprofile[sq.intfID].GetTrafficQueues(sq.tpInst, sq.direction)
if err != nil {
- log.Errorw("Unable to construct traffic queue configuration", log.Fields{"intfID": sq.intfID, "direction": sq.direction})
- return err
+ return olterrors.NewErrAdapter("unable-to-construct-traffic-queue-configuration", log.Fields{"intfID": sq.intfID, "direction": sq.direction}, err)
}
log.Debugw("Sending Traffic scheduler create to device", log.Fields{"Direction": sq.direction, "TrafficScheds": TrafficSched})
@@ -451,8 +446,7 @@
IntfId: sq.intfID, OnuId: sq.onuID,
UniId: sq.uniID, PortNo: sq.uniPort,
TrafficScheds: TrafficSched}); err != nil {
- log.Errorw("Failed to create traffic schedulers", log.Fields{"error": err})
- return err
+ return olterrors.NewErrAdapter("failed-to-create-traffic-schedulers-in-device", log.Fields{"TrafficScheds": TrafficSched}, err)
}
// On receiving the CreateTrafficQueues request, the driver should create corresponding
@@ -462,8 +456,7 @@
&tp_pb.TrafficQueues{IntfId: sq.intfID, OnuId: sq.onuID,
UniId: sq.uniID, PortNo: sq.uniPort,
TrafficQueues: trafficQueues}); err != nil {
- log.Errorw("Failed to create traffic queues in device", log.Fields{"error": err})
- return err
+ return olterrors.NewErrAdapter("failed-to-create-traffic-queues-in-device", log.Fields{"TrafficQueues": trafficQueues}, err)
}
if sq.direction == tp_pb.Direction_DOWNSTREAM {
@@ -505,14 +498,12 @@
}
if err != nil {
- log.Errorw("Unable to get Scheduler config", log.Fields{"IntID": sq.intfID, "Direction": sq.direction, "Error": err})
- return err
+ return olterrors.NewErrNotFound("scheduler-config", log.Fields{"IntID": sq.intfID, "Direction": sq.direction}, err)
}
KVStoreMeter, err := f.resourceMgr.GetMeterIDForOnu(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID)
if err != nil {
- log.Errorf("Failed to get Meter for Onu %d", sq.onuID)
- return err
+ return olterrors.NewErrNotFound("meter", log.Fields{"onuID": sq.onuID}, err)
}
if KVStoreMeter == nil {
log.Debugw("No-meter-has-been-installed-yet", log.Fields{"direction": Direction, "IntfID": sq.intfID, "OnuID": sq.onuID, "UniID": sq.uniID})
@@ -531,24 +522,23 @@
TrafficQueues, err := f.techprofile[sq.intfID].GetTrafficQueues(sq.tpInst, sq.direction)
if err != nil {
- log.Errorw("Unable to construct traffic queue configuration", log.Fields{"intfID": sq.intfID, "direction": sq.direction})
- return err
+ return olterrors.NewErrAdapter("unable-to-construct-traffic-queue-configuration", log.Fields{"intfID": sq.intfID, "direction": sq.direction}, err)
}
if _, err = f.deviceHandler.Client.RemoveTrafficQueues(ctx,
&tp_pb.TrafficQueues{IntfId: sq.intfID, OnuId: sq.onuID,
UniId: sq.uniID, PortNo: sq.uniPort,
TrafficQueues: TrafficQueues}); err != nil {
- log.Errorw("Failed to remove traffic queues", log.Fields{"error": err})
- return err
+ return olterrors.NewErrAdapter("unable-to-remove-traffic-queues-from-device",
+ log.Fields{"intfID": sq.intfID, "TrafficQueues": TrafficQueues}, err)
}
log.Debug("Removed traffic queues successfully")
if _, err = f.deviceHandler.Client.RemoveTrafficSchedulers(ctx, &tp_pb.TrafficSchedulers{
IntfId: sq.intfID, OnuId: sq.onuID,
UniId: sq.uniID, PortNo: sq.uniPort,
TrafficScheds: TrafficSched}); err != nil {
- log.Errorw("failed to remove traffic schedulers", log.Fields{"error": err})
- return err
+ return olterrors.NewErrAdapter("unable-to-remove-traffic-schedulers-from-device",
+ log.Fields{"intfID": sq.intfID, "TrafficSchedulers": TrafficSched}, err)
}
log.Debug("Removed traffic schedulers successfully")
@@ -558,8 +548,7 @@
*/
err = f.resourceMgr.RemoveMeterIDForOnu(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID)
if err != nil {
- log.Errorf("Failed to remove meter for onu %d, meter id %d", sq.onuID, KVStoreMeter.MeterId)
- return err
+ return olterrors.NewErrAdapter("unable-to-remove-meter", log.Fields{"onu": sq.onuID, "meter": KVStoreMeter.MeterId}, err)
}
log.Debugw("Removed-meter-from-KV-store successfully", log.Fields{"MeterId": KVStoreMeter.MeterId, "dir": Direction})
return err
@@ -666,7 +655,7 @@
return olterrors.NewErrInvalidValue(log.Fields{
"reason": "TP count does not match number of PON ports",
"tech-profile-count": tpCount,
- "pon-port-count": f.resourceMgr.DevInfo.GetPonPorts()}, nil).Log()
+ "pon-port-count": f.resourceMgr.DevInfo.GetPonPorts()}, nil)
}
log.Infow("Populated techprofile for ponports successfully",
log.Fields{"numofTech": tpCount, "numPonPorts": f.resourceMgr.DevInfo.GetPonPorts()})
@@ -1072,7 +1061,7 @@
case DoubleTag:
case Untagged:
default:
- return nil, olterrors.NewErrInvalidValue(log.Fields{"packet-tag-type": pktTagType}, nil).Log()
+ return nil, olterrors.NewErrInvalidValue(log.Fields{"packet-tag-type": pktTagType}, nil)
}
}
return &classifier, nil
@@ -1091,7 +1080,7 @@
} else if _, ok := actionInfo[TrapToHost]; ok {
action.Cmd.TrapToHost = actionInfo[TrapToHost].(bool)
} else {
- return nil, olterrors.NewErrInvalidValue(log.Fields{"action-command": actionInfo}, nil).Log()
+ return nil, olterrors.NewErrInvalidValue(log.Fields{"action-command": actionInfo}, nil)
}
return &action, nil
}
@@ -1106,7 +1095,7 @@
uniPortName := fmt.Sprintf("pon-{%d}/onu-{%d}/uni-{%d}", intfID, onuID, uniID)
for _, tpID := range tpIDList {
if err := f.DeleteTechProfileInstance(ctx, intfID, onuID, uniID, uniPortName, tpID); err != nil {
- log.Debugw("Failed-to-delete-tp-instance-from-kv-store", log.Fields{"tp-id": tpID, "uni-port-name": uniPortName})
+ olterrors.NewErrAdapter("delete-tech-profile-failed", nil, err).Log()
// return err
// We should continue to delete tech-profile instances for other TP IDs
}
@@ -1120,8 +1109,7 @@
uniPortName = fmt.Sprintf("pon-{%d}/onu-{%d}/uni-{%d}", intfID, onuID, uniID)
}
if err := f.techprofile[intfID].DeleteTechProfileInstance(ctx, tpID, uniPortName); err != nil {
- log.Debugw("Failed-to-delete-tp-instance-from-kv-store", log.Fields{"tp-id": tpID, "uni-port-name": uniPortName})
- return err
+ return olterrors.NewErrAdapter("failed-to-delete-tp-instance-from-kv-store", log.Fields{"tp-id": tpID, "uni-port-name": uniPortName}, err)
}
return nil
}
@@ -1254,8 +1242,7 @@
//Assume the flow is removed
return nil
}
- log.Errorw("Failed to Remove flow from device", log.Fields{"err": err, "deviceFlow": deviceFlow})
- return err
+ return olterrors.NewErrFlowOp("remove", deviceFlow.FlowId, log.Fields{"deviceFlow": deviceFlow}, err)
}
log.Debugw("Flow removed from device successfully ", log.Fields{"flow": *deviceFlow})
@@ -1325,16 +1312,16 @@
"uni-id": uniID,
"gem-port-id": gemPortID,
"cookie": flowStoreCookie},
- err).Log()
+ err)
}
classifierProto, err := makeOpenOltClassifierField(classifierInfo)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifierInfo}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifierInfo}, err)
}
log.Debugw("Created classifier proto", log.Fields{"classifier": *classifierProto})
actionProto, err := makeOpenOltActionField(actionInfo)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"action": actionInfo}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"action": actionInfo}, err)
}
log.Debugw("Created action proto", log.Fields{"action": *actionProto})
@@ -1351,7 +1338,7 @@
Cookie: flow.Cookie,
PortNo: portNo}
if err := f.addFlowToDevice(ctx, flow, &downstreamflow); err != nil {
- return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": downstreamflow}, err).Log()
+ return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": downstreamflow}, err)
}
log.Debug("LLDP trap on NNI flow added to device successfully")
flowsToKVStore := f.getUpdatedFlowInfo(ctx, &downstreamflow, flowStoreCookie, "", flowID, flow.Id)
@@ -1359,7 +1346,7 @@
int32(onuID),
int32(uniID),
flowID, flowsToKVStore); err != nil {
- return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": downstreamflow}, err).Log()
+ return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": downstreamflow}, err)
}
return nil
}
@@ -1377,7 +1364,7 @@
return nil, olterrors.NewErrNotFound("onu", log.Fields{
"interface-id": parentPortNo,
"onu-id": onuID},
- err).Log()
+ err)
}
log.Debugw("Successfully received child device from core", log.Fields{"child_device": *onuDevice})
return onuDevice, nil
@@ -1402,8 +1389,7 @@
func (f *OpenOltFlowMgr) sendDeleteGemPortToChild(intfID uint32, onuID uint32, uniID uint32, gemPortID uint32, tpPath string) error {
onuDevice, err := f.getOnuChildDevice(intfID, onuID)
if err != nil {
- log.Errorw("error fetching child device from core", log.Fields{"onuId": onuID})
- return err
+ return olterrors.NewErrNotFound("onu-child-device", log.Fields{"onuId": onuID, "intfID": intfID}, err)
}
delGemPortMsg := &ic.InterAdapterDeleteGemPortMessage{UniId: uniID, TpPath: tpPath, GemPortId: gemPortID}
@@ -1415,10 +1401,9 @@
onuDevice.Type,
onuDevice.Id,
onuDevice.ProxyAddress.DeviceId, ""); sendErr != nil {
- log.Errorw("failure sending del gem port to onu adapter", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
+ return olterrors.NewErrCommunication("send-delete-gem-port-to-onu-adapter", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
"toAdapter": onuDevice.Type, "onuId": onuDevice.Id,
- "proxyDeviceId": onuDevice.ProxyAddress.DeviceId})
- return sendErr
+ "proxyDeviceId": onuDevice.ProxyAddress.DeviceId}, sendErr)
}
log.Debugw("success sending del gem port to onu adapter", log.Fields{"msg": delGemPortMsg})
return nil
@@ -1427,8 +1412,7 @@
func (f *OpenOltFlowMgr) sendDeleteTcontToChild(intfID uint32, onuID uint32, uniID uint32, allocID uint32, tpPath string) error {
onuDevice, err := f.getOnuChildDevice(intfID, onuID)
if err != nil {
- log.Errorw("error fetching child device from core", log.Fields{"onuId": onuID})
- return err
+ return olterrors.NewErrNotFound("onu-child-device", log.Fields{"onuId": onuID, "intfID": intfID}, err)
}
delTcontMsg := &ic.InterAdapterDeleteTcontMessage{UniId: uniID, TpPath: tpPath, AllocId: allocID}
@@ -1440,10 +1424,9 @@
onuDevice.Type,
onuDevice.Id,
onuDevice.ProxyAddress.DeviceId, ""); sendErr != nil {
- log.Errorw("failure sending del tcont to onu adapter", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
+ return olterrors.NewErrCommunication("send-delete-tcont-to-onu-adapter", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
"toAdapter": onuDevice.Type, "onuId": onuDevice.Id,
- "proxyDeviceId": onuDevice.ProxyAddress.DeviceId})
- return sendErr
+ "proxyDeviceId": onuDevice.ProxyAddress.DeviceId}, sendErr)
}
log.Debugw("success sending del tcont to onu adapter", log.Fields{"msg": delTcontMsg})
return nil
@@ -1504,8 +1487,7 @@
tpID, err := getTpIDFromFlow(flow)
if err != nil {
- log.Error("metadata-is-not-present-invalid-flow-to-process", log.Fields{"pon": Intf, "onuID": onuID, "uniID": uniID})
- return err
+ return olterrors.NewErrNotFound("tpid", log.Fields{"flow": flow, "pon": Intf, "onuID": onuID, "uniID": uniID}, err)
}
if len(updatedFlows) >= 0 {
@@ -1513,7 +1495,9 @@
// So the flow should not be freed yet.
// For ex: Case of HSIA where same flow is shared
// between DS and US.
- f.updateFlowInfoToKVStore(ctx, int32(Intf), int32(onuID), int32(uniID), flowID, &updatedFlows)
+ if err := f.updateFlowInfoToKVStore(ctx, int32(Intf), int32(onuID), int32(uniID), flowID, &updatedFlows); err != nil {
+ olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": updatedFlows}, err).Log()
+ }
if len(updatedFlows) == 0 {
// Do this for subscriber flows only (not trap from NNI flows)
if onuID != -1 && uniID != -1 {
@@ -1539,13 +1523,8 @@
tpPath := f.getTPpath(Intf, uni, tpID)
log.Debugw("Getting-techprofile-instance-for-subscriber", log.Fields{"TP-PATH": tpPath})
techprofileInst, err := f.techprofile[Intf].GetTPInstanceFromKVStore(ctx, tpID, tpPath)
- if err != nil { // This should not happen, something wrong in KV backend transaction
- log.Errorw("Error in fetching tech profile instance from KV store", log.Fields{"tpID": 20, "path": tpPath})
- return err
- }
- if techprofileInst == nil {
- log.Errorw("Tech-profile-instance-does-not-exist-in-KV Store", log.Fields{"tpPath": tpPath})
- return err
+ if err != nil || techprofileInst == nil { // This should not happen, something wrong in KV backend transaction
+ return olterrors.NewErrNotFound("tech-profile-in-kv-store", log.Fields{"tpID": tpID, "path": tpPath}, err)
}
gemPK := gemPortKey{Intf, uint32(gemPortID)}
@@ -1870,8 +1849,7 @@
TpID, err := getTpIDFromFlow(flow)
if err != nil {
- log.Error("metadata-is-not-present-invalid-flow-to-process", log.Fields{"pon": intfID, "onuID": onuID, "uniID": uniID})
- return fmt.Errorf("metadata-is-not-present-invalid-flow-to-process, pon:%v, onuID:%v, uniID:%v", intfID, onuID, uniID)
+ return olterrors.NewErrNotFound("tpid-for-flow", log.Fields{"flow": flow, "pon": IntfID, "onuID": onuID, "uniID": uniID}, err)
}
log.Debugw("TPID for this subcriber", log.Fields{"TpId": TpID, "pon": intfID, "onuID": onuID, "uniID": uniID})
if IsUpstream(actionInfo[Output].(uint32)) {
@@ -1896,8 +1874,7 @@
f.divideAndAddFlow(ctx, intfID, onuID, uniID, portNo, classifierInfo, actionInfo, flow, uint32(TpID), UsMeterID, DsMeterID, flowMetadata)
case <-time.After(10 * time.Second):
- log.Errorw("pending-flow-deletes-not-completed-after-timeout", log.Fields{"pon": intfID, "onuID": onuID, "uniID": uniID})
- return fmt.Errorf("pending-flow-deletes-not-completed-after-timeout, pon:%v, onuID:%v, uniID:%v", intfID, onuID, uniID)
+ return olterrors.NewErrTimeout("pending-flow-deletes", log.Fields{"pon": intfID, "onuID": onuID, "uniID": uniID}, nil)
}
}
return nil
@@ -1910,7 +1887,7 @@
inPort, err := f.getInPortOfMulticastFlow(ctx, classifierInfo)
if err != nil {
- return olterrors.NewErrNotFound("multicast-in-port", log.Fields{"classifier": classifierInfo}, err).Log()
+ return olterrors.NewErrNotFound("multicast-in-port", log.Fields{"classifier": classifierInfo}, err)
}
//this variable acts like a switch. When it is set, multicast flows are classified by eth_dst.
//otherwise, classification is based on ipv4_dst by default.
@@ -1936,7 +1913,7 @@
networkInterfaceID, err := IntfIDFromNniPortNum(inPort)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"nni-in-port-number": inPort}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"nni-in-port-number": inPort}, err)
}
flowStoreCookie := getFlowStoreCookie(classifierInfo, uint32(0))
@@ -1952,11 +1929,11 @@
"uni-id": uniID,
"gem-port-id": gemPortID,
"cookie": flowStoreCookie},
- err).Log()
+ err)
}
classifierProto, err := makeOpenOltClassifierField(classifierInfo)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifierInfo}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifierInfo}, err)
}
groupID := actionInfo[GroupID].(uint32)
multicastFlow := openoltpb2.Flow{
@@ -1969,7 +1946,7 @@
Cookie: flow.Cookie}
if err = f.addFlowToDevice(ctx, flow, &multicastFlow); err != nil {
- return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": multicastFlow}, err).Log()
+ return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": multicastFlow}, err)
}
log.Debug("multicast flow added to device successfully")
//get cached group
@@ -1980,7 +1957,7 @@
//cached group can be removed now
f.resourceMgr.RemoveFlowGroupFromKVStore(ctx, groupID, true)
} else {
- return olterrors.NewErrGroupOp("modify", groupID, log.Fields{"group": group}, err).Log()
+ return olterrors.NewErrGroupOp("modify", groupID, log.Fields{"group": group}, err)
}
}
@@ -1989,7 +1966,7 @@
int32(onuID),
int32(uniID),
flowID, flowsToKVStore); err != nil {
- return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": multicastFlow}, err).Log()
+ return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": multicastFlow}, err)
}
return nil
}
@@ -2011,8 +1988,7 @@
func (f *OpenOltFlowMgr) AddGroup(ctx context.Context, group *ofp.OfpGroupEntry) error {
log.Infow("add-group", log.Fields{"group": group})
if group == nil {
- log.Warn("skipping nil group")
- return errors.New("group is nil")
+ return olterrors.NewErrInvalidValue(log.Fields{"group": group}, nil)
}
groupToOlt := openoltpb2.Group{
@@ -2024,13 +2000,11 @@
log.Debugw("Sending group to device", log.Fields{"groupToOlt": groupToOlt})
_, err := f.deviceHandler.Client.PerformGroupOperation(ctx, &groupToOlt)
if err != nil {
- log.Errorw("add-group operation failed", log.Fields{"err": err, "groupToOlt": groupToOlt})
- return fmt.Errorf("add-group operation failed, err %v, groupToOlt %v", err, groupToOlt)
+ return olterrors.NewErrAdapter("add-group-operation-failed", log.Fields{"groupToOlt": groupToOlt}, err)
}
// group members not created yet. So let's store the group
if err := f.resourceMgr.AddFlowGroupToKVStore(ctx, group, true); err != nil {
- log.Errorw("Group cannot be stored in KV store", log.Fields{"groupId": group.Desc.GroupId, "err": err})
- return fmt.Errorf("group cannot be stored in KV store, groupId %v, err %v", group.Desc.GroupId, err)
+ return olterrors.NewErrPersistence("add", "flow-group", group.Desc.GroupId, log.Fields{"group": group}, err)
}
log.Debugw("add-group operation performed on the device successfully ", log.Fields{"groupToOlt": groupToOlt})
return nil
@@ -2050,8 +2024,7 @@
func (f *OpenOltFlowMgr) ModifyGroup(ctx context.Context, group *ofp.OfpGroupEntry) error {
log.Infow("modify-group", log.Fields{"group": group})
if group == nil || group.Desc == nil {
- log.Warn("cannot modify group; group is nil")
- return errors.New("cannot modify group; group is nil")
+ return olterrors.NewErrInvalidValue(log.Fields{"group": group, "groupDesc": group.Desc}, nil)
}
newGroup := f.buildGroup(group.Desc.GroupId, group.Desc.Buckets)
@@ -2059,9 +2032,7 @@
val, groupExists, err := f.GetFlowGroupFromKVStore(ctx, group.Desc.GroupId, false)
if err != nil {
- log.Errorw("Failed to retrieve the group from the store. Cannot modify group.",
- log.Fields{"groupId": group.Desc.GroupId, "err": err})
- return fmt.Errorf("failed to retrieve the group from the store. Cannot modify group. groupId:%v, err:%v", group.Desc.GroupId, err)
+ return olterrors.NewErrNotFound("flow-group-in-kv-store", log.Fields{"groupId": group.Desc.GroupId}, err)
}
var current *openoltpb2.Group // represents the group on the device
@@ -2102,8 +2073,7 @@
//save the modified group
if errAdd == nil && errRemoved == nil {
if err := f.resourceMgr.AddFlowGroupToKVStore(ctx, group, false); err != nil {
- log.Errorw("Failed to save the group into kv store", log.Fields{"groupId": group.Desc.GroupId, "error": err})
- return fmt.Errorf("failed to save the group into kv store. groupId:%v, err:%v", group.Desc.GroupId, err)
+ return olterrors.NewErrPersistence("add", "flow-group", group.Desc.GroupId, log.Fields{"group": group}, err)
}
log.Debugw("modify-group was success. Storing the group", log.Fields{"group": group, "existingGroup": current})
} else {
@@ -2156,9 +2126,9 @@
log.Debugw("Sending group to device", log.Fields{"groupToOlt": group, "command": group.Command})
_, err := f.deviceHandler.Client.PerformGroupOperation(context.Background(), group)
if err != nil {
- log.Errorw("group operation failed", log.Fields{"err": err, "groupToOlt": group})
+ return olterrors.NewErrAdapter("group-operation-failed", log.Fields{"groupToOlt": group}, err)
}
- return err
+ return nil
}
//buildGroup build openoltpb2.Group from given group id and bucket list
@@ -2215,8 +2185,7 @@
onuDevice, err := f.getOnuChildDevice(intfID, onuID)
if err != nil {
- log.Errorw("Error while fetching Child device from core", log.Fields{"onuId": onuID})
- return err
+ return olterrors.NewErrNotFound("onu-child-device", log.Fields{"onuId": onuID, "intfID": intfID}, err)
}
log.Debugw("Got child device from OLT device handler", log.Fields{"device": *onuDevice})
@@ -2231,10 +2200,9 @@
onuDevice.Id,
onuDevice.ProxyAddress.DeviceId, "")
if sendErr != nil {
- log.Errorw("send techprofile-download request error", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
+ return olterrors.NewErrCommunication("send-techprofile-download-request", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
"toAdapter": onuDevice.Type, "onuId": onuDevice.Id,
- "proxyDeviceId": onuDevice.ProxyAddress.DeviceId})
- return sendErr
+ "proxyDeviceId": onuDevice.ProxyAddress.DeviceId}, sendErr)
}
log.Debugw("success Sending Load-tech-profile-request-to-brcm-onu-adapter", log.Fields{"msg": tpDownloadMsg})
return nil
@@ -2304,7 +2272,7 @@
"serial-number": serialNumber,
"interface-id": intfID,
"gem-port-id": gemPortID},
- nil).Log()
+ nil)
}
//GetLogicalPortFromPacketIn function computes logical port UNI/NNI port from packet-in indication and returns the same
@@ -2316,7 +2284,7 @@
if packetIn.IntfType == "pon" {
// packet indication does not have serial number , so sending as nil
if onuID, err = f.getOnuIDfromGemPortMap("", packetIn.IntfId, packetIn.GemportId); err != nil {
- log.Errorw("Unable to get ONU ID from GEM/PON port", log.Fields{"pon port": packetIn.IntfId, "gemport": packetIn.GemportId})
+ // Called method is returning error with all data populated; just return the same
return logicalPortNum, err
}
if packetIn.PortNo != 0 {
@@ -2362,8 +2330,7 @@
return gemPortID, nil
}
}
- log.Errorw("Failed to get gemport", log.Fields{"pktinkey": pktInkey, "gem": gemPortID})
- return uint32(0), err
+ return uint32(0), olterrors.NewErrNotFound("gem-port", log.Fields{"pktinkey": pktInkey, "gem": gemPortID}, err)
}
func installFlowOnAllGemports(ctx context.Context,
@@ -2434,7 +2401,7 @@
return olterrors.NewErrNotFound("nni-intreface-id", log.Fields{
"classifier": classifier,
"action": action},
- err).Log()
+ err)
}
flowStoreCookie := getFlowStoreCookie(classifier, uint32(0))
@@ -2450,16 +2417,16 @@
"uni-id": uniID,
"gem-port-id": gemPortID,
"cookie": flowStoreCookie},
- err).Log()
+ err)
}
classifierProto, err := makeOpenOltClassifierField(classifier)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier}, err)
}
log.Debugw("Created classifier proto", log.Fields{"classifier": *classifierProto})
actionProto, err := makeOpenOltActionField(action)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"action": action}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"action": action}, err)
}
log.Debugw("Created action proto", log.Fields{"action": *actionProto})
downstreamflow := openoltpb2.Flow{AccessIntfId: int32(-1), // AccessIntfId not required
@@ -2476,7 +2443,7 @@
Cookie: logicalFlow.Cookie,
PortNo: portNo}
if err := f.addFlowToDevice(ctx, logicalFlow, &downstreamflow); err != nil {
- return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": downstreamflow}, err).Log()
+ return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": downstreamflow}, err)
}
log.Debug("DHCP trap on NNI flow added to device successfully")
flowsToKVStore := f.getUpdatedFlowInfo(ctx, &downstreamflow, flowStoreCookie, "", flowID, logicalFlow.Id)
@@ -2484,7 +2451,7 @@
int32(onuID),
int32(uniID),
flowID, flowsToKVStore); err != nil {
- return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": downstreamflow}, err).Log()
+ return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": downstreamflow}, err)
}
return nil
}
@@ -2541,7 +2508,7 @@
return olterrors.NewErrNotFound("nni-interface-id", log.Fields{
"classifier": classifier,
"action": action},
- err).Log()
+ err)
}
flowStoreCookie := getFlowStoreCookie(classifier, uint32(0))
if present := f.resourceMgr.IsFlowCookieOnKVStore(ctx, uint32(networkInterfaceID), int32(onuID), int32(uniID), flowStoreCookie); present {
@@ -2556,16 +2523,16 @@
"uni-id": uniID,
"gem-port-id": gemPortID,
"cookie": flowStoreCookie},
- err).Log()
+ err)
}
classifierProto, err := makeOpenOltClassifierField(classifier)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier}, err)
}
log.Debugw("Created classifier proto for the IGMP flow", log.Fields{"classifier": *classifierProto})
actionProto, err := makeOpenOltActionField(action)
if err != nil {
- return olterrors.NewErrInvalidValue(log.Fields{"action": action}, err).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"action": action}, err)
}
log.Debugw("Created action proto for the IGMP flow", log.Fields{"action": *actionProto})
downstreamflow := openoltpb2.Flow{AccessIntfId: int32(-1), // AccessIntfId not required
@@ -2582,7 +2549,7 @@
Cookie: logicalFlow.Cookie,
PortNo: portNo}
if err := f.addFlowToDevice(ctx, logicalFlow, &downstreamflow); err != nil {
- return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": downstreamflow}, err).Log()
+ return olterrors.NewErrFlowOp("add", flowID, log.Fields{"flow": downstreamflow}, err)
}
log.Debug("IGMP Trap on NNI flow added to device successfully")
flowsToKVStore := f.getUpdatedFlowInfo(ctx, &downstreamflow, flowStoreCookie, "", flowID, logicalFlow.Id)
@@ -2590,7 +2557,7 @@
int32(onuID),
int32(uniID),
flowID, flowsToKVStore); err != nil {
- return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": downstreamflow}, err).Log()
+ return olterrors.NewErrPersistence("update", "flow", flowID, log.Fields{"flow": downstreamflow}, err)
}
return nil
}
@@ -2792,7 +2759,7 @@
actionInfo[Output] = out.GetPort()
log.Debugw("action-type-output", log.Fields{"out_port": actionInfo[Output].(uint32)})
} else {
- return olterrors.NewErrInvalidValue(log.Fields{"output-port": nil}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"output-port": nil}, nil)
}
} else if action.Type == flows.POP_VLAN {
actionInfo[PopVlan] = true
@@ -2812,7 +2779,7 @@
if out := action.GetSetField(); out != nil {
if field := out.GetField(); field != nil {
if ofClass := field.GetOxmClass(); ofClass != ofp.OfpOxmClass_OFPXMC_OPENFLOW_BASIC {
- return olterrors.NewErrInvalidValue(log.Fields{"openflow-class": ofClass}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"openflow-class": ofClass}, nil)
}
/*log.Debugw("action-type-set-field",log.Fields{"field": field, "in_port": classifierInfo[IN_PORT].(uint32)})*/
formulateSetFieldActionInfoFromFlow(field, actionInfo)
@@ -2821,7 +2788,7 @@
} else if action.Type == flows.GROUP {
formulateGroupActionInfoFromFlow(action, actionInfo)
} else {
- return olterrors.NewErrInvalidValue(log.Fields{"action-type": action.Type}, nil).Log()
+ return olterrors.NewErrInvalidValue(log.Fields{"action-type": action.Type}, nil)
}
}
return nil
@@ -2862,7 +2829,7 @@
} else {
return olterrors.NewErrNotFound("child-in-port", log.Fields{
"reason": "upstream pon-to-controller-flow, NO-inport-in-tunnelid",
- "flow": flow}, nil).Log()
+ "flow": flow}, nil)
}
}
} else {
@@ -2875,7 +2842,7 @@
} else {
return olterrors.NewErrNotFound("out-port", log.Fields{
"reason": "downstream-nni-to-pon-port-flow, no-outport-in-tunnelid",
- "flow": flow}, nil).Log()
+ "flow": flow}, nil)
}
// Upstream flow from PON to NNI port , Use tunnel ID as new IN port / UNI port
} else if portType := IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT {
@@ -2888,7 +2855,7 @@
"reason": "upstream-pon-to-nni-port-flow, no-inport-in-tunnelid",
"in-port": classifierInfo[InPort].(uint32),
"out-port": actionInfo[Output].(uint32),
- "flow": flow}, nil).Log()
+ "flow": flow}, nil)
}
}
}
@@ -2905,7 +2872,7 @@
*/
metadata := flows.GetMetadataFromWriteMetadataAction(flow)
if metadata == 0 {
- return 0, olterrors.NewErrNotFound("metadata", log.Fields{"flow": flow}, nil).Log()
+ return 0, olterrors.NewErrNotFound("metadata", log.Fields{"flow": flow}, nil)
}
TpID := flows.GetTechProfileIDFromWriteMetaData(metadata)
return uint32(TpID), nil
@@ -3029,7 +2996,7 @@
func (f *OpenOltFlowMgr) GetFlowGroupFromKVStore(ctx context.Context, groupID uint32, cached bool) (*ofp.OfpGroupEntry, bool, error) {
exists, groupInfo, err := f.resourceMgr.GetFlowGroupFromKVStore(ctx, groupID, cached)
if err != nil {
- return nil, false, olterrors.NewErrNotFound("flow-group", log.Fields{"group-id": groupID}, err).Log()
+ return nil, false, olterrors.NewErrNotFound("flow-group", log.Fields{"group-id": groupID}, err)
}
if exists {
return newGroup(groupInfo.GroupID, groupInfo.OutPorts), exists, nil
diff --git a/internal/pkg/core/openolt_test.go b/internal/pkg/core/openolt_test.go
index 20cb38d..9c9094f 100644
--- a/internal/pkg/core/openolt_test.go
+++ b/internal/pkg/core/openolt_test.go
@@ -563,7 +563,7 @@
{"process_inter_adaptor_messgae-1", mockOlt(), message1,
reflect.TypeOf(&olterrors.ErrNotFound{})},
{"process_inter_adaptor_messgae-2", mockOlt(), message2,
- reflect.TypeOf(errors.New("message is nil"))},
+ reflect.TypeOf(&olterrors.ErrAdapter{})},
{"process_inter_adaptor_messgae-3", mockOlt(), message3,
reflect.TypeOf(&olterrors.ErrInvalidValue{})},
}