Copilot commented on code in PR #12835:
URL: https://github.com/apache/cloudstack/pull/12835#discussion_r2945866225


##########
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java:
##########
@@ -659,6 +662,13 @@ public void 
createNsxLbServerPool(List<NsxLoadBalancerMember> memberList, String
             String activeMonitorPath = 
getLbActiveMonitorPath(lbServerPoolName, privatePort, protocol);
             List<LBPoolMember> members = getLbPoolMembers(memberList, 
tier1GatewayName);
             LbPools lbPools = (LbPools) nsxService.apply(LbPools.class);
+            List<LBPoolMember> existingMembers = getNsxLbServerPool(lbPools, 
lbServerPoolName)
+                    .map(LBPool::getMembers)
+                    .orElse(null);
+            // Skip if pool exists and members unchanged
+            if (existingMembers != null && hasSamePoolMembers(existingMembers, 
members)) {
+                return;
+            }

Review Comment:
   `getLbActiveMonitorPath()` (line 662) is called before the pool-exists check 
(lines 665-671), which means an API call to NSX is made to fetch (or create) 
the monitor profile even when the pool already exists with identical members 
and we're about to return early. Consider moving the `getLbActiveMonitorPath` 
call to after the early-return check to avoid this unnecessary NSX API call — 
which is the stated goal of this PR.



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