fix: LB Creation avoid 404 API errors due to non-needed patches#12835
fix: LB Creation avoid 404 API errors due to non-needed patches#12835ZhyliaievD wants to merge 1 commit intoapache:mainfrom
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.
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12835 +/- ##
============================================
+ Coverage 18.02% 18.05% +0.02%
- Complexity 16450 16477 +27
============================================
Files 5968 5968
Lines 537086 537119 +33
Branches 65961 65963 +2
============================================
+ Hits 96819 96978 +159
+ Misses 429347 429214 -133
- Partials 10920 10927 +7
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
4ea0f3d
Compare
|
@blueorangutan package |
|
@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.
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java
Outdated
Show resolved
Hide resolved
| Set<String> currentMembersSet = poolMembersCurrent.stream() | ||
| .map(this::buildPoolMemberKey) | ||
| .collect(toSet()); | ||
| return poolMembersUpdate.stream() | ||
| .map(this::buildPoolMemberKey) | ||
| .allMatch(currentMembersSet::contains); |
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java
Show resolved
Hide resolved
plugins/network-elements/nsx/src/test/java/org/apache/cloudstack/service/NsxApiClientTest.java
Show resolved
Hide resolved
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17174 |
Fix existing lbVirtualServer search by lbVirtualServerName
4ea0f3d to
94cabcd
Compare
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?