NETVIRT-1439 : Delete L3VPN cleanup failure. 88/76488/7
authorAchuth Maniyedath <achuth.maniyedath@gmail.com>
Wed, 12 Sep 2018 12:33:15 +0000 (18:03 +0530)
committerSam Hague <shague@redhat.com>
Tue, 16 Oct 2018 19:45:30 +0000 (19:45 +0000)
After running clean script seeing stray fib and vpn configs.

A recent fix to handle cleanup of external PNF flows had broken
footprint cleanup of all other types of FIB entries. This fix made
use of the parentVpnRd attribute in VrfEntry to check for the
footprint of external subnet where the PNFs are discovered (Since,
the footprint/interfaces for that external subnet is maintained in
the VPN of its external network). The parentVpnRf points to this
external network.

The above mentioned fix broke cleanup of existing FIBs since no
other non-PNF fibs will hve their parentVPnRd set.

SO, this fix considers the primaryRd if parentVpnRd is not set.

Change-Id: I3a6f216e9f9cfa6bc6fe1dc8fa7e95b958ebd1b7
Signed-off-by: Kiran N Upadhyaya <kiran.n.upadhyaya@ericsson.com>
Signed-off-by: Achuth Maniyedath <achuth.maniyedath@gmail.com>
Signed-off-by: Achuth <achuth.maniyedath@gmail.com>
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/VrfEntryListener.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnManager.java

index 1da0c6c6d3e0a0c25747993995e5f35f69090d75..78f2a98d5c2b4377efa6fdc09a4529136a475425 100755 (executable)
@@ -1796,10 +1796,16 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                         futures.add(retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                             String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
                             for (final VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
+                                /* parentRd is only filled for external PNF cases where the interface on the external
+                                 * network VPN are used to cleanup the flows. For all other cases, use "rd" for
+                                 * #fibUtil.isInterfacePresentInDpn().
+                                * */
+                                String parentRd = vrfEntry.getParentVpnRd() != null ? vrfEntry.getParentVpnRd()
+                                        : rd;
                                 /* Handle subnet routes here */
                                 SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
                                 if (subnetRoute != null && !fibUtil
-                                        .isInterfacePresentInDpn(vrfEntry.getParentVpnRd(), dpnId)) {
+                                        .isInterfacePresentInDpn(parentRd, dpnId)) {
                                     LOG.trace("SUBNETROUTE: cleanUpDpnForVpn: Cleaning subnetroute {} on dpn {}"
                                             + " for vpn {}", vrfEntry.getDestPrefix(), dpnId, rd);
                                     baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null,
@@ -1869,7 +1875,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                                         TransactionAdapter.toWriteTransaction(tx), txnObjects);
                                 } else {
                                     if (subnetRoute == null || !fibUtil
-                                            .isInterfacePresentInDpn(vrfEntry.getParentVpnRd(), dpnId)) {
+                                            .isInterfacePresentInDpn(parentRd, dpnId)) {
                                         baseVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId,
                                             vrfTable.get().key(), vrfEntry, extraRouteOptional,
                                             TransactionAdapter.toWriteTransaction(tx));
index 5fdd9231c0e5ebad3655b97667a4ec7605da0186..35ac3c895df3a04b8be9d21cc6e19d0eff6b9190 100644 (file)
@@ -36,7 +36,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
-import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.annotation.PreDestroy;
@@ -2238,18 +2237,18 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         // read VPNMaps
         VpnMap vpnMap = neutronvpnUtils.getVpnMap(vpnId);
         List<RouterIds> routerIdsList = vpnMap != null ? vpnMap.getRouterIds() : null;
+        List<Uuid> routerUuidList = new ArrayList<>();
         // dissociate router
         if (routerIdsList != null && !routerIdsList.isEmpty()) {
-            for (RouterIds routerId : routerIdsList) {
-                dissociateRouterFromVpn(vpnId, routerId.getRouterId());
-            }
-            List<Uuid> rtrIdsList = routerIdsList.stream().map(routerId -> routerId.getRouterId())
-                    .collect(Collectors.toList());
-            if (rtrIdsList.contains(vpnId) && vpnMap.getNetworkIds() != null) {
-                // dissociate networks
-                dissociateNetworksFromVpn(vpnId, vpnMap.getNetworkIds());
+            for (RouterIds router : routerIdsList) {
+                Uuid routerId = router.getRouterId();
+                routerUuidList.add(routerId);
+                dissociateRouterFromVpn(vpnId, routerId);
             }
         }
+        if (!routerUuidList.contains(vpnId) && vpnMap.getNetworkIds() != null) {
+            dissociateNetworksFromVpn(vpnId, vpnMap.getNetworkIds());
+        }
         // remove entire vpnMaps node
         deleteVpnMapsNode(vpnId);