Cleaning Oper DS during scalein 60/83360/4
authorNidhi Adhvaryu <nidhi.adhvaryu@ericsson.com>
Mon, 18 Nov 2019 06:58:08 +0000 (12:28 +0530)
committerNidhi Adhvaryu <nidhi.adhvaryu@ericsson.com>
Mon, 18 Nov 2019 07:25:51 +0000 (12:55 +0530)
- to key tunnel remove events on tunnel name
- uses tombstone api

Signed-off-by: Nidhi Adhvaryu <nidhi.adhvaryu@ericsson.com>
Change-Id: I46470cc20c477c2301e20d2da480a2746d949ee3

itm/itm-impl/pom.xml
itm/itm-impl/src/main/java/org/opendaylight/genius/itm/confighelpers/ItmInternalTunnelDeleteWorker.java
itm/itm-impl/src/main/java/org/opendaylight/genius/itm/listeners/TransportZoneListener.java
itm/itm-impl/src/main/java/org/opendaylight/genius/itm/recovery/impl/ItmTepInstanceRecoveryHandler.java
itm/itm-impl/src/main/resources/OSGI-INF/blueprint/itm.xml
itm/itm-impl/src/test/java/org/opendaylight/genius/itm/impl/ItmInternalTunnelDeleteTest.java
itm/itm-impl/src/test/java/org/opendaylight/genius/itm/tests/ItmTestModule.java

index f0e180ed43f45ee8e7dd1f39990728a31deb798d..96c2b81902d15053f5f025afc2f17070a7747e7c 100644 (file)
@@ -127,6 +127,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <version>${project.version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.genius</groupId>
+      <artifactId>cloudscaler-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
@@ -184,6 +189,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <groupId>org.opendaylight.infrautils</groupId>
       <artifactId>caches-test</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.genius</groupId>
+      <artifactId>cloudscaler-impl</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <!--Build Dependencies-->
   <build>
index 273f3696a18e7eefcb407fca40621132c5633daf..2ffaf6ceeee785097eb91771f7c46c85868d51cb 100644 (file)
@@ -21,6 +21,7 @@ import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager;
 import org.opendaylight.genius.infra.Datastore.Configuration;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
@@ -89,6 +90,7 @@ public class ItmInternalTunnelDeleteWorker {
     private final DirectTunnelUtils directTunnelUtils;
     private final OfEndPointCache ofEndPointCache;
     private final ItmConfig itmConfig;
+    private final TombstonedNodeManager tombstonedNodeManager;
 
     public ItmInternalTunnelDeleteWorker(DataBroker dataBroker, JobCoordinator jobCoordinator,
                                          TunnelMonitoringConfig tunnelMonitoringConfig,
@@ -98,7 +100,8 @@ public class ItmInternalTunnelDeleteWorker {
                                          TunnelStateCache tunnelStateCache,
                                          DirectTunnelUtils directTunnelUtils,
                                          OfEndPointCache ofEndPointCache,
-                                         ItmConfig itmConfig) {
+                                         ItmConfig itmConfig,
+                                         TombstonedNodeManager tombstonedNodeManager) {
         this.dataBroker = dataBroker;
         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.jobCoordinator = jobCoordinator;
@@ -111,6 +114,7 @@ public class ItmInternalTunnelDeleteWorker {
         this.directTunnelUtils = directTunnelUtils;
         this.ofEndPointCache = ofEndPointCache;
         this.itmConfig = itmConfig;
+        this.tombstonedNodeManager = tombstonedNodeManager;
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
@@ -138,6 +142,7 @@ public class ItmInternalTunnelDeleteWorker {
                 LOG.debug("Entries in meshEndPointCache {} for DPN Id{} ", meshedEndPtCache.size(), srcDpn.getDPNID());
                 for (TunnelEndPoints srcTep : srcDpn.nonnullTunnelEndPoints()) {
                     LOG.trace("Processing srcTep {}", srcTep);
+                    Boolean isDpnTombstoned = tombstonedNodeManager.isDpnTombstoned(srcDpn.getDPNID());
                     List<TzMembership> srcTZones = srcTep.nonnullTzMembership();
                     boolean tepDeleteFlag = false;
                     // First, take care of tunnel removal, so run through all other DPNS other than srcDpn
@@ -160,9 +165,12 @@ public class ItmInternalTunnelDeleteWorker {
                                                         + "Destination TEP {} " ,srcTep , dstTep);
                                                 removeTunnelInterfaceFromOvsdb(tx, srcTep, dstTep, srcDpn.getDPNID(),
                                                         dstDpn.getDPNID());
-
+                                                if (isDpnTombstoned) {
+                                                    LOG.trace("Removing tunnelState entry for {} while tombstoned "
+                                                            + "is set {}", srcDpn.getDPNID(), isDpnTombstoned);
+                                                    removeTunnelState(srcTep,dstTep);
+                                                }
                                             }
-
                                         } else {
                                             if (checkIfTrunkExists(dstDpn.getDPNID(), srcDpn.getDPNID(),
                                                 srcTep.getTunnelType(), dataBroker)) {
@@ -413,6 +421,22 @@ public class ItmInternalTunnelDeleteWorker {
         }
     }
 
+    private void removeTunnelState(TunnelEndPoints srcTep, TunnelEndPoints dstTep) {
+        String trunkfwdIfName = ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(),
+                srcTep.getIpAddress().getIpv4Address().getValue(),
+                dstTep.getIpAddress().getIpv4Address().getValue(),
+                srcTep.getTunnelType().getName());
+        LOG.trace("Removing tunnelstate for {}", trunkfwdIfName);
+        directTunnelUtils.deleteTunnelStateEntry(trunkfwdIfName);
+
+        String trunkRevIfName = ItmUtils.getTrunkInterfaceName(dstTep.getInterfaceName(),
+                dstTep.getIpAddress().getIpv4Address().getValue(),
+                srcTep.getIpAddress().getIpv4Address().getValue(),
+                srcTep.getTunnelType().getName());
+        LOG.trace("Removing tunnelstate for {}", trunkRevIfName);
+        directTunnelUtils.deleteTunnelStateEntry(trunkRevIfName);
+    }
+
     private boolean checkIfTepInterfaceExists(Uint64 srcDpnId, Uint64 dstDpnId) {
         DpnTepInterfaceInfo dpnTepInterfaceInfo = dpnTepStateCache.getDpnTepInterface(srcDpnId, dstDpnId);
         if (dpnTepInterfaceInfo != null) {
index 2bdb70d9fde578101f15c4884a38ff88c51b9d55..3db8d655ab79f8d0e21a0d4bf6899e8098d63f1b 100644 (file)
@@ -22,6 +22,7 @@ import javax.inject.Singleton;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager;
 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
 import org.opendaylight.genius.infra.Datastore;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
@@ -97,6 +98,7 @@ public class TransportZoneListener extends AbstractSyncDataTreeChangeListener<Tr
     private final DPNTEPsInfoCache dpnTEPsInfoCache;
     private final ManagedNewTransactionRunner txRunner;
     private final DataTreeEventCallbackRegistrar eventCallbacks;
+    private final TombstonedNodeManager tombstonedNodeManager;
 
     @Inject
     public TransportZoneListener(final DataBroker dataBroker,
@@ -111,7 +113,8 @@ public class TransportZoneListener extends AbstractSyncDataTreeChangeListener<Tr
                                  final IInterfaceManager interfaceManager,
                                  final OfEndPointCache ofEndPointCache,
                                  final ServiceRecoveryRegistry serviceRecoveryRegistry,
-                                 final DataTreeEventCallbackRegistrar eventCallbacks) {
+                                 final DataTreeEventCallbackRegistrar eventCallbacks,
+                                 final TombstonedNodeManager tombstonedNodeManager) {
         super(dataBroker, LogicalDatastoreType.CONFIGURATION,
                 InstanceIdentifier.create(TransportZones.class).child(TransportZone.class));
         this.dataBroker = dataBroker;
@@ -119,17 +122,20 @@ public class TransportZoneListener extends AbstractSyncDataTreeChangeListener<Tr
         this.mdsalManager = mdsalManager;
         this.itmConfig = itmConfig;
         this.dpnTEPsInfoCache = dpnTEPsInfoCache;
+        this.tombstonedNodeManager = tombstonedNodeManager;
         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.eventCallbacks = eventCallbacks;
         initializeTZNode();
         this.itmInternalTunnelDeleteWorker = new ItmInternalTunnelDeleteWorker(dataBroker, jobCoordinator,
                 tunnelMonitoringConfig, interfaceManager, dpnTepStateCache, ovsBridgeEntryCache,
-                ovsBridgeRefEntryCache, tunnelStateCache, directTunnelUtils, ofEndPointCache, itmConfig);
+                ovsBridgeRefEntryCache, tunnelStateCache, directTunnelUtils, ofEndPointCache, itmConfig,
+                tombstonedNodeManager);
         this.itmInternalTunnelAddWorker = new ItmInternalTunnelAddWorker(dataBroker, jobCoordinator,
                 tunnelMonitoringConfig, itmConfig, directTunnelUtils, interfaceManager,
                 ovsBridgeRefEntryCache, ofEndPointCache, eventCallbacks);
         this.externalTunnelAddWorker = new ItmExternalTunnelAddWorker(itmConfig, dpnTEPsInfoCache);
-        serviceRecoveryRegistry.addRecoverableListener(ItmServiceRecoveryHandler.getServiceRegistryKey(), this);
+        serviceRecoveryRegistry.addRecoverableListener(ItmServiceRecoveryHandler.getServiceRegistryKey(),
+                this);
     }
 
     @Override
index 8a9cdf236c3dc1ce021c419389644f68ae8104f9..746c7e3f7bbdaeae9dc37c523e271d9ee5b6c927 100644 (file)
@@ -17,6 +17,7 @@ import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager;
 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
@@ -76,6 +77,7 @@ public class ItmTepInstanceRecoveryHandler implements ServiceRecoveryInterface {
     private final ManagedNewTransactionRunner txRunner;
     private final IInterfaceManager interfaceManager;
     private final DpnTepStateCache dpnTepStateCache;
+    private final TombstonedNodeManager tombstonedNodeManager;
 
     @Inject
     public ItmTepInstanceRecoveryHandler(DataBroker dataBroker,
@@ -91,7 +93,8 @@ public class ItmTepInstanceRecoveryHandler implements ServiceRecoveryInterface {
                                          ServiceRecoveryRegistry serviceRecoveryRegistry,
                                          EntityOwnershipUtils entityOwnershipUtils,
                                          OfEndPointCache ofEndPointCache,
-                                         DataTreeEventCallbackRegistrar eventCallbacks) {
+                                         DataTreeEventCallbackRegistrar eventCallbacks,
+                                         TombstonedNodeManager tombstonedNodeManager) {
         this.dataBroker = dataBroker;
         this.itmConfig = itmConfig;
         this.imdsalApiManager = imdsalApiMgr;
@@ -99,6 +102,7 @@ public class ItmTepInstanceRecoveryHandler implements ServiceRecoveryInterface {
         this.dpntePsInfoCache = dpntePsInfoCache;
         this.entityOwnershipUtils = entityOwnershipUtils;
         this.eventCallbacks = eventCallbacks;
+        this.tombstonedNodeManager = tombstonedNodeManager;
         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.itmInternalTunnelAddWorker = new ItmInternalTunnelAddWorker(dataBroker, jobCoordinator,
                 tunnelMonitoringConfig, itmConfig, directTunnelUtils, interfaceManager,
@@ -107,7 +111,8 @@ public class ItmTepInstanceRecoveryHandler implements ServiceRecoveryInterface {
                 dpntePsInfoCache);
         this.itmInternalTunnelDeleteWorker = new ItmInternalTunnelDeleteWorker(dataBroker, jobCoordinator,
                 tunnelMonitoringConfig, interfaceManager, dpnTepStateCache, ovsBridgeEntryCache,
-                ovsBridgeRefEntryCache, tunnelStateCache, directTunnelUtils, ofEndPointCache, itmConfig);
+                ovsBridgeRefEntryCache, tunnelStateCache, directTunnelUtils, ofEndPointCache, itmConfig,
+                tombstonedNodeManager);
         serviceRecoveryRegistry.registerServiceRecoveryRegistry(getServiceRegistryKey(), this);
         this.interfaceManager = interfaceManager;
         this.dpnTepStateCache = dpnTepStateCache;
index 54c89e38f89ee5e4678b4f4a87702d0ca6fd57f2..4287e3bd1259aae14ea8dee065b948c259f1f84b 100644 (file)
@@ -48,6 +48,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <reference id="dataTreeEventCallbackRegistrar"
                interface="org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar"/>
 
+    <reference id="tombstonedNodeManager"
+               interface="org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager"/>
+
     <odl:clustered-app-config id="itmConfig"
                               binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig"
                               default-config-file-name="genius-itm-config.xml"
index 9c965339f2a6c2d1496cb6d28dcba1d2a9044baf..384902ed3458b521e2f613c305bc375f88afd5a5 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
 import org.opendaylight.genius.itm.cache.DpnTepStateCache;
@@ -121,6 +122,7 @@ public class ItmInternalTunnelDeleteTest {
     @Mock IInterfaceManager interfaceManager;
     @Mock ItmConfig itmConfig;
     @Mock TunnelMonitoringConfig tunnelMonitoringConfig;
+    @Mock TombstonedNodeManager tombstonedNodeManager;
     DirectTunnelUtils directTunnelUtils;
     ItmInternalTunnelDeleteWorker itmInternalTunnelDeleteWorker;
     UnprocessedNodeConnectorCache unprocessedNodeConnectorCache;
@@ -169,7 +171,7 @@ public class ItmInternalTunnelDeleteTest {
             new OvsBridgeEntryCache(dataBroker, new GuavaCacheProvider(new CacheManagersRegistryImpl())),
             new OvsBridgeRefEntryCache(dataBroker, new GuavaCacheProvider(new CacheManagersRegistryImpl())),
             new TunnelStateCache(dataBroker, new GuavaCacheProvider(new CacheManagersRegistryImpl())),
-            directTunnelUtils, ofEndPointCache, itmConfig);
+            directTunnelUtils, ofEndPointCache, itmConfig, tombstonedNodeManager);
     }
 
     @After
index f76d34773147c4eda99052789f01093d877e3eea..2417ac77e447d4375295c45ce00e38712acfdb76 100644 (file)
@@ -12,6 +12,8 @@ import static org.mockito.Mockito.mock;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
 import org.opendaylight.daexim.DataImportBootReady;
+import org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager;
+import org.opendaylight.genius.cloudscaler.rpcservice.TombstonedNodeManagerImpl;
 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
 import org.opendaylight.genius.datastoreutils.listeners.internal.DataTreeEventCallbackRegistrarImpl;
 import org.opendaylight.genius.datastoreutils.testutils.JobCoordinatorEventsWaiter;
@@ -101,6 +103,7 @@ public class ItmTestModule extends AbstractGuiceJsr250Module {
                 new SimpleDOMEntityOwnershipService(), dataBrokerTestModule.getBindingToNormalizedNodeCodec());
         bind(EntityOwnershipService.class).toInstance(entityOwnershipService);
         bind(EntityOwnershipUtils.class);
+        bind(TombstonedNodeManager.class).to(TombstonedNodeManagerImpl.class);
 
         // Bindings to test infra (fakes & mocks)
         TestIMdsalApiManager mdsalManager = TestIMdsalApiManager.newInstance();