Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package device |
| 18 | |
| 19 | import ( |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 20 | "context" |
| 21 | |
| 22 | "github.com/gogo/protobuf/proto" |
| 23 | coreutils "github.com/opencord/voltha-go/rw_core/utils" |
Maninder | dfadc98 | 2020-10-28 14:04:33 +0530 | [diff] [blame] | 24 | fu "github.com/opencord/voltha-lib-go/v4/pkg/flows" |
| 25 | "github.com/opencord/voltha-lib-go/v4/pkg/log" |
| 26 | ofp "github.com/opencord/voltha-protos/v4/go/openflow_13" |
| 27 | "github.com/opencord/voltha-protos/v4/go/voltha" |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 28 | "google.golang.org/grpc/codes" |
| 29 | "google.golang.org/grpc/status" |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 30 | ) |
| 31 | |
| 32 | // listDeviceFlows returns device flows |
| 33 | func (agent *Agent) listDeviceFlows() map[uint64]*ofp.OfpFlowStats { |
Kent Hagerman | fa9d6d4 | 2020-05-25 11:49:40 -0400 | [diff] [blame] | 34 | flowIDs := agent.flowLoader.ListIDs() |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 35 | flows := make(map[uint64]*ofp.OfpFlowStats, len(flowIDs)) |
| 36 | for flowID := range flowIDs { |
| 37 | if flowHandle, have := agent.flowLoader.Lock(flowID); have { |
| 38 | flows[flowID] = flowHandle.GetReadOnly() |
| 39 | flowHandle.Unlock() |
| 40 | } |
| 41 | } |
| 42 | return flows |
| 43 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 44 | |
| 45 | func (agent *Agent) addFlowsToAdapter(ctx context.Context, newFlows []*ofp.OfpFlowStats, flowMetadata *voltha.FlowMetadata) (coreutils.Response, error) { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 46 | logger.Debugw(ctx, "add-flows-to-adapters", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "flow-metadata": flowMetadata}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 47 | |
| 48 | if (len(newFlows)) == 0 { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 49 | logger.Debugw(ctx, "nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 50 | return coreutils.DoneResponse(), nil |
| 51 | } |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 52 | device, err := agent.getDeviceReadOnly(ctx) |
| 53 | if err != nil { |
| 54 | return coreutils.DoneResponse(), status.Errorf(codes.Aborted, "%s", err) |
| 55 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 56 | dType, err := agent.adapterMgr.GetDeviceType(ctx, &voltha.ID{Id: device.Type}) |
| 57 | if err != nil { |
| 58 | return coreutils.DoneResponse(), status.Errorf(codes.FailedPrecondition, "non-existent-device-type-%s", device.Type) |
| 59 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 60 | flowsToAdd := make([]*ofp.OfpFlowStats, 0) |
| 61 | flowsToDelete := make([]*ofp.OfpFlowStats, 0) |
| 62 | for _, flow := range newFlows { |
| 63 | flowHandle, created, err := agent.flowLoader.LockOrCreate(ctx, flow) |
| 64 | if err != nil { |
| 65 | return coreutils.DoneResponse(), err |
| 66 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 67 | if created { |
| 68 | flowsToAdd = append(flowsToAdd, flow) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 69 | } else { |
| 70 | flowToReplace := flowHandle.GetReadOnly() |
| 71 | if !proto.Equal(flowToReplace, flow) { |
| 72 | //Flow needs to be updated. |
| 73 | if err := flowHandle.Update(ctx, flow); err != nil { |
| 74 | flowHandle.Unlock() |
| 75 | return coreutils.DoneResponse(), status.Errorf(codes.Internal, "failure-updating-flow-%d-to-device-%s", flow.Id, agent.deviceID) |
| 76 | } |
| 77 | flowsToDelete = append(flowsToDelete, flowToReplace) |
| 78 | flowsToAdd = append(flowsToAdd, flow) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 79 | } else { |
| 80 | //No need to change the flow. It is already exist. |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 81 | logger.Debugw(ctx, "No-need-to-change-already-existing-flow", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "flow-metadata": flowMetadata}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 82 | } |
| 83 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 84 | flowHandle.Unlock() |
| 85 | } |
| 86 | |
| 87 | // Sanity check |
| 88 | if (len(flowsToAdd)) == 0 { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 89 | logger.Debugw(ctx, "no-flows-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 90 | return coreutils.DoneResponse(), nil |
| 91 | } |
| 92 | |
| 93 | // Send update to adapters |
Rohan Agrawal | cf12f20 | 2020-08-03 04:42:01 +0000 | [diff] [blame] | 94 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 95 | response := coreutils.NewResponse() |
| 96 | if !dType.AcceptsAddRemoveFlowUpdates { |
Kent Hagerman | a7c9d79 | 2020-07-16 17:39:01 -0400 | [diff] [blame] | 97 | |
| 98 | updatedAllFlows := agent.listDeviceFlows() |
| 99 | rpcResponse, err := agent.adapterProxy.UpdateFlowsBulk(subCtx, device, updatedAllFlows, nil, flowMetadata) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 100 | if err != nil { |
| 101 | cancel() |
| 102 | return coreutils.DoneResponse(), err |
| 103 | } |
| 104 | go agent.waitForAdapterFlowResponse(subCtx, cancel, rpcResponse, response) |
| 105 | } else { |
| 106 | flowChanges := &ofp.FlowChanges{ |
| 107 | ToAdd: &voltha.Flows{Items: flowsToAdd}, |
| 108 | ToRemove: &voltha.Flows{Items: flowsToDelete}, |
| 109 | } |
| 110 | groupChanges := &ofp.FlowGroupChanges{ |
| 111 | ToAdd: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 112 | ToRemove: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 113 | ToUpdate: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 114 | } |
| 115 | rpcResponse, err := agent.adapterProxy.UpdateFlowsIncremental(subCtx, device, flowChanges, groupChanges, flowMetadata) |
| 116 | if err != nil { |
| 117 | cancel() |
| 118 | return coreutils.DoneResponse(), err |
| 119 | } |
| 120 | go agent.waitForAdapterFlowResponse(subCtx, cancel, rpcResponse, response) |
| 121 | } |
| 122 | return response, nil |
| 123 | } |
| 124 | |
| 125 | func (agent *Agent) deleteFlowsFromAdapter(ctx context.Context, flowsToDel []*ofp.OfpFlowStats, flowMetadata *voltha.FlowMetadata) (coreutils.Response, error) { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 126 | logger.Debugw(ctx, "delete-flows-from-adapter", log.Fields{"device-id": agent.deviceID, "flows": flowsToDel}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 127 | |
| 128 | if (len(flowsToDel)) == 0 { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 129 | logger.Debugw(ctx, "nothing-to-delete", log.Fields{"device-id": agent.deviceID, "flows": flowsToDel}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 130 | return coreutils.DoneResponse(), nil |
| 131 | } |
| 132 | |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 133 | device, err := agent.getDeviceReadOnly(ctx) |
| 134 | if err != nil { |
| 135 | return coreutils.DoneResponse(), status.Errorf(codes.Aborted, "%s", err) |
| 136 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 137 | dType, err := agent.adapterMgr.GetDeviceType(ctx, &voltha.ID{Id: device.Type}) |
| 138 | if err != nil { |
| 139 | return coreutils.DoneResponse(), status.Errorf(codes.FailedPrecondition, "non-existent-device-type-%s", device.Type) |
| 140 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 141 | for _, flow := range flowsToDel { |
| 142 | if flowHandle, have := agent.flowLoader.Lock(flow.Id); have { |
| 143 | // Update the store and cache |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 144 | if err := flowHandle.Delete(ctx); err != nil { |
| 145 | flowHandle.Unlock() |
| 146 | return coreutils.DoneResponse(), err |
| 147 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 148 | flowHandle.Unlock() |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // Send update to adapters |
Rohan Agrawal | cf12f20 | 2020-08-03 04:42:01 +0000 | [diff] [blame] | 153 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 154 | response := coreutils.NewResponse() |
| 155 | if !dType.AcceptsAddRemoveFlowUpdates { |
Kent Hagerman | a7c9d79 | 2020-07-16 17:39:01 -0400 | [diff] [blame] | 156 | |
| 157 | updatedAllFlows := agent.listDeviceFlows() |
| 158 | rpcResponse, err := agent.adapterProxy.UpdateFlowsBulk(subCtx, device, updatedAllFlows, nil, flowMetadata) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 159 | if err != nil { |
| 160 | cancel() |
| 161 | return coreutils.DoneResponse(), err |
| 162 | } |
| 163 | go agent.waitForAdapterFlowResponse(subCtx, cancel, rpcResponse, response) |
| 164 | } else { |
| 165 | flowChanges := &ofp.FlowChanges{ |
| 166 | ToAdd: &voltha.Flows{Items: []*ofp.OfpFlowStats{}}, |
| 167 | ToRemove: &voltha.Flows{Items: flowsToDel}, |
| 168 | } |
| 169 | groupChanges := &ofp.FlowGroupChanges{ |
| 170 | ToAdd: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 171 | ToRemove: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 172 | ToUpdate: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 173 | } |
| 174 | rpcResponse, err := agent.adapterProxy.UpdateFlowsIncremental(subCtx, device, flowChanges, groupChanges, flowMetadata) |
| 175 | if err != nil { |
| 176 | cancel() |
| 177 | return coreutils.DoneResponse(), err |
| 178 | } |
| 179 | go agent.waitForAdapterFlowResponse(subCtx, cancel, rpcResponse, response) |
| 180 | } |
| 181 | return response, nil |
| 182 | } |
| 183 | |
| 184 | func (agent *Agent) updateFlowsToAdapter(ctx context.Context, updatedFlows []*ofp.OfpFlowStats, flowMetadata *voltha.FlowMetadata) (coreutils.Response, error) { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 185 | logger.Debugw(ctx, "updateFlowsToAdapter", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 186 | |
| 187 | if (len(updatedFlows)) == 0 { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 188 | logger.Debugw(ctx, "nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 189 | return coreutils.DoneResponse(), nil |
| 190 | } |
| 191 | |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 192 | device, err := agent.getDeviceReadOnly(ctx) |
| 193 | if err != nil { |
| 194 | return coreutils.DoneResponse(), status.Errorf(codes.Aborted, "%s", err) |
| 195 | } |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 196 | if device.OperStatus != voltha.OperStatus_ACTIVE || device.ConnectStatus != voltha.ConnectStatus_REACHABLE || device.AdminState != voltha.AdminState_ENABLED { |
| 197 | return coreutils.DoneResponse(), status.Errorf(codes.FailedPrecondition, "invalid device states") |
| 198 | } |
| 199 | dType, err := agent.adapterMgr.GetDeviceType(ctx, &voltha.ID{Id: device.Type}) |
| 200 | if err != nil { |
| 201 | return coreutils.DoneResponse(), status.Errorf(codes.FailedPrecondition, "non-existent-device-type-%s", device.Type) |
| 202 | } |
Kent Hagerman | a7c9d79 | 2020-07-16 17:39:01 -0400 | [diff] [blame] | 203 | flowsToAdd := make([]*ofp.OfpFlowStats, 0, len(updatedFlows)) |
| 204 | flowsToDelete := make([]*ofp.OfpFlowStats, 0, len(updatedFlows)) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 205 | for _, flow := range updatedFlows { |
| 206 | if flowHandle, have := agent.flowLoader.Lock(flow.Id); have { |
| 207 | flowToDelete := flowHandle.GetReadOnly() |
| 208 | // Update the store and cache |
| 209 | if err := flowHandle.Update(ctx, flow); err != nil { |
| 210 | flowHandle.Unlock() |
| 211 | return coreutils.DoneResponse(), err |
| 212 | } |
| 213 | |
| 214 | flowsToDelete = append(flowsToDelete, flowToDelete) |
| 215 | flowsToAdd = append(flowsToAdd, flow) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 216 | flowHandle.Unlock() |
| 217 | } |
| 218 | } |
| 219 | |
Rohan Agrawal | cf12f20 | 2020-08-03 04:42:01 +0000 | [diff] [blame] | 220 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 221 | response := coreutils.NewResponse() |
| 222 | // Process bulk flow update differently than incremental update |
| 223 | if !dType.AcceptsAddRemoveFlowUpdates { |
Kent Hagerman | a7c9d79 | 2020-07-16 17:39:01 -0400 | [diff] [blame] | 224 | updatedAllFlows := agent.listDeviceFlows() |
| 225 | rpcResponse, err := agent.adapterProxy.UpdateFlowsBulk(subCtx, device, updatedAllFlows, nil, nil) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 226 | if err != nil { |
| 227 | cancel() |
| 228 | return coreutils.DoneResponse(), err |
| 229 | } |
| 230 | go agent.waitForAdapterFlowResponse(subCtx, cancel, rpcResponse, response) |
| 231 | } else { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 232 | logger.Debugw(ctx, "updating-flows-and-groups", |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 233 | log.Fields{ |
| 234 | "device-id": agent.deviceID, |
| 235 | "flows-to-add": flowsToAdd, |
| 236 | "flows-to-delete": flowsToDelete, |
| 237 | }) |
| 238 | // Sanity check |
| 239 | if (len(flowsToAdd) | len(flowsToDelete)) == 0 { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 240 | logger.Debugw(ctx, "nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 241 | cancel() |
| 242 | return coreutils.DoneResponse(), nil |
| 243 | } |
| 244 | |
| 245 | flowChanges := &ofp.FlowChanges{ |
| 246 | ToAdd: &voltha.Flows{Items: flowsToAdd}, |
| 247 | ToRemove: &voltha.Flows{Items: flowsToDelete}, |
| 248 | } |
| 249 | groupChanges := &ofp.FlowGroupChanges{ |
| 250 | ToAdd: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 251 | ToRemove: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 252 | ToUpdate: &voltha.FlowGroups{Items: []*ofp.OfpGroupEntry{}}, |
| 253 | } |
| 254 | rpcResponse, err := agent.adapterProxy.UpdateFlowsIncremental(subCtx, device, flowChanges, groupChanges, flowMetadata) |
| 255 | if err != nil { |
| 256 | cancel() |
| 257 | return coreutils.DoneResponse(), err |
| 258 | } |
| 259 | go agent.waitForAdapterFlowResponse(subCtx, cancel, rpcResponse, response) |
| 260 | } |
| 261 | |
| 262 | return response, nil |
| 263 | } |
| 264 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 265 | //filterOutFlows removes flows from a device using the uni-port as filter |
| 266 | func (agent *Agent) filterOutFlows(ctx context.Context, uniPort uint32, flowMetadata *voltha.FlowMetadata) error { |
| 267 | var flowsToDelete []*ofp.OfpFlowStats |
| 268 | // If an existing flow has the uniPort as an InPort or OutPort or as a Tunnel ID then it needs to be removed |
| 269 | for flowID := range agent.flowLoader.ListIDs() { |
| 270 | if flowHandle, have := agent.flowLoader.Lock(flowID); have { |
| 271 | flow := flowHandle.GetReadOnly() |
| 272 | if flow != nil && (fu.GetInPort(flow) == uniPort || fu.GetOutPort(flow) == uniPort || fu.GetTunnelId(flow) == uint64(uniPort)) { |
| 273 | flowsToDelete = append(flowsToDelete, flow) |
| 274 | } |
| 275 | flowHandle.Unlock() |
| 276 | } |
| 277 | } |
| 278 | |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 279 | logger.Debugw(ctx, "flows-to-delete", log.Fields{"device-id": agent.deviceID, "uni-port": uniPort, "flows": flowsToDelete}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 280 | if len(flowsToDelete) == 0 { |
| 281 | return nil |
| 282 | } |
| 283 | |
| 284 | response, err := agent.deleteFlowsFromAdapter(ctx, flowsToDelete, flowMetadata) |
| 285 | if err != nil { |
| 286 | return err |
| 287 | } |
| 288 | if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, response); res != nil { |
| 289 | return status.Errorf(codes.Aborted, "errors-%s", res) |
| 290 | } |
| 291 | return nil |
| 292 | } |
| 293 | |
| 294 | //deleteAllFlows deletes all flows in the device table |
| 295 | func (agent *Agent) deleteAllFlows(ctx context.Context) error { |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 296 | logger.Debugw(ctx, "deleteAllFlows", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 297 | |
| 298 | for flowID := range agent.flowLoader.ListIDs() { |
| 299 | if flowHandle, have := agent.flowLoader.Lock(flowID); have { |
| 300 | // Update the store and cache |
| 301 | if err := flowHandle.Delete(ctx); err != nil { |
| 302 | flowHandle.Unlock() |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 303 | logger.Errorw(ctx, "unable-to-delete-flow", log.Fields{"device-id": agent.deviceID, "flowID": flowID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 304 | continue |
| 305 | } |
| 306 | flowHandle.Unlock() |
| 307 | } |
| 308 | } |
| 309 | return nil |
| 310 | } |