Adding flow info to error messages

Change-Id: Iadddc9a7f12dcebdb775bdcc9922259fc654693d
diff --git a/rw_core/core/device/logical_agent.go b/rw_core/core/device/logical_agent.go
index c14750d..7abd8f2 100644
--- a/rw_core/core/device/logical_agent.go
+++ b/rw_core/core/device/logical_agent.go
@@ -240,7 +240,7 @@
 	return responses
 }
 
-func (agent *LogicalAgent) deleteFlowsAndGroupsFromDevices(deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata) []coreutils.Response {
+func (agent *LogicalAgent) deleteFlowsAndGroupsFromDevices(deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata, mod *ofp.OfpFlowMod) []coreutils.Response {
 	logger.Debugw("send-delete-flows-to-device-manager", log.Fields{"logicalDeviceID": agent.logicalDeviceID})
 
 	responses := make([]coreutils.Response, 0)
@@ -252,7 +252,12 @@
 			defer cancel()
 			start := time.Now()
 			if err := agent.deviceMgr.deleteFlowsAndGroups(subCtx, deviceId, value.ListFlows(), value.ListGroups(), flowMetadata); err != nil {
-				logger.Errorw("flow-delete-failed", log.Fields{"deviceID": deviceId, "error": err, "wait-time": time.Since(start)})
+				logger.Errorw("flows-and-groups-delete-failed", log.Fields{
+					"device-id":   deviceId,
+					"error":       err,
+					"flow-cookie": mod.Cookie,
+					"wait-time":   time.Since(start),
+				})
 				response.Error(status.Errorf(codes.Internal, "flow-delete-failed: %s", deviceId))
 			}
 			response.Done()
@@ -281,7 +286,7 @@
 	return responses
 }
 
-func (agent *LogicalAgent) deleteFlowsFromParentDevice(flows map[uint64]*ofp.OfpFlowStats, metadata *voltha.FlowMetadata) []coreutils.Response {
+func (agent *LogicalAgent) deleteFlowsFromParentDevice(flows map[uint64]*ofp.OfpFlowStats, metadata *voltha.FlowMetadata, mod *ofp.OfpFlowMod) []coreutils.Response {
 	logger.Debugw("deleting-flows-from-parent-device", log.Fields{"logical-device-id": agent.logicalDeviceID, "flows": flows})
 	responses := make([]coreutils.Response, 0)
 	for _, flow := range flows {
@@ -299,7 +304,11 @@
 			subCtx, cancel := context.WithTimeout(context.Background(), agent.defaultTimeout)
 			defer cancel()
 			if err := agent.deviceMgr.deleteParentFlows(subCtx, agent.rootDeviceID, uniPort, metadata); err != nil {
-				logger.Error("flow-delete-failed", log.Fields{"device-id": agent.rootDeviceID, "error": err})
+				logger.Error("flow-delete-failed-from-parent-device", log.Fields{
+					"device-id":   agent.rootDeviceID,
+					"error":       err,
+					"flow-cookie": mod.Cookie,
+				})
 				response.Error(status.Errorf(codes.Internal, "flow-delete-failed: %s %v", agent.rootDeviceID, err))
 			}
 			response.Done()
diff --git a/rw_core/core/device/logical_agent_flow.go b/rw_core/core/device/logical_agent_flow.go
index ff0f6e1..92ba4a2 100644
--- a/rw_core/core/device/logical_agent_flow.go
+++ b/rw_core/core/device/logical_agent_flow.go
@@ -208,13 +208,17 @@
 	}
 
 	// Update the devices
-	respChnls := agent.deleteFlowsAndGroupsFromDevices(deviceRules, metadata)
+	respChnls := agent.deleteFlowsAndGroupsFromDevices(deviceRules, metadata, mod)
 
 	// Wait for the responses
 	go func() {
 		// Since this action is taken following an add failure, we may also receive a failure for the revert
 		if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChnls...); res != nil {
-			logger.Warnw("failure-reverting-added-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
+			logger.Warnw("failure-reverting-added-flows", log.Fields{
+				"logical-device-id": agent.logicalDeviceID,
+				"flow-cookie":       mod.Cookie,
+				"errors":            res,
+			})
 		}
 	}()
 
@@ -306,9 +310,9 @@
 
 		// Update the devices
 		if partialRoute {
-			respChnls = agent.deleteFlowsFromParentDevice(toDelete, toMetadata(metersConfig))
+			respChnls = agent.deleteFlowsFromParentDevice(toDelete, toMetadata(metersConfig), mod)
 		} else {
-			respChnls = agent.deleteFlowsAndGroupsFromDevices(deviceRules, toMetadata(metersConfig))
+			respChnls = agent.deleteFlowsAndGroupsFromDevices(deviceRules, toMetadata(metersConfig), mod)
 		}
 
 		// Wait for the responses
@@ -381,15 +385,19 @@
 	}
 	// Update the devices
 	if partialRoute {
-		respChnls = agent.deleteFlowsFromParentDevice(flowsToDelete, toMetadata(flowMetadata))
+		respChnls = agent.deleteFlowsFromParentDevice(flowsToDelete, toMetadata(flowMetadata), mod)
 	} else {
-		respChnls = agent.deleteFlowsAndGroupsFromDevices(deviceRules, toMetadata(flowMetadata))
+		respChnls = agent.deleteFlowsAndGroupsFromDevices(deviceRules, toMetadata(flowMetadata), mod)
 	}
 
 	// Wait for completion
 	go func() {
 		if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChnls...); res != nil {
-			logger.Warnw("failure-deleting-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
+			logger.Warnw("failure-deleting-device-flows", log.Fields{
+				"flow-cookie":       mod.Cookie,
+				"logical-device-id": agent.logicalDeviceID,
+				"errors":            res,
+			})
 			//TODO: Revert flow changes
 		}
 	}()