Allow MDSALManager exceptions 82/73882/3
authorStephen Kitt <skitt@redhat.com>
Tue, 10 Jul 2018 15:26:05 +0000 (17:26 +0200)
committerStephen Kitt <skitt@redhat.com>
Thu, 12 Jul 2018 16:27:05 +0000 (18:27 +0200)
The exception-handling story in MDSALManager is currently
underwhelming: we basically swallow errors, or encapsulate them in
RuntimeException. To allow this to be changed, NetVirt has to allow
for exceptions coming from MDSALManager; this patch implements this.

Once MDSALManager’s exceptions have been defined, this will be
revisited to clean everything up and use specific exceptions.

JIRA: NETVIRT-1318
Change-Id: I66ad8c2643a03d64ccb4abed94628498636f9152
Signed-off-by: Stephen Kitt <skitt@redhat.com>
15 files changed:
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpServiceUtils.java
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanUtils.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/AbstractSnatService.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/EvpnDnatFlowProgrammer.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/EvpnNaptSwitchHA.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/EvpnSnatFlowProgrammer.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/ExternalRoutersListener.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FloatingIPListener.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NaptSwitchHA.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NatEvpnUtil.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NatUtil.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/SNATDefaultRouteProgrammer.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VpnFloatingIpHandler.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnManagerImpl.java

index cb8251c8a7f9da9c999d165497a8e78c3e93dead..db0bec0f6db5976f4580e3bf05dd660695f37008 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.netvirt.dhcpservice;
 import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
 
 import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -118,6 +119,9 @@ public final class DhcpServiceUtils {
 
     private DhcpServiceUtils() { }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public static void setupDhcpFlowEntry(@Nullable BigInteger dpId, short tableId, @Nullable String vmMacAddress,
                                           int addOrRemove,
                                           IMdsalApiManager mdsalUtil, DhcpServiceCounters dhcpServiceCounters,
@@ -135,7 +139,12 @@ public final class DhcpServiceUtils {
         if (addOrRemove == NwConstants.DEL_FLOW) {
             LOG.trace("Removing DHCP Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
             dhcpServiceCounters.removeDhcpFlow();
-            mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+            try {
+                mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+            } catch (Exception e) {
+                LOG.error("Error removing flow", e);
+                throw new RuntimeException("Error removing flow", e);
+            }
         } else {
             FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId,
                     getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY,
@@ -161,6 +170,9 @@ public final class DhcpServiceUtils {
                 .append(ipAddress).toString();
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public static void setupDhcpDropAction(BigInteger dpId, short tableId, String vmMacAddress, int addOrRemove,
                                            IMdsalApiManager mdsalUtil, DhcpServiceCounters dhcpServiceCounters,
                                            TypedReadWriteTransaction<Configuration> tx) {
@@ -177,7 +189,12 @@ public final class DhcpServiceUtils {
         if (addOrRemove == NwConstants.DEL_FLOW) {
             LOG.trace("Removing DHCP Drop Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
             dhcpServiceCounters.removeDhcpDropFlow();
-            mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+            try {
+                mdsalUtil.removeFlow(tx, dpId, getDhcpFlowRef(dpId, tableId, vmMacAddress), tableId);
+            } catch (Exception e) {
+                LOG.error("Error removing flow", e);
+                throw new RuntimeException("Error removing flow", e);
+            }
         } else {
             FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId,
                     getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY,
index cd513bebf32a4f05f59fced896aa585e822e5312..b2f6e311ccc6e8e1a5f5e0d7d7233e2e01824f3c 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.ListenableFuture;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -950,20 +951,28 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
         mdsalManager.addFlowToTx(interfaceInfo.getDpId(), flowEntry, writeFlowGroupTx);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public void removeFilterEqualsTable(ElanInstance elanInfo, InterfaceInfo interfaceInfo,
             TypedReadWriteTransaction<Configuration> flowTx) {
-        int ifTag = interfaceInfo.getInterfaceTag();
-        Flow flow = MDSALUtil.buildFlow(NwConstants.ELAN_FILTER_EQUALS_TABLE,
+        try {
+            int ifTag = interfaceInfo.getInterfaceTag();
+            Flow flow = MDSALUtil.buildFlow(NwConstants.ELAN_FILTER_EQUALS_TABLE,
                 getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "group"));
 
-        mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flow);
+            mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flow);
 
-        Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE,
+            Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE,
                 getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "drop"), 10, elanInfo.getElanInstanceName(), 0,
                 0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)),
                 getMatchesForFilterEqualsLPortTag(ifTag), MDSALUtil.buildInstructionsDrop());
 
-        mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flowEntity);
+            mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
     }
 
     private List<Bucket> getRemoteBCGroupBucketInfos(ElanInstance elanInfo, int bucketKeyStart,
index f6145e3a24498d988932feda62b049f1760d8053..f5c0d970fd3f7a9757a438d8403f3825f937b224 100755 (executable)
@@ -20,6 +20,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -1089,6 +1090,9 @@ public class ElanUtils {
         }
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private boolean executeDeleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
             boolean deleteSmac, String elanInstanceName, BigInteger srcdpId, Long elanTag, BigInteger dstDpId,
             TypedReadWriteTransaction<Configuration> flowTx) {
@@ -1097,31 +1101,44 @@ public class ElanUtils {
             isFlowsRemovedInSrcDpn = true;
             deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, flowTx);
         } else if (isDpnPresent(dstDpId)) {
-            mdsalManager
+            try {
+                mdsalManager
                     .removeFlow(flowTx, dstDpId,
-                            MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(
-                                    NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)));
+                        MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(
+                            NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)));
+            } catch (Exception e) {
+                LOG.error("Error removing flow", e);
+                throw new RuntimeException("Error removing flow", e);
+            }
             LOG.debug("Dmac flow entry deleted for elan:{}, logical interface port:{} and mac address:{} on dpn:{}",
                     elanInstanceName, interfaceInfo.getPortName(), macAddress, dstDpId);
         }
         return isFlowsRemovedInSrcDpn;
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void deleteSmacAndDmacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
             boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) {
         String elanInstanceName = elanInfo.getElanInstanceName();
         long ifTag = interfaceInfo.getInterfaceTag();
         BigInteger srcdpId = interfaceInfo.getDpId();
         Long elanTag = elanInfo.getElanTag();
-        if (deleteSmac) {
-            mdsalManager
-                    .removeFlow(flowTx, srcdpId,
-                            MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(
-                                    NwConstants.ELAN_SMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
-        }
-        mdsalManager.removeFlow(flowTx, srcdpId,
+        try {
+            if (deleteSmac) {
+                mdsalManager
+                        .removeFlow(flowTx, srcdpId,
+                                MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(
+                                        NwConstants.ELAN_SMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
+            }
+            mdsalManager.removeFlow(flowTx, srcdpId,
                 MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE,
-                        getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
+                    getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
         LOG.debug("All the required flows deleted for elan:{}, logical Interface port:{} and MAC address:{} on dpn:{}",
                 elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
     }
index ccf9dcb2aeb2e160d8e16a36e8eb4e8fe506819a..5899ef73bd4331432d855f7051dd4abf6b012a8f 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.netvirt.natservice.internal;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -369,6 +370,9 @@ public abstract class AbstractSnatService implements SnatServiceListener {
             NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     protected void removeSnatMissEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
         Long routerId, String routerName) {
         LOG.debug("installSnatMissEntry : Removing SNAT miss entry from switch {}", dpnId);
@@ -376,7 +380,12 @@ public abstract class AbstractSnatService implements SnatServiceListener {
         long groupId = createGroupId(getGroupIdKey(routerName));
 
         LOG.debug("removing the PSNAT to NAPTSwitch on DPN {} with GroupId: {}", dpnId, groupId);
-        mdsalManager.removeGroup(confTx, dpnId, groupId);
+        try {
+            mdsalManager.removeGroup(confTx, dpnId, groupId);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
 
         // Install miss entry pointing to group
         LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}",
@@ -469,10 +478,18 @@ public abstract class AbstractSnatService implements SnatServiceListener {
         mdsalManager.addFlow(confTx, flowEntity);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     protected void removeFlow(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpId, short tableId,
         String flowId) {
         LOG.trace("syncFlow : Removing Acl Flow DpnId {}, flowId {}", dpId, flowId);
-        mdsalManager.removeFlow(confTx, dpId, flowId, tableId);
+        try {
+            mdsalManager.removeFlow(confTx, dpId, flowId, tableId);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
     }
 
     protected long createGroupId(String groupIdKey) {
index d37fac2ea04f150cb717918a5fb0c02e6a8ddd19..34abd2c0849dc02ceea80fdee5adb619b4ecad25 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -379,6 +380,9 @@ public class EvpnDnatFlowProgrammer {
                 terminatingServiceTableFlowEntity, dpnId);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, TypedReadWriteTransaction<Configuration> confTx) {
         LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on DpnId {} "
                 + "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE, NwConstants.PDNAT_TABLE,
@@ -389,7 +393,12 @@ public class EvpnDnatFlowProgrammer {
                 NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.DNAT_FLOW_NAME),
                 6, String.format("%s:%d", "TST Flow Entry ", l3Vni), 0, 0,
                 COOKIE_TUNNEL.add(BigInteger.valueOf(l3Vni)), mkMatches, null);
-        mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
         LOG.debug("removeTunnelTableEntry : Successfully removed terminating service table flow {} on DpnId {}",
                 flowEntity, dpnId);
     }
index 5c27a1baa3c8a1acd1d5d26bde791cbf79f2c7d5..8032f5ddb7eaa8918ea7ff43ca479ff7c65ae286 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.netvirt.natservice.internal;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 
 import javax.inject.Inject;
@@ -41,6 +42,9 @@ public class EvpnNaptSwitchHA {
         this.idManager = idManager;
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public void evpnRemoveSnatFlowsInOldNaptSwitch(String routerName, long routerId, String vpnName,
             BigInteger naptSwitch, TypedReadWriteTransaction<Configuration> confTx) {
         //Handling VXLAN Provider type flow removal from old NAPT switch
@@ -79,7 +83,12 @@ public class EvpnNaptSwitchHA {
         LOG.info("evpnRemoveSnatFlowsInOldNaptSwitch: Remove the flow (table26->46) in table {} "
                 + "for the old napt switch with the DPN ID {} and router ID {}",
                 NwConstants.PSNAT_TABLE, naptSwitch, routerId);
-        mdsalManager.removeFlow(confTx, flowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
 
         //Remove the Terminating Service table entry which forwards the packet to Inbound NAPT Table (table36->44)
         LOG.info("evpnRemoveSnatFlowsInOldNaptSwitch : Remove the flow (table36->44) in table {} "
@@ -94,7 +103,12 @@ public class EvpnNaptSwitchHA {
         FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE, tsFlowRef);
         LOG.info("evpnRemoveSnatFlowsInOldNaptSwitch : Remove the flow in the {} for the active switch "
                 + "with the DPN ID {} and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, naptSwitch, routerId);
-        mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
 
     }
 
index a880a9d4fbb0b8f0093027cab35a07a50d86f02a..6693b5a392d633476e55d9f5344b8691ef00a598 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
@@ -275,6 +276,9 @@ public class EvpnSnatFlowProgrammer {
                 terminatingServiceTableFlowEntity, dpnId);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, TypedReadWriteTransaction<Configuration> confTx) {
         LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on NAPT DpnId {} "
                 + "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE,
@@ -286,7 +290,12 @@ public class EvpnSnatFlowProgrammer {
                 NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.SNAT_FLOW_NAME),
                 5, String.format("%s:%d", "TST Flow Entry ", l3Vni), 0, 0,
                 COOKIE_TUNNEL.add(BigInteger.valueOf(l3Vni)), mkMatches, null);
-        mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, dpnId, flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
         LOG.debug("removeTunnelTableEntry : Successfully removed terminating service table flow {} on DpnId {}",
                 flowEntity, dpnId);
     }
index 436592c8e4f3323a622d92a7dbb78bce427cdae6..ea51ec2c3e745fab8e32b2cc0fe39a08a95c8d36 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.net.Inet6Address;
 import java.net.InetAddress;
@@ -1901,165 +1902,181 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
         NatEvpnUtil.releaseLPortTagForRouter(dataBroker, idManager, routerName);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public void removeNaptFlowsFromActiveSwitch(long routerId, String routerName,
                                                 BigInteger dpnId, Uuid networkId, String vpnName,
                                                 @Nonnull Collection<String> externalIps,
                                                 Collection<Uuid> externalSubnetList,
                                                 TypedReadWriteTransaction<Configuration> confTx,
                                                 ProviderTypes extNwProvType) {
-        LOG.debug("removeNaptFlowsFromActiveSwitch : Remove NAPT flows from Active switch");
-        BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
-
-        //Remove the PSNAT entry which forwards the packet to Outbound NAPT Table (For the
-        // traffic which comes from the  VMs of the NAPT switches)
-        String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, routerName);
-        FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
-
-        LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
-                + "and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
-        mdsalManager.removeFlow(confTx, preSnatFlowEntity);
-
-        //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table (For the
-        // traffic which comes from the VMs of the non NAPT switches)
-        long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
+        try {
+            LOG.debug("removeNaptFlowsFromActiveSwitch : Remove NAPT flows from Active switch");
+            BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
+
+            //Remove the PSNAT entry which forwards the packet to Outbound NAPT Table (For the
+            // traffic which comes from the  VMs of the NAPT switches)
+            String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, routerName);
+            FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
+
+            LOG.info(
+                "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
+                    + "and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
+            mdsalManager.removeFlow(confTx, preSnatFlowEntity);
+
+            //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table (For the
+            // traffic which comes from the VMs of the non NAPT switches)
+            long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
                 routerName);
-        String tsFlowRef = getFlowRefTs(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tunnelId);
-        FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tsFlowRef);
-        LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
-                + "and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, dpnId, routerId);
-        mdsalManager.removeFlow(confTx, tsNatFlowEntity);
-
-        //Remove the flow table 25->44 from NAPT Switch
-        if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
-            NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, dpnId);
-        }
+            String tsFlowRef = getFlowRefTs(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tunnelId);
+            FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, tsFlowRef);
+            LOG.info(
+                "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
+                    + "and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, dpnId, routerId);
+            mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+
+            //Remove the flow table 25->44 from NAPT Switch
+            if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
+                NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, dpnId);
+            }
 
-        //Remove the Outbound flow entry which forwards the packet to FIB Table
-        LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {}"
-                + " and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
+            //Remove the Outbound flow entry which forwards the packet to FIB Table
+            LOG.info(
+                "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {}"
+                    + " and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
 
-        String outboundTcpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+            String outboundTcpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
                 NwConstants.IP_PROT_TCP);
-        FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
-            outboundTcpNatFlowRef);
-        mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
+            FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+                outboundTcpNatFlowRef);
+            mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
 
-        String outboundUdpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+            String outboundUdpNatFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
                 NwConstants.IP_PROT_UDP);
-        FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+            FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
                 outboundUdpNatFlowRef);
-        mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
+            mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
 
-        String icmpDropFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
+            String icmpDropFlowRef = getFlowRefOutbound(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId,
                 NwConstants.IP_PROT_ICMP);
-        FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+            FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
                 icmpDropFlowRef);
-        mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
-
-        removeNaptFibExternalOutputFlows(routerId, dpnId, networkId, externalIps, confTx);
-        //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
-        // External Subnet Vpn Id.
-        for (Uuid externalSubnetId : externalSubnetList) {
-            long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
-            if (subnetVpnId != -1) {
-                String natPfibSubnetFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
-                FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE,
+            mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
+
+            removeNaptFibExternalOutputFlows(routerId, dpnId, networkId, externalIps, confTx);
+            //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
+            // External Subnet Vpn Id.
+            for (Uuid externalSubnetId : externalSubnetList) {
+                long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
+                if (subnetVpnId != -1) {
+                    String natPfibSubnetFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
+                    FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE,
                         natPfibSubnetFlowRef);
-                mdsalManager.removeFlow(confTx, natPfibFlowEntity);
-                LOG.debug("removeNaptFlowsFromActiveSwitch : Removed the flow in table {} with external subnet "
-                        + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
+                    mdsalManager.removeFlow(confTx, natPfibFlowEntity);
+                    LOG.debug("removeNaptFlowsFromActiveSwitch : Removed the flow in table {} with external subnet "
+                            + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
                         subnetVpnId, dpnId);
+                }
             }
-        }
-
-        //Remove the NAPT PFIB TABLE which forwards the incoming packet to FIB Table matching on the router ID.
-        String natPfibFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
-        FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibFlowRef);
 
-        LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
-                + "and router ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, routerId);
-        mdsalManager.removeFlow(confTx, natPfibFlowEntity);
-
-        // Long vpnId = NatUtil.getVpnId(dataBroker, routerId);
-        // - This does not work since ext-routers is deleted already - no network info
-        //Get the VPN ID from the ExternalNetworks model
-        long vpnId = -1;
-        if (vpnName == null || vpnName.isEmpty()) {
-            // ie called from router delete cases
-            Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
-            LOG.debug("removeNaptFlowsFromActiveSwitch : vpnUuid is {}", vpnUuid);
-            if (vpnUuid != null) {
-                vpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
-                LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId {} for external  network {} router delete or "
+            //Remove the NAPT PFIB TABLE which forwards the incoming packet to FIB Table matching on the router ID.
+            String natPfibFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
+            FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibFlowRef);
+
+            LOG.info(
+                "removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch with the DPN ID {} "
+                    + "and router ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, routerId);
+            mdsalManager.removeFlow(confTx, natPfibFlowEntity);
+
+            // Long vpnId = NatUtil.getVpnId(dataBroker, routerId);
+            // - This does not work since ext-routers is deleted already - no network info
+            //Get the VPN ID from the ExternalNetworks model
+            long vpnId = -1;
+            if (vpnName == null || vpnName.isEmpty()) {
+                // ie called from router delete cases
+                Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
+                LOG.debug("removeNaptFlowsFromActiveSwitch : vpnUuid is {}", vpnUuid);
+                if (vpnUuid != null) {
+                    vpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
+                    LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId {} for external  network {} router delete or "
                         + "disableSNAT scenario", vpnId, networkId);
-            }
-        } else {
-            // ie called from disassociate vpn case
-            LOG.debug("removeNaptFlowsFromActiveSwitch : This is disassociate nw with vpn case with vpnName {}",
+                }
+            } else {
+                // ie called from disassociate vpn case
+                LOG.debug("removeNaptFlowsFromActiveSwitch : This is disassociate nw with vpn case with vpnName {}",
                     vpnName);
-            vpnId = NatUtil.getVpnId(dataBroker, vpnName);
-            LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId for disassociate nw with vpn scenario {}", vpnId);
-        }
+                vpnId = NatUtil.getVpnId(dataBroker, vpnName);
+                LOG.debug("removeNaptFlowsFromActiveSwitch : vpnId for disassociate nw with vpn scenario {}", vpnId);
+            }
 
-        if (vpnId != NatConstants.INVALID_ID) {
-            //Remove the NAPT PFIB TABLE which forwards the outgoing packet to FIB Table matching on the VPN ID.
-            String natPfibVpnFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, vpnId);
-            FlowEntity natPfibVpnFlowEntity =
-                NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibVpnFlowRef);
-            LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in {} for the active switch with the DPN ID {} "
-                    + "and VPN ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, vpnId);
-            mdsalManager.removeFlow(confTx, natPfibVpnFlowEntity);
-        }
+            if (vpnId != NatConstants.INVALID_ID) {
+                //Remove the NAPT PFIB TABLE which forwards the outgoing packet to FIB Table matching on the VPN ID.
+                String natPfibVpnFlowRef = getFlowRefTs(dpnId, NwConstants.NAPT_PFIB_TABLE, vpnId);
+                FlowEntity natPfibVpnFlowEntity =
+                    NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibVpnFlowRef);
+                LOG.info(
+                    "removeNaptFlowsFromActiveSwitch : Remove the flow in {} for the active switch with the DPN ID {} "
+                        + "and VPN ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, vpnId);
+                mdsalManager.removeFlow(confTx, natPfibVpnFlowEntity);
+            }
 
-        //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
-        IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
-        if (ipPortMapping == null) {
-            LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the IpPortMapping");
-            return;
-        }
+            //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
+            IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
+            if (ipPortMapping == null) {
+                LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the IpPortMapping");
+                return;
+            }
 
-        List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
-        for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
-            List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
-            for (IpPortMap ipPortMap : ipPortMaps) {
-                String ipPortInternal = ipPortMap.getIpPortInternal();
-                String[] ipPortParts = ipPortInternal.split(":");
-                if (ipPortParts.length != 2) {
-                    LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the Internal IP and port");
-                    return;
-                }
-                String internalIp = ipPortParts[0];
-                String internalPort = ipPortParts[1];
+            List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
+            for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
+                List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
+                for (IpPortMap ipPortMap : ipPortMaps) {
+                    String ipPortInternal = ipPortMap.getIpPortInternal();
+                    String[] ipPortParts = ipPortInternal.split(":");
+                    if (ipPortParts.length != 2) {
+                        LOG.error("removeNaptFlowsFromActiveSwitch : Unable to retrieve the Internal IP and port");
+                        return;
+                    }
+                    String internalIp = ipPortParts[0];
+                    String internalPort = ipPortParts[1];
 
-                //Build the flow for the outbound NAPT table
-                naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR + internalIp
+                    //Build the flow for the outbound NAPT table
+                    naptPacketInHandler.removeIncomingPacketMap(routerId + NatConstants.COLON_SEPARATOR + internalIp
                         + NatConstants.COLON_SEPARATOR + internalPort);
-                String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
-                    String.valueOf(routerId), internalIp, Integer.parseInt(internalPort));
-                FlowEntity outboundNaptFlowEntity =
-                    NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
+                    String switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE,
+                        String.valueOf(routerId), internalIp, Integer.parseInt(internalPort));
+                    FlowEntity outboundNaptFlowEntity =
+                        NatUtil.buildFlowEntity(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
 
-                LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch "
+                    LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active switch "
                         + "with the DPN ID {} and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
-                mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
+                    mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
 
-                IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
-                String externalIp = ipPortExternal.getIpAddress();
-                int externalPort = ipPortExternal.getPortNum();
+                    IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
+                    String externalIp = ipPortExternal.getIpAddress();
+                    int externalPort = ipPortExternal.getPortNum();
 
-                //Build the flow for the inbound NAPT table
-                switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE,
-                    String.valueOf(routerId), externalIp, externalPort);
-                FlowEntity inboundNaptFlowEntity =
-                    NatUtil.buildFlowEntity(dpnId, NwConstants.INBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
+                    //Build the flow for the inbound NAPT table
+                    switchFlowRef = NatUtil.getNaptFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE,
+                        String.valueOf(routerId), externalIp, externalPort);
+                    FlowEntity inboundNaptFlowEntity =
+                        NatUtil.buildFlowEntity(dpnId, NwConstants.INBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
 
-                LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active active switch "
+                    LOG.info("removeNaptFlowsFromActiveSwitch : Remove the flow in the {} for the active active switch "
                         + "with the DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, dpnId, routerId);
-                mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
+                    mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
+                }
             }
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
         }
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     protected void removeNaptFibExternalOutputFlows(long routerId, BigInteger dpnId, Uuid networkId,
                                                     @Nonnull Collection<String> externalIps,
                                                     TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
@@ -2086,7 +2103,12 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
                 + " with the DPN ID {} and router ID {} and IP {} flowRef {}",
                 NwConstants.NAPT_PFIB_TABLE, dpnId, routerId, extIp, naptFlowRef);
             FlowEntity natPfibVpnFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, naptFlowRef);
-            mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+            try {
+                mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+            } catch (Exception e) {
+                LOG.error("Error removing flow", e);
+                throw new RuntimeException("Error removing flow", e);
+            }
         }
     }
 
@@ -2097,6 +2119,9 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
         return ip;
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public void removeNaptFlowsFromActiveSwitchInternetVpn(long routerId, String routerName,
                                                            BigInteger dpnId, Uuid networkId, String vpnName,
                                                            TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
@@ -2122,7 +2147,12 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
                 NatUtil.buildFlowEntity(dpnId, NwConstants.NAPT_PFIB_TABLE, natPfibVpnFlowRef);
             LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the active switch "
                     + "with the DPN ID {} and VPN ID {}", NwConstants.NAPT_PFIB_TABLE, dpnId, vpnId);
-            mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+            try {
+                mdsalManager.removeFlow(writeFlowInvTx, natPfibVpnFlowEntity);
+            } catch (Exception e) {
+                LOG.error("Error removing flow", e);
+                throw new RuntimeException("Error removing flow", e);
+            }
 
             // Remove IP-PORT active NAPT entries and release port from IdManager
             // For the router ID get the internal IP , internal port and the corresponding
@@ -2157,7 +2187,12 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
                     LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the "
                             + "active switch with the DPN ID {} and router ID {}",
                             NwConstants.OUTBOUND_NAPT_TABLE, dpnId, routerId);
-                    mdsalManager.removeFlow(writeFlowInvTx, outboundNaptFlowEntity);
+                    try {
+                        mdsalManager.removeFlow(writeFlowInvTx, outboundNaptFlowEntity);
+                    } catch (Exception e) {
+                        LOG.error("Error removing flow", e);
+                        throw new RuntimeException("Error removing flow", e);
+                    }
 
                     IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
                     String externalIp = ipPortExternal.getIpAddress();
@@ -2172,7 +2207,12 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
                     LOG.info("removeNaptFlowsFromActiveSwitchInternetVpn : Remove the flow in the {} for the "
                             + "active active switch with the DPN ID {} and router ID {}",
                             NwConstants.INBOUND_NAPT_TABLE, dpnId, routerId);
-                    mdsalManager.removeFlow(writeFlowInvTx, inboundNaptFlowEntity);
+                    try {
+                        mdsalManager.removeFlow(writeFlowInvTx, inboundNaptFlowEntity);
+                    } catch (Exception e) {
+                        LOG.error("Error removing flow", e);
+                        throw new RuntimeException("Error removing flow", e);
+                    }
 
                     // Finally release port from idmanager
                     String internalIpPort = internalIp + ":" + internalPort;
@@ -2188,6 +2228,9 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
         }
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public void removeFlowsFromNonActiveSwitches(long routerId, String routerName,
             BigInteger naptSwitchDpnId, TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
         LOG.debug("removeFlowsFromNonActiveSwitches : Remove NAPT related flows from non active switches");
@@ -2199,29 +2242,35 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
             LOG.error("removeFlowsFromNonActiveSwitches : Unable to get the swithces for the router {}", routerName);
             return;
         }
-        for (BigInteger dpnId : allSwitchList) {
-            if (!naptSwitchDpnId.equals(dpnId)) {
-                LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
+        try {
+            for (BigInteger dpnId : allSwitchList) {
+                if (!naptSwitchDpnId.equals(dpnId)) {
+                    LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
 
-                //Remove the PSNAT entry which forwards the packet to Terminating Service table
-                String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, String.valueOf(routerName));
-                FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
+                    //Remove the PSNAT entry which forwards the packet to Terminating Service table
+                    String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, String.valueOf(routerName));
+                    FlowEntity preSnatFlowEntity =
+                        NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
 
-                LOG.info("removeFlowsFromNonActiveSwitches : Remove the flow in the {} for the non active switch "
+                    LOG.info("removeFlowsFromNonActiveSwitches : Remove the flow in the {} for the non active switch "
                         + "with the DPN ID {} and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
-                mdsalManager.removeFlow(removeFlowInvTx, preSnatFlowEntity);
+                    mdsalManager.removeFlow(removeFlowInvTx, preSnatFlowEntity);
 
-                //Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
-                long groupId = createGroupId(getGroupIdKey(routerName));
-                List<BucketInfo> listBucketInfo = new ArrayList<>();
-                GroupEntity preSnatGroupEntity =
-                    MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
+                    //Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
+                    long groupId = createGroupId(getGroupIdKey(routerName));
+                    List<BucketInfo> listBucketInfo = new ArrayList<>();
+                    GroupEntity preSnatGroupEntity =
+                        MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
 
-                LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with "
+                    LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with "
                         + "the DPN ID {} and router ID {}", groupId, dpnId, routerId);
-                mdsalManager.removeGroup(removeFlowInvTx, preSnatGroupEntity);
+                    mdsalManager.removeGroup(removeFlowInvTx, preSnatGroupEntity);
 
+                }
             }
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
         }
     }
 
@@ -2499,6 +2548,9 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
         NatUtil.removePrefixFromBGP(bgpManager, fibManager, rd, externalIp, vpnName, LOG);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeTunnelTableEntry(BigInteger dpnId, long serviceId,
         TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
         LOG.info("removeTunnelTableEntry : called with DpnId = {} and label = {}", dpnId, serviceId);
@@ -2509,10 +2561,18 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
             getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""),
             5, String.format("%s:%d", "TST Flow Entry ", serviceId), 0, 0,
             COOKIE_TUNNEL.add(BigInteger.valueOf(serviceId)), mkMatches, null);
-        mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+        try {
+            mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
         LOG.debug("removeTunnelTableEntry : dpID {} : label : {} removed successfully", dpnId, serviceId);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeLFibTableEntry(BigInteger dpnId, long serviceId,
         TypedReadWriteTransaction<Configuration> writeFlowInvTx) {
         List<MatchInfo> matches = new ArrayList<>();
@@ -2527,7 +2587,12 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
             10, flowRef, 0, 0,
             COOKIE_VM_LFIB_TABLE, matches, null);
 
-        mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+        try {
+            mdsalManager.removeFlow(writeFlowInvTx, dpnId, flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
 
         LOG.debug("removeLFibTableEntry : dpID : {} label : {} removed successfully", dpnId, serviceId);
     }
index 0891ad544d540ac442953915c4f0ae83d5562733..c0b45ecfce0ad98e523afcc519d721c1e5ae6e17 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.netvirt.natservice.internal;
 import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
 
 import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -301,14 +302,22 @@ public class FloatingIPListener extends AsyncDataTreeChangeListenerBase<Internal
         }
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeDNATTblEntry(BigInteger dpnId, String internalIp, String externalIp, long routerId,
-        TypedReadWriteTransaction<Configuration> confTx) {
-        FlowEntity preFlowEntity = buildPreDNATDeleteFlowEntity(dpnId, externalIp, routerId);
-        mdsalManager.removeFlow(confTx, preFlowEntity);
+            TypedReadWriteTransaction<Configuration> confTx) {
+        try {
+            FlowEntity preFlowEntity = buildPreDNATDeleteFlowEntity(dpnId, externalIp, routerId);
+            mdsalManager.removeFlow(confTx, preFlowEntity);
 
-        FlowEntity flowEntity = buildDNATDeleteFlowEntity(dpnId, internalIp, routerId);
-        if (flowEntity != null) {
-            mdsalManager.removeFlow(confTx, flowEntity);
+            FlowEntity flowEntity = buildDNATDeleteFlowEntity(dpnId, internalIp, routerId);
+            if (flowEntity != null) {
+                mdsalManager.removeFlow(confTx, flowEntity);
+            }
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
         }
     }
 
@@ -324,14 +333,22 @@ public class FloatingIPListener extends AsyncDataTreeChangeListenerBase<Internal
         }
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeSNATTblEntry(BigInteger dpnId, String internalIp, String externalIp, long routerId, long vpnId,
                                     TypedReadWriteTransaction<Configuration> removeFlowInvTx) {
-        FlowEntity preFlowEntity = buildPreSNATDeleteFlowEntity(dpnId, internalIp, routerId);
-        mdsalManager.removeFlow(removeFlowInvTx, preFlowEntity);
+        try {
+            FlowEntity preFlowEntity = buildPreSNATDeleteFlowEntity(dpnId, internalIp, routerId);
+            mdsalManager.removeFlow(removeFlowInvTx, preFlowEntity);
 
-        FlowEntity flowEntity = buildSNATDeleteFlowEntity(dpnId, externalIp, vpnId);
-        if (flowEntity != null) {
-            mdsalManager.removeFlow(removeFlowInvTx, flowEntity);
+            FlowEntity flowEntity = buildSNATDeleteFlowEntity(dpnId, externalIp, vpnId);
+            if (flowEntity != null) {
+                mdsalManager.removeFlow(removeFlowInvTx, flowEntity);
+            }
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
         }
     }
 
index 09586499c66d0bd50ed70817b1660bacc4168834..246df91b98e39e026abe529ddc04edbf15eaa2e5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.netvirt.natservice.internal;
 
 import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -176,213 +177,228 @@ public class NaptSwitchHA {
         }
     }*/
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     protected void removeSnatFlowsInOldNaptSwitch(String routerName, Long routerId, BigInteger naptSwitch,
                                                   Map<String, Long> externalIpmap,
                                                   TypedReadWriteTransaction<Configuration> confTx) {
 
-        //remove SNAT flows in old NAPT SWITCH
-        Uuid networkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
-        String vpnName = getExtNetworkVpnName(routerName, networkId);
-        if (vpnName == null) {
-            LOG.error("removeSnatFlowsInOldNaptSwitch : Vpn is not associated to externalN/w of router {}",
+        try {
+            //remove SNAT flows in old NAPT SWITCH
+            Uuid networkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
+            String vpnName = getExtNetworkVpnName(routerName, networkId);
+            if (vpnName == null) {
+                LOG.error("removeSnatFlowsInOldNaptSwitch : Vpn is not associated to externalN/w of router {}",
                     routerName);
-            return;
-        }
-        ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, networkId);
-        if (extNwProvType == null) {
-            LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the External Network Provider Type "
+                return;
+            }
+            ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, networkId);
+            if (extNwProvType == null) {
+                LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the External Network Provider Type "
                     + "for Router {}", routerName);
-            return;
-        }
-        if (extNwProvType == ProviderTypes.VXLAN) {
-            evpnNaptSwitchHA.evpnRemoveSnatFlowsInOldNaptSwitch(routerName, routerId, vpnName, naptSwitch, confTx);
-        } else {
-            //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table
-            long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
+                return;
+            }
+            if (extNwProvType == ProviderTypes.VXLAN) {
+                evpnNaptSwitchHA.evpnRemoveSnatFlowsInOldNaptSwitch(routerName, routerId, vpnName, naptSwitch, confTx);
+            } else {
+                //Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table
+                long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId,
                     routerName);
-            String tsFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
+                String tsFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
                     tunnelId);
-            FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
+                FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE,
                     tsFlowRef);
 
-            LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
+                LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
                     + "with the DPN ID {} and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, naptSwitch, routerId);
-            mdsalManager.removeFlow(confTx, tsNatFlowEntity);
-        }
-        if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
-            //Remove the flow table 25->44 If there is no FIP Match on table 25 (PDNAT_TABLE)
-            NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, naptSwitch);
-        }
-        //Remove the Outbound flow entry which forwards the packet to Outbound NAPT Table
-        LOG.info("Remove the flow in table {} for the old napt switch with the DPN ID {} and router ID {}",
+                mdsalManager.removeFlow(confTx, tsNatFlowEntity);
+            }
+            if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
+                //Remove the flow table 25->44 If there is no FIP Match on table 25 (PDNAT_TABLE)
+                NatUtil.removePreDnatToSnatTableEntry(confTx, mdsalManager, naptSwitch);
+            }
+            //Remove the Outbound flow entry which forwards the packet to Outbound NAPT Table
+            LOG.info("Remove the flow in table {} for the old napt switch with the DPN ID {} and router ID {}",
                 NwConstants.OUTBOUND_NAPT_TABLE, naptSwitch, routerId);
 
-        String outboundTcpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
-            NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_TCP);
-        FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
-            NwConstants.OUTBOUND_NAPT_TABLE, outboundTcpNatFlowRef);
-        mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
+            String outboundTcpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+                NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_TCP);
+            FlowEntity outboundTcpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
+                NwConstants.OUTBOUND_NAPT_TABLE, outboundTcpNatFlowRef);
+            mdsalManager.removeFlow(confTx, outboundTcpNatFlowEntity);
 
-        String outboundUdpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+            String outboundUdpNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
                 NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_UDP);
-        FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
+            FlowEntity outboundUdpNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch,
                 NwConstants.OUTBOUND_NAPT_TABLE, outboundUdpNatFlowRef);
-        mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
+            mdsalManager.removeFlow(confTx, outboundUdpNatFlowEntity);
 
-        String icmpDropFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
+            String icmpDropFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch,
                 NwConstants.OUTBOUND_NAPT_TABLE, routerId, NwConstants.IP_PROT_ICMP);
-        FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
+            FlowEntity icmpDropFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
                 icmpDropFlowRef);
-        mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
+            mdsalManager.removeFlow(confTx, icmpDropFlowEntity);
 
-        //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
-        // External Subnet Vpn Id.
-        Collection<Uuid> externalSubnetIdsForRouter = NatUtil.getExternalSubnetIdsForRouter(dataBroker,
+            //Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
+            // External Subnet Vpn Id.
+            Collection<Uuid> externalSubnetIdsForRouter = NatUtil.getExternalSubnetIdsForRouter(dataBroker,
                 routerName);
-        for (Uuid externalSubnetId : externalSubnetIdsForRouter) {
-            long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
-            if (subnetVpnId != -1) {
-                String natPfibSubnetFlowRef = externalRouterListener.getFlowRefTs(naptSwitch,
+            for (Uuid externalSubnetId : externalSubnetIdsForRouter) {
+                long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
+                if (subnetVpnId != -1) {
+                    String natPfibSubnetFlowRef = externalRouterListener.getFlowRefTs(naptSwitch,
                         NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
-                FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE,
+                    FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE,
                         natPfibSubnetFlowRef);
-                mdsalManager.removeFlow(confTx, natPfibFlowEntity);
-                LOG.debug("removeSnatFlowsInOldNaptSwitch : Removed the flow in table {} with external subnet "
-                                + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
+                    mdsalManager.removeFlow(confTx, natPfibFlowEntity);
+                    LOG.debug("removeSnatFlowsInOldNaptSwitch : Removed the flow in table {} with external subnet "
+                            + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE,
                         subnetVpnId, naptSwitch);
+                }
             }
-        }
 
-        // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for inbound traffic
-        // matching on the router ID.
-        String naptPFibflowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, routerId);
-        FlowEntity naptPFibFlowEntity =
-            NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptPFibflowRef);
-        LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
+            // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for inbound traffic
+            // matching on the router ID.
+            String naptPFibflowRef =
+                externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, routerId);
+            FlowEntity naptPFibFlowEntity =
+                NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptPFibflowRef);
+            LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch "
                 + "with the DPN ID {} and router ID {}", NwConstants.NAPT_PFIB_TABLE, naptSwitch, routerId);
-        mdsalManager.removeFlow(confTx, naptPFibFlowEntity);
-
-        // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for outbound traffic
-        // matching on the vpn ID.
-        boolean switchSharedByRouters = false;
-        Uuid extNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
-        if (extNetworkId != null) {
-            List<String> routerNamesAssociated = getRouterIdsForExtNetwork(extNetworkId);
-            for (String routerNameAssociated : routerNamesAssociated) {
-                if (!routerNameAssociated.equals(routerName)) {
-                    Long routerIdAssociated = NatUtil.getVpnId(dataBroker, routerNameAssociated);
-                    BigInteger naptDpn = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerNameAssociated);
-                    if (naptDpn != null && naptDpn.equals(naptSwitch)) {
-                        LOG.debug("removeSnatFlowsInOldNaptSwitch : Napt switch {} is also acting as primary "
+            mdsalManager.removeFlow(confTx, naptPFibFlowEntity);
+
+            // Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for outbound traffic
+            // matching on the vpn ID.
+            boolean switchSharedByRouters = false;
+            Uuid extNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
+            if (extNetworkId != null) {
+                List<String> routerNamesAssociated = getRouterIdsForExtNetwork(extNetworkId);
+                for (String routerNameAssociated : routerNamesAssociated) {
+                    if (!routerNameAssociated.equals(routerName)) {
+                        Long routerIdAssociated = NatUtil.getVpnId(dataBroker, routerNameAssociated);
+                        BigInteger naptDpn = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerNameAssociated);
+                        if (naptDpn != null && naptDpn.equals(naptSwitch)) {
+                            LOG.debug("removeSnatFlowsInOldNaptSwitch : Napt switch {} is also acting as primary "
                                 + "for router {}", naptSwitch, routerIdAssociated);
-                        switchSharedByRouters = true;
-                        break;
+                            switchSharedByRouters = true;
+                            break;
+                        }
                     }
                 }
-            }
-            if (!switchSharedByRouters) {
-                Long vpnId = getVpnIdForRouter(routerId, extNetworkId);
-                if (vpnId != NatConstants.INVALID_ID) {
-                    String naptFibflowRef =
+                if (!switchSharedByRouters) {
+                    Long vpnId = getVpnIdForRouter(routerId, extNetworkId);
+                    if (vpnId != NatConstants.INVALID_ID) {
+                        String naptFibflowRef =
                             externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, vpnId);
-                    FlowEntity naptFibFlowEntity =
+                        FlowEntity naptFibFlowEntity =
                             NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptFibflowRef);
-                    LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch"
+                        LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch"
                             + " with the DPN ID {} and vpnId {}", NwConstants.NAPT_PFIB_TABLE, naptSwitch, vpnId);
-                    mdsalManager.removeFlow(confTx, naptFibFlowEntity);
-                } else {
-                    LOG.error("removeSnatFlowsInOldNaptSwitch : Invalid vpnId retrieved for routerId {}",
+                        mdsalManager.removeFlow(confTx, naptFibFlowEntity);
+                    } else {
+                        LOG.error("removeSnatFlowsInOldNaptSwitch : Invalid vpnId retrieved for routerId {}",
                             routerId);
-                    return;
+                        return;
+                    }
                 }
             }
-        }
 
-        //Remove Fib entries,tables 20->44 ,36-> 44
-        String gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
-        if (externalIpmap != null && !externalIpmap.isEmpty()) {
-            for (Entry<String, Long> entry : externalIpmap.entrySet()) {
-                String externalIp = entry.getKey();
-                Long label = entry.getValue();
-                externalRouterListener.delFibTsAndReverseTraffic(naptSwitch, routerId, externalIp, vpnName,
+            //Remove Fib entries,tables 20->44 ,36-> 44
+            String gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
+            if (externalIpmap != null && !externalIpmap.isEmpty()) {
+                for (Entry<String, Long> entry : externalIpmap.entrySet()) {
+                    String externalIp = entry.getKey();
+                    Long label = entry.getValue();
+                    externalRouterListener.delFibTsAndReverseTraffic(naptSwitch, routerId, externalIp, vpnName,
                         extNetworkId, label, gwMacAddress, true, confTx);
-                LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} "
+                    LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} "
                         + "for router {} and externalIps {} label {}", naptSwitch, routerId, externalIp, label);
-            }
-        } else {
-            List<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerName);
-            if (networkId != null) {
-                externalRouterListener.clearFibTsAndReverseTraffic(naptSwitch, routerId, networkId,
+                }
+            } else {
+                List<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerName);
+                if (networkId != null) {
+                    externalRouterListener.clearFibTsAndReverseTraffic(naptSwitch, routerId, networkId,
                         externalIps, null, gwMacAddress, confTx);
-                LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} for "
-                        + "router {} with networkId {} and externalIps {}", naptSwitch, routerId, networkId,
+                    LOG.debug(
+                        "removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} for "
+                            + "router {} with networkId {} and externalIps {}", naptSwitch, routerId, networkId,
                         externalIps);
-            } else {
-                LOG.debug("removeSnatFlowsInOldNaptSwitch : External network not associated to router {}", routerId);
-            }
-            externalRouterListener.removeNaptFibExternalOutputFlows(routerId, naptSwitch, extNetworkId,
+                } else {
+                    LOG.debug("removeSnatFlowsInOldNaptSwitch : External network not associated to router {}",
+                        routerId);
+                }
+                externalRouterListener.removeNaptFibExternalOutputFlows(routerId, naptSwitch, extNetworkId,
                     externalIps, confTx);
-        }
+            }
 
-        //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
-        IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
-        if (ipPortMapping == null || ipPortMapping.getIntextIpProtocolType() == null
-            || ipPortMapping.getIntextIpProtocolType().isEmpty()) {
-            LOG.warn("removeSnatFlowsInOldNaptSwitch : No Internal Ip Port mapping associated to router {}, "
+            //For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
+            IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
+            if (ipPortMapping == null || ipPortMapping.getIntextIpProtocolType() == null
+                || ipPortMapping.getIntextIpProtocolType().isEmpty()) {
+                LOG.warn("removeSnatFlowsInOldNaptSwitch : No Internal Ip Port mapping associated to router {}, "
                     + "no flows need to be removed in oldNaptSwitch {}", routerId, naptSwitch);
-            return;
-        }
-        BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
-        List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
-        for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
-            if (intextIpProtocolType.getIpPortMap() == null || intextIpProtocolType.getIpPortMap().isEmpty()) {
-                LOG.debug("removeSnatFlowsInOldNaptSwitch : No {} session associated to router {},"
-                        + "no flows need to be removed in oldNaptSwitch {}",
-                        intextIpProtocolType.getProtocol(), routerId, naptSwitch);
-                break;
+                return;
             }
-            List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
-            for (IpPortMap ipPortMap : ipPortMaps) {
-                String ipPortInternal = ipPortMap.getIpPortInternal();
-                String[] ipPortParts = ipPortInternal.split(":");
-                if (ipPortParts.length != 2) {
-                    LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the Internal IP and port");
-                    continue;
+            BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
+            List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
+            for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
+                if (intextIpProtocolType.getIpPortMap() == null || intextIpProtocolType.getIpPortMap().isEmpty()) {
+                    LOG.debug("removeSnatFlowsInOldNaptSwitch : No {} session associated to router {},"
+                            + "no flows need to be removed in oldNaptSwitch {}",
+                        intextIpProtocolType.getProtocol(), routerId, naptSwitch);
+                    break;
                 }
-                String internalIp = ipPortParts[0];
-                String internalPort = ipPortParts[1];
-
-                //Build and remove flow in outbound NAPT table
-                String switchFlowRef =
-                    NatUtil.getNaptFlowRef(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, String.valueOf(routerId),
-                    internalIp, Integer.parseInt(internalPort));
-                FlowEntity outboundNaptFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
-                    cookieSnatFlow, switchFlowRef);
-
-                LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch "
+                List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
+                for (IpPortMap ipPortMap : ipPortMaps) {
+                    String ipPortInternal = ipPortMap.getIpPortInternal();
+                    String[] ipPortParts = ipPortInternal.split(":");
+                    if (ipPortParts.length != 2) {
+                        LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the Internal IP and port");
+                        continue;
+                    }
+                    String internalIp = ipPortParts[0];
+                    String internalPort = ipPortParts[1];
+
+                    //Build and remove flow in outbound NAPT table
+                    String switchFlowRef =
+                        NatUtil.getNaptFlowRef(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, String.valueOf(routerId),
+                            internalIp, Integer.parseInt(internalPort));
+                    FlowEntity outboundNaptFlowEntity =
+                        NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE,
+                            cookieSnatFlow, switchFlowRef);
+
+                    LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch "
                         + "with the DPN ID {} and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, naptSwitch, routerId);
-                mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
+                    mdsalManager.removeFlow(confTx, outboundNaptFlowEntity);
 
-                IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
-                if (ipPortExternal == null) {
-                    LOG.debug("removeSnatFlowsInOldNaptSwitch : External Ipport mapping not found for internalIp {} "
-                            + "with port {} for router {}", internalIp, internalPort, routerId);
-                    continue;
+                    IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
+                    if (ipPortExternal == null) {
+                        LOG.debug(
+                            "removeSnatFlowsInOldNaptSwitch : External Ipport mapping not found for internalIp {} "
+                                + "with port {} for router {}", internalIp, internalPort, routerId);
+                        continue;
+                    }
+                    String externalIp = ipPortExternal.getIpAddress();
+                    int externalPort = ipPortExternal.getPortNum();
+
+                    //Build and remove flow in  inbound NAPT table
+                    switchFlowRef =
+                        NatUtil.getNaptFlowRef(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, String.valueOf(routerId),
+                            externalIp, externalPort);
+                    FlowEntity inboundNaptFlowEntity =
+                        NatUtil.buildFlowEntity(naptSwitch, NwConstants.INBOUND_NAPT_TABLE,
+                            cookieSnatFlow, switchFlowRef);
+
+                    LOG.info(
+                        "removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch with the "
+                            + "DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, naptSwitch, routerId);
+                    mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
                 }
-                String externalIp = ipPortExternal.getIpAddress();
-                int externalPort = ipPortExternal.getPortNum();
-
-                //Build and remove flow in  inbound NAPT table
-                switchFlowRef =
-                    NatUtil.getNaptFlowRef(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, String.valueOf(routerId),
-                        externalIp, externalPort);
-                FlowEntity inboundNaptFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INBOUND_NAPT_TABLE,
-                    cookieSnatFlow, switchFlowRef);
-
-                LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch with the "
-                        + "DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, naptSwitch, routerId);
-                mdsalManager.removeFlow(confTx, inboundNaptFlowEntity);
             }
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
         }
     }
 
index b4f6ad6935190dcc7b85a05d9fe750936812d14e..fddcaf39eb3ffaa3ea931de464a9eeff91192dc2 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.netvirt.natservice.internal;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -219,6 +220,9 @@ public final class NatEvpnUtil {
                 l3GwMacTableFlowEntity, dpnId);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     static void removeL3GwMacTableEntry(final BigInteger dpnId, final long vpnId, final String macAddress,
         IMdsalApiManager mdsalManager, TypedReadWriteTransaction<Configuration> confTx) {
         List<MatchInfo> matchInfo = new ArrayList<>();
@@ -232,7 +236,12 @@ public final class NatEvpnUtil {
         Flow l3GwMacTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_GW_MAC_TABLE,
                 flowRef, 21, flowRef, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, matchInfo, null);
 
-        mdsalManager.removeFlow(confTx, dpnId, l3GwMacTableFlowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, dpnId, l3GwMacTableFlowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
         LOG.debug("removeL3GwMacTableEntry : Successfully removed flow entity {} on DPN = {}",
                 l3GwMacTableFlowEntity, dpnId);
     }
index 26e9035b274e8d5a9cc6b80adad384e57573f469..b895bbf31a9e48017a1e761fb67872ce1afca9f5 100644 (file)
@@ -1924,6 +1924,9 @@ public final class NatUtil {
                 preDnatToSnatTableFlowEntity,  naptDpnId);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     public static void removePreDnatToSnatTableEntry(TypedReadWriteTransaction<Configuration> confTx,
         IMdsalApiManager mdsalManager, BigInteger naptDpnId) {
         LOG.debug("removePreDnatToSnatTableEntry : Remove Pre-DNAT table {} --> table {} flow on NAPT DpnId {} ",
@@ -1931,7 +1934,12 @@ public final class NatUtil {
         String flowRef = getFlowRefPreDnatToSnat(naptDpnId, NwConstants.PDNAT_TABLE, "PreDNATToSNAT");
         Flow preDnatToSnatTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.PDNAT_TABLE,flowRef,
                 5, flowRef, 0, 0,  NwConstants.COOKIE_DNAT_TABLE, null, null);
-        mdsalManager.removeFlow(confTx, naptDpnId, preDnatToSnatTableFlowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, naptDpnId, preDnatToSnatTableFlowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
         LOG.debug("removePreDnatToSnatTableEntry: Successfully removed Pre-DNAT flow {} on NAPT DpnId = {}",
                 preDnatToSnatTableFlowEntity, naptDpnId);
     }
index 26adc77f18bc722150bc43d898a07e0b48579be5..c5da04cd17759b2bdb02a822653fd68b1151e4d5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.netvirt.natservice.internal;
 
 import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -163,6 +164,9 @@ public class SNATDefaultRouteProgrammer {
         mdsalManager.installFlow(flowEntity);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     void removeDefNATRouteInDPN(BigInteger dpnId, long vpnId, TypedReadWriteTransaction<Configuration> confTx) {
         FlowEntity flowEntity = buildDefNATFlowEntity(dpnId, vpnId);
         if (flowEntity == null) {
@@ -171,9 +175,17 @@ public class SNATDefaultRouteProgrammer {
             return;
         }
         natServiceCounters.removeDefaultNatFlow();
-        mdsalManager.removeFlow(confTx, flowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     void removeDefNATRouteInDPN(BigInteger dpnId, long bgpVpnId, long routerId,
         TypedReadWriteTransaction<Configuration> confTx) {
         FlowEntity flowEntity = buildDefNATFlowEntity(dpnId, bgpVpnId, routerId);
@@ -183,7 +195,12 @@ public class SNATDefaultRouteProgrammer {
             return;
         }
         natServiceCounters.removeDefaultNatFlow();
-        mdsalManager.removeFlow(confTx, flowEntity);
+        try {
+            mdsalManager.removeFlow(confTx, flowEntity);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
     }
 
     void addOrDelDefaultFibRouteToSNATForSubnet(Subnets subnet, String networkId, int flowAction, long vpnId) {
index f5ac94c77b0c185499eb91697e4fb702181363f5..30f2b3ecf2554540d71157d1c863843a47b6ea5c 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -409,13 +410,21 @@ public class VpnFloatingIpHandler implements FloatingIPHandler {
                 + NwConstants.FLOWID_SEPARATOR + ipAddress;
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeTunnelTableEntry(BigInteger dpnId, long serviceId,
         TypedReadWriteTransaction<Configuration> confTx) {
 
         LOG.debug("removeTunnelTableEntry : called with DpnId = {} and label = {}", dpnId, serviceId);
-        mdsalManager.removeFlow(confTx, dpnId,
-            new FlowKey(new FlowId(getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""))),
-            NwConstants.INTERNAL_TUNNEL_TABLE);
+        try {
+            mdsalManager.removeFlow(confTx, dpnId,
+                new FlowKey(new FlowId(getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""))),
+                NwConstants.INTERNAL_TUNNEL_TABLE);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
         LOG.debug("removeTunnelTableEntry : Terminating service Entry for dpID {} : label : {} removed successfully",
                 dpnId, serviceId);
     }
@@ -471,6 +480,9 @@ public class VpnFloatingIpHandler implements FloatingIPHandler {
         LOG.debug("makeLFibTableEntry : LFIB Entry for dpID {} : label : {} modified successfully", dpId, serviceId);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeLFibTableEntry(BigInteger dpnId, long serviceId,
         TypedReadWriteTransaction<Configuration> confTx) {
 
@@ -478,7 +490,12 @@ public class VpnFloatingIpHandler implements FloatingIPHandler {
 
         LOG.debug("removeLFibTableEntry : removing LFib entry with flow ref {}", flowRef);
 
-        mdsalManager.removeFlow(confTx, dpnId, new FlowKey(new FlowId(flowRef)), NwConstants.L3_LFIB_TABLE);
+        try {
+            mdsalManager.removeFlow(confTx, dpnId, new FlowKey(new FlowId(flowRef)), NwConstants.L3_LFIB_TABLE);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
 
         LOG.debug("removeLFibTableEntry : LFIB Entry for dpID : {} label : {} removed successfully",
                 dpnId, serviceId);
index 4c82220d3dd24fc88351c83fb90cbbb30dd2e42b..61bee964cf633958e2c6b1b5743064c1bc50317c 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -457,11 +458,19 @@ public class VpnManagerImpl implements IVpnManager {
         mdsalManager.removeFlowToTx(flowEntity, tx);
     }
 
+    // TODO skitt Fix the exception handling here
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     private void removeGwMac(String srcMacAddress, TypedReadWriteTransaction<Configuration> tx, long vpnId,
         BigInteger dpId, long subnetVpnId) {
-        mdsalManager.removeFlow(tx, dpId,
-            VpnUtil.getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, srcMacAddress, subnetVpnId),
-            NwConstants.L3_GW_MAC_TABLE);
+        try {
+            mdsalManager.removeFlow(tx, dpId,
+                VpnUtil.getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, srcMacAddress, subnetVpnId),
+                NwConstants.L3_GW_MAC_TABLE);
+        } catch (Exception e) {
+            LOG.error("Error removing flow", e);
+            throw new RuntimeException("Error removing flow", e);
+        }
     }
 
     @Override