Damans227 commented on code in PR #14139:
URL: https://github.com/apache/cloudstack/pull/14139#discussion_r4162281919
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java:
##########
@@ -1141,6 +1142,29 @@ private NicVO checkForRaceAndAllocateNic(final
NicProfile requested, final Netwo
return vo;
}
+ /**
+ * Allocate a nic for {@code vm} on {@code network}, choosing its device
id atomically.
+ *
+ * {@link NicDao#getFreeDeviceId(long)} picks the first unused device id
by reading the vm's
+ * existing nics, but the new nic row is not persisted until the end of
{@link #allocateNic}. Two
+ * nics being added to the same vm concurrently (e.g. several tiers of a
VPC brought up in parallel,
+ * each attaching the shared redundant VR) would otherwise both read the
same free id and land on
+ * the same {@code ethN} — corrupting the VR config and, for a redundant
VPC, driving both routers
+ * PRIMARY (issue #11710). Holding the {@code vm_instance} row lock across
the read-and-persist makes
+ * the device id assignment atomic per vm.
+ */
+ protected NicProfile allocateNicWithFreeDeviceId(final NicProfile
requested, final Network network, final boolean isDefaultNic, final
VirtualMachineProfile vm)
+ throws InsufficientCapacityException, ConcurrentOperationException
{
+ return Transaction.execute(new
TransactionCallbackWithException<NicProfile, InsufficientCapacityException>() {
Review Comment:
ok that covers it, thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]