rootnomad commented on code in PR #14038:
URL: https://github.com/apache/cloudstack/pull/14038#discussion_r4325860385


##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java:
##########
@@ -1120,10 +1120,12 @@ private NicVO checkForRaceAndAllocateNic(final 
NicProfile requested, final Netwo
             }
 
             if (vo == null) {
-                if (requested.getRequestedIPv4() != null) {
-                    throw new 
InsufficientVirtualNetworkCapacityException("Unable to acquire requested Guest 
IP address " + requested.getRequestedIPv4() + " for network " + network, 
DataCenter.class, dcVo.getId());
-                } else {
-                    requested.setIPv4Address(null);
+                if (requested != null) {

Review Comment:
   Good question, thanks @Damans227. The null `requested` comes from 
`allocate()`: when a network is handed in with an empty profile list, the loop 
adds a single null entry and calls `allocateNic(null, ...)`. You're right that 
normal user-vm deploys build a NicProfile and don't reach it; the path that 
does is `reallocate()` in Basic zones and the other internal add-network flows 
that pass no profile. Before the fix, losing the allocation race there 
dereferenced the null `requested` and threw NPE; the guard makes it retry the 
same as the non-null case.



-- 
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]

Reply via email to