Fixes overwrite when adding termination point 21/78221/3
authorTim Rozet <trozet@redhat.com>
Tue, 27 Nov 2018 16:44:53 +0000 (11:44 -0500)
committerSam Hague <shague@redhat.com>
Wed, 28 Nov 2018 14:14:57 +0000 (14:14 +0000)
A race condition was observed where OVSDB had already added the VTEP TP
to br-int, and following this Netvirt ELAN Manager added the patch port
(br-ex-patch) to br-int. Upon ELAN manager adding this using
SouthboundUtils addTerminationPoint, the previous VTEP was deleted. This
change modifies the addTerminationPoint to use a merge in MDSAL rather
than a put.

JIRA: OVSDB-472

Change-Id: I2afa7dc33ef915856774f431dd4c3d9bcd029155
Signed-off-by: Tim Rozet <trozet@redhat.com>
utils/southbound-utils/src/main/java/org/opendaylight/ovsdb/utils/southbound/utils/SouthboundUtils.java

index 645725024f112902bc95d314230206acf7902004..2def225e1292368ab317ba3f507aafed05908398 100644 (file)
@@ -757,8 +757,7 @@ public class SouthboundUtils {
         InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(bridgeNode, portName);
         tpBuilder.withKey(InstanceIdentifier.keyOf(tpIid));
         tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
-        /* TODO SB_MIGRATION should this be merge or mdsalUtils.put */
-        return mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
+        return mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
     }
 
     public Boolean addTerminationPoint(Node bridgeNode, String portName, String type) {
@@ -788,8 +787,7 @@ public class SouthboundUtils {
         InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(bridgeNode, portName);
         tpBuilder.withKey(InstanceIdentifier.keyOf(tpIid));
         tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
-        /* TODO SB_MIGRATION should this be merge or mdsalUtils.put */
-        return mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
+        return mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
     }
 
     public Boolean addTerminationPoint(Node bridgeNode, String bridgeName, String portName, String type) {
@@ -804,7 +802,7 @@ public class SouthboundUtils {
         TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
         tpBuilder.withKey(InstanceIdentifier.keyOf(tpIid));
         tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
-        return mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
+        return mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
     }
 
     public Boolean addPatchTerminationPoint(Node node, String bridgeName, String portName, String peerPortName) {