Fixing "inconsistency will tunnel-port creation" issue 95/30195/2
authorFaseela K <faseela.k@ericsson.com>
Wed, 25 Nov 2015 12:32:51 +0000 (18:02 +0530)
committerFaseela K <faseela.k@ericsson.com>
Wed, 25 Nov 2015 15:51:09 +0000 (21:21 +0530)
    - parallel tunnel port creations were giving inconsistent results due
      to issues in transaction commit timeouts
    - Adding more debug logs

Change-Id: Ib108cb9e23327fcd2a2533f1eb4338dccaa4ef6a
Signed-off-by: Faseela K <faseela.k@ericsson.com>
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceMetaUtils.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigAddHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateAddHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/utilities/SouthboundUtils.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java

index 8367b8a409ab588ecaea30df13b183c8741301c3..f8aaaf6b956a7f25bf1123dab667584247018fdc 100644 (file)
@@ -93,23 +93,6 @@ public class InterfaceMetaUtils {
         t.put(LogicalDatastoreType.CONFIGURATION, bridgeInterfaceEntryIid, entryBuilder.build(), true);
     }
 
-    public static void createBridgeInterfaceEntryInConfigDS(BridgeEntryKey bridgeEntryKey,
-                                                             BridgeInterfaceEntryKey bridgeInterfaceEntryKey,
-                                                             String childInterface,
-                                                             InstanceIdentifier<TerminationPoint> tpIid,
-                                                             WriteTransaction t) {
-        if (tpIid == null) {
-            createBridgeInterfaceEntryInConfigDS(bridgeEntryKey, bridgeInterfaceEntryKey, childInterface, t);
-            return;
-        }
-
-        InstanceIdentifier<BridgeInterfaceEntry> bridgeInterfaceEntryIid =
-                InterfaceMetaUtils.getBridgeInterfaceEntryIdentifier(bridgeEntryKey, bridgeInterfaceEntryKey);
-        BridgeInterfaceEntryBuilder entryBuilder = new BridgeInterfaceEntryBuilder().setKey(bridgeInterfaceEntryKey)
-                .setInterfaceName(childInterface);
-        t.put(LogicalDatastoreType.CONFIGURATION, bridgeInterfaceEntryIid, entryBuilder.build(), true);
-    }
-
     public static InstanceIdentifier<InterfaceParentEntry> getInterfaceParentEntryIdentifier(
             InterfaceParentEntryKey interfaceParentEntryKey) {
         InstanceIdentifier.InstanceIdentifierBuilder<InterfaceParentEntry> intfIdBuilder =
index cc2619278958129ba887d47ac5641e85c2bb6439..49f5da22feb641edae9ad61fbc6d0acdc4b2c6bf 100644 (file)
@@ -53,21 +53,20 @@ public class OvsInterfaceConfigAddHelper {
     public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
                                                                 Interface interfaceNew, IdManager idManager) {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
-        WriteTransaction t = dataBroker.newWriteOnlyTransaction();
 
         IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
         if (ifTunnel != null) {
-            addTunnelConfiguration(dataBroker, parentRefs, interfaceNew, idManager, t);
-            futures.add(t.submit());
+            addTunnelConfiguration(dataBroker, parentRefs, interfaceNew, idManager, futures);
             return futures;
         }
 
-        addVlanConfiguration(interfaceNew, t, dataBroker);
-        futures.add(t.submit());
+        addVlanConfiguration(interfaceNew, dataBroker, futures);
         return futures;
     }
 
-    private static void addVlanConfiguration(Interface interfaceNew, WriteTransaction t, DataBroker dataBroker) {
+    private static void addVlanConfiguration(Interface interfaceNew, DataBroker dataBroker,
+                                             List<ListenableFuture<Void>> futures) {
+        WriteTransaction t = dataBroker.newWriteOnlyTransaction();
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
                 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceNew.getName(), dataBroker);
         if (ifState == null) {
@@ -117,11 +116,14 @@ public class OvsInterfaceConfigAddHelper {
             childIfaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifaceChild.getName()));
             t.put(LogicalDatastoreType.OPERATIONAL, ifChildStateId, childIfaceBuilder.build(), true);
         }
+        futures.add(t.submit());
     }
 
     private static void addTunnelConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
                                               Interface interfaceNew, IdManager idManager,
-                                              WriteTransaction t) {
+                                              List<ListenableFuture<Void>> futures) {
+        LOG.debug("adding tunnel configuration for {}", interfaceNew.getName());
+        WriteTransaction t = dataBroker.newWriteOnlyTransaction();
         if (parentRefs == null) {
             LOG.warn("ParentRefs for interface: {} Not Found. " +
                     "Creation of Tunnel OF-Port not supported when dpid not provided.", interfaceNew.getName());
@@ -144,11 +146,11 @@ public class OvsInterfaceConfigAddHelper {
                 InterfaceMetaUtils.getBridgeRefEntryFromOperDS(dpnBridgeEntryIid, dataBroker);
         BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpId);
         BridgeInterfaceEntryKey bridgeInterfaceEntryKey = new BridgeInterfaceEntryKey(interfaceNew.getName());
-        if (bridgeRefEntry == null) {
-            InterfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(bridgeEntryKey, bridgeInterfaceEntryKey,
+
+        LOG.debug("creating bridge interfaceEntry in ConfigDS {}", bridgeEntryKey);
+        InterfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(bridgeEntryKey, bridgeInterfaceEntryKey,
                     interfaceNew.getName(), t);
-            return;
-        }
+        futures.add(t.submit());
 
         InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
                 (InstanceIdentifier<OvsdbBridgeAugmentation>)bridgeRefEntry.getBridgeReference().getValue();
@@ -158,13 +160,8 @@ public class OvsInterfaceConfigAddHelper {
             OvsdbBridgeAugmentation ovsdbBridgeAugmentation = bridgeNodeOptional.get();
             String bridgeName = ovsdbBridgeAugmentation.getBridgeName().getValue();
             SouthboundUtils.addPortToBridge(bridgeIid, interfaceNew,
-                    ovsdbBridgeAugmentation, bridgeName, interfaceNew.getName(), dataBroker, t);
+                    ovsdbBridgeAugmentation, bridgeName, interfaceNew.getName(), dataBroker, futures);
         }
-
-        InstanceIdentifier<TerminationPoint> tpIid = SouthboundUtils.createTerminationPointInstanceIdentifier(
-            InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), interfaceNew.getName());
-        InterfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(bridgeEntryKey, bridgeInterfaceEntryKey,
-                interfaceNew.getName(), tpIid, t);
     }
 
     private static void updateStateEntry(Interface interfaceNew, WriteTransaction t,
@@ -183,6 +180,7 @@ public class OvsInterfaceConfigAddHelper {
 
     private static void createBridgeEntryIfNotPresent(BigInteger dpId,
                                                       DataBroker dataBroker, WriteTransaction t) {
+        LOG.debug("creating bridge entry if not present for dpn {}",dpId);
         BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpId);
         InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
                 InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
@@ -195,4 +193,4 @@ public class OvsInterfaceConfigAddHelper {
             t.put(LogicalDatastoreType.CONFIGURATION, bridgeEntryInstanceIdentifier, bridgeEntryBuilder.build(), true);
         }
     }
-}
\ No newline at end of file
+}
index bf37408a4781c0cbe47a71c4d59611193a8bbf2b..6a4724487f05e8ccb0f412872608919c95d0f158 100644 (file)
@@ -65,8 +65,10 @@ public class OvsInterfaceTopologyStateAddHelper {
             return futures;
         }
 
-        dpId = dpId.replaceAll("[^\\d.]", "");
-        BigInteger ovsdbDpId = new BigInteger(dpId, 16);
+        String datapathId = dpId.replaceAll("[^\\d.]", "");
+        BigInteger ovsdbDpId = new BigInteger(datapathId, 16);
+
+        LOG.info("adding dpId {} to bridge reference {}", datapathId, bridgeName);
         BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(ovsdbDpId);
         InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
                 InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
@@ -92,11 +94,9 @@ public class OvsInterfaceTopologyStateAddHelper {
             InterfaceKey interfaceKey = new InterfaceKey(portName);
             Interface iface = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
             if (iface.getAugmentation(IfTunnel.class) != null) {
-                SouthboundUtils.addPortToBridge(bridgeIid, iface, bridgeNew, bridgeName, portName, dataBroker, t);
-                 InstanceIdentifier<TerminationPoint> tpIid = SouthboundUtils.createTerminationPointInstanceIdentifier(
-                        InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName);
+                SouthboundUtils.addPortToBridge(bridgeIid, iface, bridgeNew, bridgeName, portName, dataBroker, futures);
                 InterfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(bridgeEntryKey,
-                        new BridgeInterfaceEntryKey(portName), portName, tpIid, t);
+                        new BridgeInterfaceEntryKey(portName), portName, t);
             }
         }
 
index d921ac91826d0bd82ed99344c18037de8fdf4d7d..e20b81dc901fe44dff8f92d100702f97f4a3207a 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities;
 
 import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -45,17 +46,18 @@ public class SouthboundUtils {
 
     public static void addPortToBridge(InstanceIdentifier<?> bridgeIid, Interface iface,
                                        OvsdbBridgeAugmentation bridgeAugmentation, String bridgeName,
-                                       String portName, DataBroker dataBroker, WriteTransaction t) {
+                                       String portName, DataBroker dataBroker, List<ListenableFuture<Void>> futures) {
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
         if (ifTunnel != null) {
-            addTunnelPortToBridge(ifTunnel, bridgeIid, iface, bridgeAugmentation, bridgeName, portName, dataBroker, t);
-            return;
+            addTunnelPortToBridge(ifTunnel, bridgeIid, iface, bridgeAugmentation, bridgeName, portName, dataBroker, tx);
         }
 
         IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
         if (ifL2vlan != null) {
-            addVlanPortToBridge(bridgeIid, ifL2vlan, bridgeAugmentation, bridgeName, portName, dataBroker, t);
+            addVlanPortToBridge(bridgeIid, ifL2vlan, bridgeAugmentation, bridgeName, portName, dataBroker, tx);
         }
+        futures.add(tx.submit());
     }
 
     private static void addVlanPortToBridge(InstanceIdentifier<?> bridgeIid, IfL2vlan ifL2vlan,
@@ -69,6 +71,8 @@ public class SouthboundUtils {
                                              OvsdbBridgeAugmentation bridgeAugmentation, String bridgeName,
                                              String portName, DataBroker dataBroker, WriteTransaction t) {
         Class type = null;
+        LOG.debug("adding tunnel port {} to bridge {}",portName, bridgeName);
+
         if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeGre.class)) {
             type = InterfaceTypeGre.class;
         } else if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
index 8df055ba405caa11c8eb01c15354ce1388095828..a48f71dbd1671e6b6924a4d435747b9a910d44a1 100644 (file)
@@ -83,19 +83,6 @@ public class FlowBasedServicesUtils {
     public static List<MatchInfo> getMatchInfoForTunnelPortAtIngressTable(BigInteger dpId, long portNo, Interface iface) {
         List<MatchInfo> matches = new ArrayList<MatchInfo>();
         matches.add(new MatchInfo(MatchFieldType.in_port, new BigInteger[]{dpId, BigInteger.valueOf(portNo)}));
-        /*IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
-        TunnelResources tunnelResources = tunnel.getTunnelResources();
-        if (tunnelResources.getTunnelType().isAssignableFrom(TunnelTypeGre.class)) {
-            IfGre ifgre = tunnelResources.getAugmentation(IfGre.class);
-            BigInteger grekey = ifgre.getGreKey();
-            // FIXME: Add tunnel-id match information
-
-        } else if (tunnelResources.getTunnelType().isAssignableFrom(TunnelTypeVxlan.class)) {
-            IfVxlan ifVxlan = tunnelResources.getAugmentation(IfVxlan.class);
-            BigInteger vni = ifVxlan.getVni();
-            // FIXME: Add tunnel-id match information
-        }*/
-
         return matches;
     }
 
@@ -105,20 +92,6 @@ public class FlowBasedServicesUtils {
         matches.add(new MatchInfo(MatchFieldType.metadata, new BigInteger[] {
                 MetaDataUtil.getMetaDataForLPortDispatcher(interfaceTag, servicePriority),
                 MetaDataUtil.getMetaDataMaskForLPortDispatcher() }));
-        /*if (iface.getType().isAssignableFrom(Tunnel.class)) {
-            IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
-            TunnelResources tunnelResources = tunnel.getTunnelResources();
-            if (tunnelResources.getTunnelType().isAssignableFrom(TunnelTypeGre.class)) {
-                IfGre ifgre = tunnelResources.getAugmentation(IfGre.class);
-                BigInteger grekey = ifgre.getGreKey();
-                // FIXME: Add tunnel-id match information
-
-            } else if (tunnelResources.getTunnelType().isAssignableFrom(TunnelTypeVxlan.class)) {
-                IfVxlan ifVxlan = tunnelResources.getAugmentation(IfVxlan.class);
-                BigInteger vni = ifVxlan.getVni();
-                // FIXME: Add tunnel-id match information
-            }
-        }*/
         return matches;
     }