Local Bucket Entry deleted 41/73641/5
authorDhiman <dhiman.ghosh@ericsson.com>
Wed, 20 Jun 2018 09:06:13 +0000 (14:36 +0530)
committerSam Hague <shague@redhat.com>
Wed, 4 Jul 2018 18:13:31 +0000 (18:13 +0000)
Verify ECMP traffic distribution with weighted buckets -
Controller Restart with CSS in standalone Mode
========================================================

After Controller Restart the Local Bucket Entry was getting deleted.
This was happening bacause of multiple simultanious event was causing
ConflictModifiactionException while updating the group entry. Now
we are using DJC to submit a job using SAME key for adding group and
flows, so that it would go to the samed jobqueue and writes get
executed serially, first the froups and then the flows), instead of
parallely and no comflict in writing by diffent thread to the same
node.

Change-Id: I23ad23d1db830213feb992897ee01de6148b156a
Signed-off-by: Dhiman <dhiman.ghosh@ericsson.com>
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/EvpnVrfEntryHandler.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/NexthopManager.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/VrfEntryListener.java

index c19378df375d3a166e7e2f44b3ba230c90a6ff03..2fcb3da8433e435d08e46459d87ae04f47b11792 100644 (file)
@@ -168,18 +168,17 @@ public class EvpnVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntr
                                                  final Long vpnId, final String rd,
                                                  final VrfEntry vrfEntry) {
         final BigInteger dpnId = localNextHopInfo.getDpnId();
-        String jobKey = "FIB-" + vpnId.toString() + "-" + dpnId.toString() + "-" + vrfEntry.getDestPrefix();
+        String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, vrfEntry.getDestPrefix());
         final long groupId = nexthopManager.createLocalNextHop(vpnId, dpnId,
             localNextHopInfo.getVpnInterfaceName(), localNextHopIP, vrfEntry.getDestPrefix(),
-            vrfEntry.getGatewayMacAddress(), jobKey);
+            vrfEntry.getGatewayMacAddress());
         LOG.debug("LocalNextHopGroup {} created/reused for prefix {} rd {} evi {} route-paths {}", groupId,
             vrfEntry.getDestPrefix(), rd, vrfEntry.getL3vni(), vrfEntry.getRoutePaths());
 
         final List<InstructionInfo> instructions = Collections.singletonList(
             new InstructionApplyActions(
                 Collections.singletonList(new ActionGroup(groupId))));
-        jobCoordinator.enqueueJob("FIB-" + vpnId.toString() + "-" + dpnId.toString()
-                + "-" + vrfEntry.getDestPrefix(),
+        jobCoordinator.enqueueJob(jobKey,
             () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
                 tx -> makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx,
                         null))));
index 5d2bcb37d52a67bea3d701cb91c6ab888cebbbf3..73712df9ca0b6df13468e634862842eee694fa59 100644 (file)
@@ -365,7 +365,7 @@ public class NexthopManager implements AutoCloseable {
 
     public long createLocalNextHop(long vpnId, BigInteger dpnId, String ifName,
                                    String primaryIpAddress, String currDestIpPrefix,
-                                   String gwMacAddress, String jobKey) {
+                                   String gwMacAddress) {
         String vpnName = fibUtil.getVpnNameFromId(vpnId);
         if (vpnName == null) {
             return 0;
@@ -379,6 +379,7 @@ public class NexthopManager implements AutoCloseable {
             return groupId;
         }
         String nextHopLockStr = vpnId + primaryIpAddress;
+        String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, currDestIpPrefix);
         jobCoordinator.enqueueJob(jobKey, () -> {
             try {
                 if (FibUtil.lockCluster(lockManager, nextHopLockStr, WAIT_TIME_TO_ACQUIRE_LOCK)) {
@@ -829,17 +830,25 @@ public class NexthopManager implements AutoCloseable {
         }
         GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
                 dpnId, groupId, destPrefix, GroupTypes.GroupSelect, listBucketInfo);
-        if (addOrRemove) {
-            mdsalApiManager.syncInstallGroup(groupEntity);
-            try {
-                Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
-            } catch (InterruptedException e1) {
-                LOG.warn("Thread got interrupted while programming LB group {}", groupEntity);
-                Thread.currentThread().interrupt();
+        String jobKey = FibUtil.getCreateLocalNextHopJobKey(parentVpnId, dpnId, destPrefix);
+        jobCoordinator.enqueueJob(jobKey, () -> {
+            if (addOrRemove) {
+                mdsalApiManager.syncInstallGroup(groupEntity);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Finished installing GroupEntity with jobCoordinator key {} groupEntity.groupId {}"
+                            + "  groupEntity.groupType {}", jobKey, groupEntity.getGroupId(),
+                            groupEntity.getGroupType());
+                }
+            } else {
+                mdsalApiManager.removeGroup(groupEntity);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Finished removing GroupEntity with jobCoordinator key {} groupEntity.groupId {}"
+                            + "  groupEntity.groupType {}", jobKey, groupEntity.getGroupId(),
+                            groupEntity.getGroupType());
+                }
             }
-        } else {
-            mdsalApiManager.removeGroup(groupEntity);
-        }
+            return Collections.emptyList();
+        });
         return groupId;
     }
 
@@ -852,11 +861,16 @@ public class NexthopManager implements AutoCloseable {
             clonedVpnExtraRoutes.remove(routes);
         }
         listBucketInfo.addAll(getBucketsForRemoteNexthop(vpnId, dpnId, vrfEntry, rd, clonedVpnExtraRoutes));
-        return setupLoadBalancingNextHop(vpnId, dpnId, vrfEntry.getDestPrefix(), listBucketInfo, true);
+        return setupLoadBalancingNextHop(vpnId, dpnId, vrfEntry.getDestPrefix(), listBucketInfo,true);
     }
 
     private List<BucketInfo> getBucketsForLocalNexthop(Long vpnId, BigInteger dpnId,
             VrfEntry vrfEntry, Routes routes) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("NexthopManager.getBucketsForLocalNexthop invoked with vpnId {} dpnId {} "
+                            + " vrfEntry.routePaths {}, routes.nexthopList {}", vpnId, dpnId, vrfEntry.getRoutePaths(),
+                    routes.getNexthopIpList());
+        }
         List<BucketInfo> listBucketInfo = new CopyOnWriteArrayList<>();
         routes.getNexthopIpList().parallelStream().forEach(nextHopIp -> {
             String localNextHopIP;
index 7465a861b22ffaac323fd2f08a97bf821bd77c49..5d66993cf831a99135107f240a000fe3248eb28d 100755 (executable)
@@ -736,6 +736,10 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, localNextHopIP);
             List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker,
                     vpnName, usedRds, localNextHopIP);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Creating Local fib entry with vpnName {} usedRds {} localNextHopIP {} vpnExtraRoutes {}",
+                        vpnName, usedRds, localNextHopIP, vpnExtraRoutes);
+            }
             boolean localNextHopSeen = false;
             //Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
             for (Routes vpnExtraRoute : vpnExtraRoutes) {
@@ -832,7 +836,6 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                         vpnId, rd, dpnId.toString());
                 return BigInteger.ZERO;
             }
-            String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, vrfEntry.getDestPrefix());
             String interfaceName = localNextHopInfo.getVpnInterfaceName();
             String prefix = vrfEntry.getDestPrefix();
             String gwMacAddress = vrfEntry.getGatewayMacAddress();
@@ -845,21 +848,19 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                     localNextHopIP = routes.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
                 }
                 if (vpnExtraRoutes.size() > 1) {
-                    groupId = nextHopManager.createNextHopGroups(vpnId, rd, dpnId, vrfEntry, routes,
-                            vpnExtraRoutes);
+                    groupId = nextHopManager.createNextHopGroups(vpnId, rd, dpnId, vrfEntry, routes, vpnExtraRoutes);
                     localGroupId = nextHopManager.getLocalNextHopGroup(vpnId, localNextHopIP);
                 } else if (routes.getNexthopIpList().size() > 1) {
-                    groupId = nextHopManager.createNextHopGroups(vpnId, rd, dpnId, vrfEntry, routes,
-                            vpnExtraRoutes);
+                    groupId = nextHopManager.createNextHopGroups(vpnId, rd, dpnId, vrfEntry, routes, vpnExtraRoutes);
                     localGroupId = groupId;
                 } else {
                     groupId = nextHopManager.createLocalNextHop(vpnId, dpnId, interfaceName, localNextHopIP,
-                            prefix, gwMacAddress, jobKey);
+                            prefix, gwMacAddress);
                     localGroupId = groupId;
                 }
             } else {
                 groupId = nextHopManager.createLocalNextHop(vpnId, dpnId, interfaceName, localNextHopIP, prefix,
-                        gwMacAddress, jobKey);
+                        gwMacAddress);
                 localGroupId = groupId;
             }
             if (groupId == FibConstants.INVALID_GROUP_ID) {
@@ -875,6 +876,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                             Arrays.asList(new ActionPopMpls(etherType), new ActionGroup(groupId))));
             java.util.Optional<Long> optLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
             List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
+            String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, vrfEntry.getDestPrefix());
             jobCoordinator.enqueueJob(jobKey, () -> {
                 return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
                     baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions,