[VOL-3767] Log instead of throwing errors when deletion target is not found
Change-Id: I497fa7f41bb4fe2ec6662832b5d7c8cb45f17699
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 7e6ef2c..140158a 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -1745,7 +1745,17 @@
err = dh.flowMgr[intfID].RouteFlowToOnuChannel(ctx, flow, false, nil)
}
if err != nil {
- errorsList = append(errorsList, err)
+ if werr, ok := err.(olterrors.WrappedError); ok && status.Code(werr.Unwrap()) == codes.NotFound {
+ //The flow we want to remove is not there, there is no need to throw an error
+ logger.Warnw(ctx, "flow-to-remove-not-found",
+ log.Fields{
+ "ponIf": intfID,
+ "flowToRemove": flow,
+ "error": err,
+ })
+ } else {
+ errorsList = append(errorsList, err)
+ }
}
}
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 41988ec..9b3a9de 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -1915,10 +1915,12 @@
logger.Warnw(ctx, "child device and its associated resources are already cleared", log.Fields{"intfID": intfID, "onuID": onuID, "uniID": uniID})
return nil
}
- return olterrors.NewErrNotFound("tech-profile-in-kv-store",
+ // If the tech profile is not found, since we want to delete it, there is no need to throw an error
+ _ = olterrors.NewErrNotFound("tech-profile-in-kv-store",
log.Fields{
"tp-id": tpID,
- "path": tpPath}, err)
+ "path": tpPath}, err).Log()
+ return nil
}
var allGemPortsFree = true
diff --git a/internal/pkg/olterrors/olterrors.go b/internal/pkg/olterrors/olterrors.go
index bafc721..53c4d61 100644
--- a/internal/pkg/olterrors/olterrors.go
+++ b/internal/pkg/olterrors/olterrors.go
@@ -56,6 +56,11 @@
LogAt(log.LogLevel) error
}
+// WrappedError can be used to extract the wrapped errors of structs that include ErrAdapter
+type WrappedError interface {
+ Unwrap() error
+}
+
// ErrAdapter represents a basic adapter error that combines an name, field set
// and wrapped error
type ErrAdapter struct {