Ensure adjacencies are created with a transaction 78/77078/2
authorStephen Kitt <skitt@redhat.com>
Thu, 18 Oct 2018 14:01:25 +0000 (16:01 +0200)
committerSam Hague <shague@redhat.com>
Fri, 19 Oct 2018 20:54:19 +0000 (20:54 +0000)
It’s possible for addNewAdjToVpnInterface() to end up being called
with a null inventory transaction, which will cause pain once we get
to Genius. This patch fixes that (re-using the configuration
transaction in a couple of cases).

Change-Id: Ic84573cf575fe4b75cb22dffd8b37dac3f5e3aee
Signed-off-by: Stephen Kitt <skitt@redhat.com>
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java

index aa7981641eb42dd6f0348e27d70dbf5a0b38e244..8b99e41378a1eda024e8e05df343cc6258a0b232 100755 (executable)
@@ -301,7 +301,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                                             if (!isBgpVpnInternetVpn
                                                                 || vpnUtil.isAdjacencyEligibleToVpnInternet(adj)) {
                                                                 addNewAdjToVpnInterface(vpnInterfaceOpIdentifier,
-                                                                    primaryRd, adj, dpnId, operTx, confTx);
+                                                                    primaryRd, adj, dpnId, operTx, confTx, invTx);
                                                             }
                                                         }
                                                     }
@@ -512,7 +512,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                         continue;
                     }
                     addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency,
-                            dpId, writeOperTxn, writeConfigTxn);
+                            dpId, writeOperTxn, writeConfigTxn, writeInvTxn);
                 }
             } catch (ReadFailedException e) {
                 LOG.error("processVpnInterfaceUp: Failed to read data store for interface {} vpn {} rd {} dpn {}",
@@ -1682,7 +1682,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
             String primaryRd = vpnUtil.getPrimaryRd(newVpnName);
             if (!vpnUtil.isVpnPendingDelete(primaryRd)) {
                 // TODO Deal with sequencing — the config tx must only submitted if the oper tx goes in
-                futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
+                futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> {
                     futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operTx -> {
                         InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier =
                                 VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterfaceName, newVpnName);
@@ -1699,7 +1699,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                     // add new adjacency
                                     if (!isBgpVpnInternetVpn || vpnUtil.isAdjacencyEligibleToVpnInternet(adj)) {
                                         addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adj,
-                                                dpnId, operTx, confTx);
+                                                dpnId, operTx, confTx, confTx);
                                     }
                                     LOG.info("update: new Adjacency {} with nextHop {} label {} subnet {} added to"
                                                     + " vpn interface {} on vpn {} dpnId {}",
@@ -1797,7 +1797,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     protected void addNewAdjToVpnInterface(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, String primaryRd,
                                            Adjacency adj, BigInteger dpnId,
                                            TypedWriteTransaction<Operational> writeOperTxn,
-                                           TypedWriteTransaction<Configuration> writeConfigTxn)
+                                           TypedWriteTransaction<Configuration> writeConfigTxn,
+                                           TypedReadWriteTransaction<Configuration> writeInvTxn)
             throws ExecutionException, InterruptedException {
         String interfaceName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getName();
         String configVpnName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getVpnInstanceName();
@@ -1836,7 +1837,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                     if (interfaceState != null) {
                         processVpnInterfaceAdjacencies(dpnId, currVpnIntf.getLportTag().intValue(), vpnName, primaryRd,
                                 currVpnIntf.getName(),
-                                vpnId, writeConfigTxn, writeOperTxn, null, interfaceState);
+                                vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState);
                     }
                 }
                 if (adj.getNextHopIpList() != null && !adj.getNextHopIpList().isEmpty()
@@ -2257,10 +2258,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                         futures.add(
                                             txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx ->
                                                 futures.add(
-                                                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                                                    txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
                                                         confTx -> addNewAdjToVpnInterface(existingVpnInterfaceId,
                                                             primaryRd, adjacency, vpnInterfaceOptional.get()
-                                                                .getDpnId(), operTx, confTx)))));
+                                                                .getDpnId(), operTx, confTx, confTx)))));
                                         return futures;
                                     } else {
                                         return Collections.emptyList();