[VOL-4178, VOL-3952] This commit removes flows/groups/meters persistency
This commit removes flows/groups/meters persistency from rw-core.
As part of this change, it also fixes a bug where devices were not
being loaded on an rw-core restart. This is a necessary condition
to allow the non-persistency of flows/groups/meters to work.
This commit also renames "loader" to "cache" for the flows/groups/
meters to differentiate between data that is loaded from the KV
store and the one in cache.
Change-Id: Ib14e1450021abe30b17673c2910768fb740dba51
diff --git a/rw_core/core/device/agent_flow.go b/rw_core/core/device/agent_flow.go
index 3b04c02..2ac9bd7 100644
--- a/rw_core/core/device/agent_flow.go
+++ b/rw_core/core/device/agent_flow.go
@@ -33,10 +33,10 @@
// listDeviceFlows returns device flows
func (agent *Agent) listDeviceFlows() map[uint64]*ofp.OfpFlowStats {
- flowIDs := agent.flowLoader.ListIDs()
+ flowIDs := agent.flowCache.ListIDs()
flows := make(map[uint64]*ofp.OfpFlowStats, len(flowIDs))
for flowID := range flowIDs {
- if flowHandle, have := agent.flowLoader.Lock(flowID); have {
+ if flowHandle, have := agent.flowCache.Lock(flowID); have {
flows[flowID] = flowHandle.GetReadOnly()
flowHandle.Unlock()
}
@@ -69,7 +69,7 @@
flowsToAdd := make([]*ofp.OfpFlowStats, 0)
flowsToDelete := make([]*ofp.OfpFlowStats, 0)
for _, flow := range newFlows {
- flowHandle, created, err := agent.flowLoader.LockOrCreate(ctx, flow)
+ flowHandle, created, err := agent.flowCache.LockOrCreate(ctx, flow)
if err != nil {
desc = err.Error()
agent.logDeviceUpdate(ctx, "addFlowsToAdapter", nil, nil, operStatus, &desc)
@@ -167,7 +167,7 @@
return coreutils.DoneResponse(), status.Errorf(codes.FailedPrecondition, "non-existent-device-type-%s", device.Type)
}
for _, flow := range flowsToDel {
- if flowHandle, have := agent.flowLoader.Lock(flow.Id); have {
+ if flowHandle, have := agent.flowCache.Lock(flow.Id); have {
// Update the store and cache
if err := flowHandle.Delete(ctx); err != nil {
flowHandle.Unlock()
@@ -245,7 +245,7 @@
flowsToAdd := make([]*ofp.OfpFlowStats, 0, len(updatedFlows))
flowsToDelete := make([]*ofp.OfpFlowStats, 0, len(updatedFlows))
for _, flow := range updatedFlows {
- if flowHandle, have := agent.flowLoader.Lock(flow.Id); have {
+ if flowHandle, have := agent.flowCache.Lock(flow.Id); have {
flowToDelete := flowHandle.GetReadOnly()
// Update the store and cache
if err := flowHandle.Update(ctx, flow); err != nil {
@@ -318,8 +318,8 @@
func (agent *Agent) filterOutFlows(ctx context.Context, uniPort uint32, flowMetadata *voltha.FlowMetadata) error {
var flowsToDelete []*ofp.OfpFlowStats
// If an existing flow has the uniPort as an InPort or OutPort or as a Tunnel ID then it needs to be removed
- for flowID := range agent.flowLoader.ListIDs() {
- if flowHandle, have := agent.flowLoader.Lock(flowID); have {
+ for flowID := range agent.flowCache.ListIDs() {
+ if flowHandle, have := agent.flowCache.Lock(flowID); have {
flow := flowHandle.GetReadOnly()
if flow != nil && (fu.GetInPort(flow) == uniPort || fu.GetOutPort(flow) == uniPort || fu.GetTunnelId(flow) == uint64(uniPort)) {
flowsToDelete = append(flowsToDelete, flow)
@@ -353,8 +353,8 @@
defer agent.logDeviceUpdate(ctx, "deleteAllFlows", nil, nil, operStatus, &desc)
- for flowID := range agent.flowLoader.ListIDs() {
- if flowHandle, have := agent.flowLoader.Lock(flowID); have {
+ for flowID := range agent.flowCache.ListIDs() {
+ if flowHandle, have := agent.flowCache.Lock(flowID); have {
// Update the store and cache
if err := flowHandle.Delete(ctx); err != nil {
flowHandle.Unlock()