[VOL-1385] Remove parent's device flows after child deletion
This commit fixes the following:
1) Do not automatically raise an error when no routes can be
found when decomposing a flow. In some cases flows can still
be decomposed (e.g. some trap flows).
2) Delete flows from a parent device when receiving delete flow
instructions from the OF controller after a child device has
been deleted (previously was failing as no route could be
obtained).
Change-Id: I33dd45d52626146f0a6b4668048c979b5c931f9c
diff --git a/rw_core/flowdecomposition/flow_decomposer.go b/rw_core/flowdecomposition/flow_decomposer.go
index 94594b0..bfeccf6 100644
--- a/rw_core/flowdecomposition/flow_decomposer.go
+++ b/rw_core/flowdecomposition/flow_decomposer.go
@@ -18,6 +18,7 @@
import (
"context"
+ "fmt"
"github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/rw_core/coreif"
"github.com/opencord/voltha-go/rw_core/route"
@@ -468,17 +469,16 @@
deviceRules := fu.NewDeviceRules()
path, err := agent.GetRoute(ctx, inPortNo, outPortNo)
if err != nil {
- logger.Errorw("no-route", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "error": err})
return deviceRules, err
}
switch len(path) {
case 0:
- return deviceRules, status.Errorf(codes.FailedPrecondition, "no route from:%d to:%d", inPortNo, outPortNo)
+ return deviceRules, fmt.Errorf("no route from:%d to:%d :%w", inPortNo, outPortNo, route.ErrNoRoute)
case 2:
logger.Debugw("route-found", log.Fields{"ingressHop": path[0], "egressHop": path[1]})
default:
- return deviceRules, status.Errorf(codes.Aborted, "invalid route length %d", len(path))
+ return deviceRules, fmt.Errorf("invalid route length %d :%w", len(path), route.ErrNoRoute)
}
// Process controller bound flow
@@ -491,7 +491,9 @@
var ingressDevice *voltha.Device
var err error
if ingressDevice, err = fd.deviceMgr.GetDevice(ctx, path[0].DeviceID); err != nil {
- return deviceRules, err
+ // This can happen in a race condition where a device is deleted right after we obtain a
+ // route involving the device (GetRoute() above). Handle it as a no route event as well.
+ return deviceRules, fmt.Errorf("get-device-error :%v :%w", err, route.ErrNoRoute)
}
isUpstream := !ingressDevice.Root
if isUpstream { // Unicast OLT and ONU UL