VOL-3841 panic during error in flow delete + some context change for rpc events
Change-Id: Ic76de4c5a9dada610f67bd156e4f0641fb4a34b0
diff --git a/rw_core/core/device/logical_agent_flow.go b/rw_core/core/device/logical_agent_flow.go
index 2b88abc..6e26e42 100644
--- a/rw_core/core/device/logical_agent_flow.go
+++ b/rw_core/core/device/logical_agent_flow.go
@@ -194,8 +194,12 @@
agent.ldeviceMgr.SendFlowChangeEvent(ctx, agent.logicalDeviceID, res, flowUpdate.Xid, flowUpdate.FlowMod.Cookie)
context := make(map[string]string)
context["rpc"] = coreutils.GetRPCMetadataFromContext(ctx)
- context["flow-id"] = string(flow.Id)
- context["device-rules"] = deviceRules.String()
+ context["flow-id"] = fmt.Sprintf("%v", flow.Id)
+ context["flow-cookie"] = fmt.Sprintf("%v", flowUpdate.FlowMod.Cookie)
+ context["logical-device-id"] = agent.logicalDeviceID
+ if deviceRules != nil {
+ context["device-rules"] = deviceRules.String()
+ }
go agent.ldeviceMgr.SendRPCEvent(ctx,
agent.logicalDeviceID, "failed-to-add-flow", context, "RPC_ERROR_RAISE_EVENT",
voltha.EventCategory_COMMUNICATION, nil, time.Now().UnixNano())
@@ -349,7 +353,13 @@
logger.Errorw(ctx, "failure-updating-device-flows", log.Fields{"logical-device-id": agent.logicalDeviceID, "errors": res})
context := make(map[string]string)
context["rpc"] = coreutils.GetRPCMetadataFromContext(ctx)
- context["device-rules"] = deviceRules.String()
+ context["logical-device-id"] = agent.logicalDeviceID
+ context["flow-id"] = fmt.Sprintf("%v", fs.Id)
+ context["flow-cookie"] = fmt.Sprintf("%v", flowUpdate.FlowMod.Cookie)
+ if deviceRules != nil {
+ context["device-rules"] = deviceRules.String()
+ }
+
go agent.ldeviceMgr.SendRPCEvent(ctx,
agent.logicalDeviceID, "failed-to-update-device-flows", context, "RPC_ERROR_RAISE_EVENT",
voltha.EventCategory_COMMUNICATION, nil, time.Now().UnixNano())
@@ -439,8 +449,12 @@
agent.ldeviceMgr.SendFlowChangeEvent(ctx, agent.logicalDeviceID, res, flowUpdate.Xid, flowUpdate.FlowMod.Cookie)
context := make(map[string]string)
context["rpc"] = coreutils.GetRPCMetadataFromContext(ctx)
- context["flow-id"] = string(flow.Id)
- context["device-rules"] = deviceRules.String()
+ context["flow-id"] = fmt.Sprintf("%v", flow.Id)
+ context["flow-cookie"] = fmt.Sprintf("%v", flowUpdate.FlowMod.Cookie)
+ context["logical-device-id"] = agent.logicalDeviceID
+ if deviceRules != nil {
+ context["device-rules"] = deviceRules.String()
+ }
// Create context and send extra information as part of it.
go agent.ldeviceMgr.SendRPCEvent(ctx,
agent.logicalDeviceID, "failed-to-delete-device-flows", context, "RPC_ERROR_RAISE_EVENT",
diff --git a/rw_core/core/device/logical_agent_group.go b/rw_core/core/device/logical_agent_group.go
index b7bf1b6..1b6babc 100644
--- a/rw_core/core/device/logical_agent_group.go
+++ b/rw_core/core/device/logical_agent_group.go
@@ -95,8 +95,11 @@
logger.Warnw(ctx, "failure-updating-device-flows-groups", log.Fields{"logical-device-id": agent.logicalDeviceID, "errors": res})
context := make(map[string]string)
context["rpc"] = coreutils.GetRPCMetadataFromContext(ctx)
- context["group-id"] = string(groupMod.GroupId)
- context["device-rules"] = deviceRules.String()
+ context["logical-device-id"] = agent.logicalDeviceID
+ context["group-id"] = fmt.Sprintf("%v", groupMod.GroupId)
+ if deviceRules != nil {
+ context["device-rules"] = deviceRules.String()
+ }
go agent.ldeviceMgr.SendRPCEvent(ctx,
agent.logicalDeviceID, "failed-to-update-device-flows-groups", context, "RPC_ERROR_RAISE_EVENT",
voltha.EventCategory_COMMUNICATION, nil, time.Now().UnixNano())
@@ -177,8 +180,11 @@
logger.Warnw(ctx, "failure-updating-device-flows-groups", log.Fields{"logical-device-id": agent.logicalDeviceID, "errors": res})
context := make(map[string]string)
context["rpc"] = coreutils.GetRPCMetadataFromContext(ctx)
- context["group-id"] = string(groupMod.GroupId)
- context["device-rules"] = deviceRules.String()
+ context["group-id"] = fmt.Sprintf("%v", groupMod.GroupId)
+ context["logical-device-id"] = agent.logicalDeviceID
+ if deviceRules != nil {
+ context["device-rules"] = deviceRules.String()
+ }
go agent.ldeviceMgr.SendRPCEvent(ctx,
agent.logicalDeviceID, "failed-to-update-device-flows-groups", context, "RPC_ERROR_RAISE_EVENT",
voltha.EventCategory_COMMUNICATION, nil, time.Now().UnixNano())
@@ -227,8 +233,11 @@
logger.Warnw(ctx, "failure-updating-device-flows-groups", log.Fields{"logical-device-id": agent.logicalDeviceID, "errors": res})
context := make(map[string]string)
context["rpc"] = coreutils.GetRPCMetadataFromContext(ctx)
- context["group-id"] = string(groupMod.GroupId)
- context["device-rules"] = deviceRules.String()
+ context["group-id"] = fmt.Sprintf("%v", groupMod.GroupId)
+ context["logical-device-id"] = agent.logicalDeviceID
+ if deviceRules != nil {
+ context["device-rules"] = deviceRules.String()
+ }
go agent.ldeviceMgr.SendRPCEvent(ctx,
agent.logicalDeviceID, "failed-to-update-device-flows-groups", context, "RPC_ERROR_RAISE_EVENT",
voltha.EventCategory_COMMUNICATION, nil, time.Now().UnixNano())