Uh oh!
There was an error while loading. Please reload this page.
fix: LB Creation avoid 404 API errors due to non-needed patches - #12835
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes NSX load balancer creation by avoiding unnecessary API PATCH calls when resources already exist and don't need updating. It fixes a bug where createAndAddNsxLbVirtualServer() was checking for an existing virtual server using the wrong name (the LB service name instead of the virtual server name), causing it to never detect existing virtual servers.
Changes:
- Skip monitor profile patching when the profile already exists in NSX, and skip server pool patching when the pool already has the same members
- Fix the virtual server existence check to use the correct virtual server name instead of the LB service name, so existing virtual servers are detected and not re-patched
- Add comprehensive unit tests covering all the new skip/patch scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java | Add existence checks for monitor profiles, server pools, and virtual servers to avoid unnecessary NSX API patch calls; fix virtual server lookup to use correct name |
plugins/network-elements/nsx/src/test/java/org/apache/cloudstack/service/NsxApiClientTest.java | Add tests for monitor profile reuse, pool member comparison skip/patch logic, and virtual server existence detection |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## 4.22 #12835 +/- ##
============================================
+ Coverage 17.61% 17.99% +0.37% - Complexity 15706 16557 +851
============================================
Files 5921 6022 +101 Lines 532392 541426 +9034 Branches 65109 66350 +1241 ============================================
+ Hits 93788 97409 +3621 - Misses 428015 433043 +5028 - Partials 10589 10974 +385
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9f079d8 to
4ea0f3dCompareDaanHoogland
commented
Mar 17, 2026
@blueorangutan package |
blueorangutan
commented
Mar 17, 2026
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
There was a problem hiding this comment.
Pull request overview
This PR avoids unnecessary NSX API patch calls during load balancer creation by checking if resources already exist before patching, preventing 404 errors.
Changes:
- Skip server pool patching when existing pool has identical members; skip virtual server patching when it already exists.
- Reuse existing LB active monitor profiles instead of re-patching them, fetching by ID directly rather than listing all profiles.
- Fix
createAndAddNsxLbVirtualServer()to look up the virtual server by its own name instead of the LB service name.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
NsxApiClient.java | Added existence checks for pools, monitor profiles, and virtual servers before issuing patch calls; fixed virtual server lookup key. |
NsxApiClientTest.java | Added tests covering skip/patch scenarios for server pools, monitor profiles, virtual servers, and error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
blueorangutan
commented
Mar 17, 2026
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17174 |
4ea0f3d to
94cabcdCompareZhyliaievD
commented
Mar 23, 2026
@blueorangutan test |
1 similar comment
sureshanaparti
commented
Mar 23, 2026
@blueorangutan test |
blueorangutan
commented
Mar 23, 2026
@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
blueorangutan
commented
Mar 24, 2026
[SF] Trillian test result (tid-15714)
|
ZhyliaievD
commented
Apr 6, 2026
@weizhouapache@winterhazel a kind reminder about this PR 😅 |
winterhazel
left a comment
There was a problem hiding this comment.
Code looks good to me. I just left some minor remarks.
@Pearl1594@nvazquez could you have a look at this one too?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Thanks for the improvement @ZhyliaievD! Code LGTM - some minor remarks raised by @winterhazel, could be great if addressed
Uh oh!
There was an error while loading. Please reload this page.
94cabcd to
5785a43CompareZhyliaievD
commented
Apr 9, 2026
Covered all comments, thanks for review |
blueorangutan
commented
Apr 9, 2026
Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 17419 |
nvazquez
commented
Apr 9, 2026
@blueorangutan package |
blueorangutan
commented
Apr 9, 2026
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
blueorangutan
commented
Apr 9, 2026
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17422 |
nvazquez
commented
Apr 9, 2026
@blueorangutan test |
blueorangutan
commented
Apr 9, 2026
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
blueorangutan
commented
Apr 10, 2026
[SF] Trillian test result (tid-15839)
|
DaanHoogland
commented
Apr 10, 2026
@nvazquez@Pearl1594@ZhyliaievD ccan you advise on testing? |
ZhyliaievD
commented
Apr 15, 2026
Tested on 4.22.0.0 base, see #12834 (comment) |
DaanHoogland
commented
Apr 15, 2026
same for this one
does it then make sense to base ofo of 22 and merge on that? |
weizhouapache
left a comment
There was a problem hiding this comment.
code lgtm
better to fix into 4.22.1.0
cc @sureshanaparti@rajujith
sureshanaparti
commented
Apr 15, 2026
@ZhyliaievD can re-target to 4.22? |
Fix existing lbVirtualServer search by lbVirtualServerName
5785a43 to
557d483CompareZhyliaievD
commented
Apr 15, 2026
@sureshanaparti Done |
nvazquez
commented
Apr 15, 2026
Thanks @ZhyliaievD @blueorangutan package |
blueorangutan
commented
Apr 15, 2026
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
blueorangutan
commented
Apr 15, 2026
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17508 |
nvazquez
commented
Apr 15, 2026
@blueorangutan test |
blueorangutan
commented
Apr 15, 2026
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
blueorangutan
commented
Apr 16, 2026
[SF] Trillian test result (tid-15890)
|
Uh oh!
There was an error while loading. Please reload this page.
Description
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?