Use key tunnel remove events on tunnel name 31/90931/4
authorNishchya Gupta <nishchyag@altencalsoftlabs.com>
Mon, 6 Jul 2020 12:30:53 +0000 (18:00 +0530)
committerChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Wed, 16 Sep 2020 14:32:10 +0000 (14:32 +0000)
Adding uses of tombstone api.

Signed-off-by: Nishchya Gupta <nishchyag@altencalsoftlabs.com>
Change-Id: Ib5f0280549fcbd71684be53e378a8f04bcf21675

interfacemanager/interfacemanager-impl/pom.xml
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java
interfacemanager/interfacemanager-impl/src/main/resources/OSGI-INF/blueprint/interfacemanager.xml
interfacemanager/interfacemanager-impl/src/test/java/org/opendaylight/genius/interfacemanager/test/InterfaceManagerTestModule.java

index ee2c73d621076bcfa2baa109fce3c3ba3c040e45..bb57b7f84dcdd0ca6f0ae0418fd15265f252c2b2 100644 (file)
@@ -113,6 +113,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>blueprint-maven-plugin-annotation</artifactId>
       <optional>true</optional>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.genius</groupId>
+      <artifactId>cloudscaler-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <!-- for infrautils metrics APIs -->
     <dependency>
       <groupId>org.opendaylight.infrautils</groupId>
index 1ba73a595b349a07fe65e6db0815d9695c98226c..7e8fe6ef06b0f3e480dcf7538102c8395b139099 100644 (file)
@@ -20,6 +20,7 @@ import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.apache.aries.blueprint.annotation.service.Reference;
 import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager;
 import org.opendaylight.genius.interfacemanager.IfmConstants;
 import org.opendaylight.genius.interfacemanager.IfmUtil;
 import org.opendaylight.genius.interfacemanager.commons.AlivenessMonitorUtils;
@@ -36,6 +37,7 @@ import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
 import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction;
 import org.opendaylight.mdsal.binding.util.TypedWriteTransaction;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry;
@@ -68,6 +70,7 @@ public final class OvsInterfaceConfigRemoveHelper {
     private final AlivenessMonitorUtils alivenessMonitorUtils;
     private final InterfaceMetaUtils interfaceMetaUtils;
     private final SouthboundUtils southboundUtils;
+    private final TombstonedNodeManager tombstonedNodeManager;
 
     @Inject
     public OvsInterfaceConfigRemoveHelper(@Reference DataBroker dataBroker,
@@ -76,7 +79,8 @@ public final class OvsInterfaceConfigRemoveHelper {
                                           @Reference JobCoordinator coordinator,
                                           InterfaceManagerCommonUtils interfaceManagerCommonUtils,
                                           InterfaceMetaUtils interfaceMetaUtils,
-                                          SouthboundUtils southboundUtils) {
+                                          SouthboundUtils southboundUtils,
+                                          TombstonedNodeManager tombstonedNodeManager) {
         this.dataBroker = dataBroker;
         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.mdsalApiManager = mdsalApiManager;
@@ -85,6 +89,7 @@ public final class OvsInterfaceConfigRemoveHelper {
         this.alivenessMonitorUtils = alivenessMonitorUtils;
         this.interfaceMetaUtils = interfaceMetaUtils;
         this.southboundUtils = southboundUtils;
+        this.tombstonedNodeManager = tombstonedNodeManager;
     }
 
     public List<? extends ListenableFuture<?>> removeConfiguration(Interface interfaceOld, ParentRefs parentRefs) {
@@ -104,7 +109,8 @@ public final class OvsInterfaceConfigRemoveHelper {
 
     private void removeVlanConfiguration(ParentRefs parentRefs, String interfaceName,
             IfL2vlan ifL2vlan, TypedWriteTransaction<Operational> tx,
-            List<ListenableFuture<?>> futures) {
+            List<ListenableFuture<?>> futures) throws ReadFailedException {
+
         if (parentRefs == null || ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode()
                 && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode()) {
             return;
@@ -145,7 +151,7 @@ public final class OvsInterfaceConfigRemoveHelper {
 
     private void removeTunnelConfiguration(ParentRefs parentRefs, String interfaceName, IfTunnel ifTunnel,
             TypedWriteTransaction<Operational> operTx, TypedReadWriteTransaction<Configuration> confTx)
-            throws ExecutionException, InterruptedException {
+            throws ExecutionException, InterruptedException, ReadFailedException {
         LOG.info("removing tunnel configuration for interface {}", interfaceName);
         Uint64 dpId = null;
         if (parentRefs != null) {
@@ -228,14 +234,16 @@ public final class OvsInterfaceConfigRemoveHelper {
     public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
         .ietf.interfaces.rev140508.interfaces.state.Interface cleanUpInterfaceWithUnknownState(
             String interfaceName, ParentRefs parentRefs, IfTunnel ifTunnel,
-            TypedWriteTransaction<Operational> transaction) {
+            TypedWriteTransaction<Operational> transaction) throws ReadFailedException {
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508
             .interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
         if (ifState != null && ifState
                 .getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                .ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Unknown) {
+                .ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Unknown
+                || tombstonedNodeManager.isDpnTombstoned(parentRefs.getDatapathNodeIdentifier())) {
             String staleInterface = ifTunnel != null ? interfaceName : parentRefs.getParentInterface();
-            LOG.debug("cleaning up parent-interface for {}, since the oper-status is UNKNOWN", interfaceName);
+            LOG.debug("cleaning up parent-interface for {}, in the case oper-status is UNKNOWN or the DPN:{}"
+                    + " is tombstoned", interfaceName, parentRefs.getDatapathNodeIdentifier());
             interfaceManagerCommonUtils.deleteInterfaceStateInformation(staleInterface, transaction);
         }
         return ifState;
index 9acf52840b7a6bd74c36415dcbe7066f0114f6cc..a1c68069c7d621c004429e65902bc038c1e26f78 100644 (file)
@@ -22,6 +22,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <reference id="entityOwnershipService"
                interface="org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService" />
 
+    <reference id="tombstonedNodeManager"
+               interface="org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager"/>
+
     <odl:rpc-implementation ref="interfaceManagerRpcService" />
 
     <odl:clustered-app-config id="ifmConfig"
index ca3db278e3248730ddbd9777e135e4213e31cad0..4675d3bb858be48b3cd5b985d430f35f4f6d723d 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.genius.interfacemanager.test;
 import static org.mockito.Mockito.mock;
 
 import org.opendaylight.daexim.DataImportBootReady;
+import org.opendaylight.genius.cloudscaler.api.TombstonedNodeManager;
 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
 import org.opendaylight.genius.datastoreutils.testutils.AbstractTestableListener;
 import org.opendaylight.genius.datastoreutils.testutils.JobCoordinatorCountedEventsWaiter;
@@ -101,6 +102,7 @@ public class InterfaceManagerTestModule extends AbstractGuiceJsr250Module {
         bind(EntityOwnershipService.class).toInstance(entityOwnershipService);
         bind(EntityOwnershipUtils.class);
         bind(AlivenessMonitorService.class).toInstance(mock(AlivenessMonitorService.class));
+        bind(TombstonedNodeManager.class).toInstance(mock(TombstonedNodeManager.class));
         bind(OdlInterfaceRpcService.class).to(InterfaceManagerRpcService.class);
         bind(CacheBridgeEntryConfigListener.class);
         bind(CacheBridgeRefEntryListener.class);