NETVIRT-1144: PNF failure: Ping External Network PNF from Vm Instance 1 41/69441/2
authoreupakir <kiran.n.upadhyaya@ericsson.com>
Tue, 13 Mar 2018 11:29:50 +0000 (16:59 +0530)
committerSam Hague <shague@redhat.com>
Thu, 15 Mar 2018 01:04:24 +0000 (01:04 +0000)
The rotuer<->bgpvpn swap procedure was being triggered even for addition
of a new adjacency to the vpn-interface, leading to a delay of two
seconds(the sleep present in the swap logic) in learning the PNF route.

Change-Id: I1178545da1d11dd7635fbdeb7f5848b25d2ade1a
Signed-off-by: eupakir <kiran.n.upadhyaya@ericsson.com>
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java

index 05528c6d2550f93b602e97695c76209a1603fc05..39704f6a8ded6579549d6ff87a22e9c5692f2575 100755 (executable)
@@ -1558,38 +1558,40 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
         List<String> newVpnList = update.getVpnInstanceNames().stream()
             .map(VpnInstanceNames::getVpnName).collect(Collectors.toList());
         oldVpnList.removeAll(newVpnList);
-        for (String oldVpnName: oldVpnList) {
-            isSwap = Boolean.TRUE;
-            LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} remove vpnName {} running"
-                     + " config-driven swap removal", interfaceName, oldVpnName);
-            removeVpnInterfaceCall(identifier, original, oldVpnName, interfaceName);
-            LOG.info("handleVpnSwapForVpnInterface: Processed Remove for update on VPNInterface {} upon VPN swap"
-                     + "from old vpn {} to newVpn(s) {}", interfaceName, oldVpnName, newVpnList);
-        }
-        //Wait for previous interface bindings to be removed
-        try {
-            Thread.sleep(2000);
-        } catch (InterruptedException e) {
-            //Ignore
-        }
         newVpnList.removeAll(oldVpnListCopy);
-        for (String newVpnName: newVpnList) {
-            String primaryRd = VpnUtil.getPrimaryRd(dataBroker, newVpnName);
-            isSwap = Boolean.TRUE;
-            if (!VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) {
-                LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} onto vpnName {}"
-                         + "running config-driven swap addition", interfaceName, newVpnName);
-                final Adjacencies origAdjs = original.getAugmentation(Adjacencies.class);
-                final List<Adjacency> oldAdjs = (origAdjs != null && origAdjs.getAdjacency() != null)
-                                                ? origAdjs.getAdjacency() : new ArrayList<>();
-                final Adjacencies updateAdjs = update.getAugmentation(Adjacencies.class);
-                final List<Adjacency> newAdjs = (updateAdjs != null && updateAdjs.getAdjacency() != null)
-                                                ? updateAdjs.getAdjacency() : new ArrayList<>();
-
-                addVpnInterfaceCall(identifier, update, oldAdjs, newAdjs, newVpnName);
-                LOG.info("handleVpnSwapForVpnInterface: Processed Add for update on VPNInterface {}"
-                         + "from oldVpn(s) {} to newVpn {} upon VPN swap",
-                         interfaceName, oldVpnListCopy, newVpnName);
+        if (!oldVpnList.isEmpty() || !newVpnList.isEmpty()) {
+            for (String oldVpnName: oldVpnList) {
+                isSwap = Boolean.TRUE;
+                LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} remove vpnName {}"
+                        + " running config-driven swap removal", interfaceName, oldVpnName);
+                removeVpnInterfaceCall(identifier, original, oldVpnName, interfaceName);
+                LOG.info("handleVpnSwapForVpnInterface: Processed Remove for update on VPNInterface {} upon VPN swap"
+                        + "from old vpn {} to newVpn(s) {}", interfaceName, oldVpnName, newVpnList);
+            }
+            //Wait for previous interface bindings to be removed
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e) {
+                //Ignore
+            }
+            for (String newVpnName: newVpnList) {
+                String primaryRd = VpnUtil.getPrimaryRd(dataBroker, newVpnName);
+                isSwap = Boolean.TRUE;
+                if (!VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) {
+                    LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} onto vpnName {}"
+                            + "running config-driven swap addition", interfaceName, newVpnName);
+                    final Adjacencies origAdjs = original.getAugmentation(Adjacencies.class);
+                    final List<Adjacency> oldAdjs = (origAdjs != null && origAdjs.getAdjacency() != null)
+                            ? origAdjs.getAdjacency() : new ArrayList<>();
+                    final Adjacencies updateAdjs = update.getAugmentation(Adjacencies.class);
+                    final List<Adjacency> newAdjs = (updateAdjs != null && updateAdjs.getAdjacency() != null)
+                            ? updateAdjs.getAdjacency() : new ArrayList<>();
+
+                    addVpnInterfaceCall(identifier, update, oldAdjs, newAdjs, newVpnName);
+                    LOG.info("handleVpnSwapForVpnInterface: Processed Add for update on VPNInterface {}"
+                                    + "from oldVpn(s) {} to newVpn {} upon VPN swap",
+                            interfaceName, oldVpnListCopy, newVpnName);
+                }
             }
         }
         return isSwap;