Skip to content

fix: LB Creation avoid 404 API errors due to non-needed patches - #12835

Merged
sureshanaparti merged 1 commit into
apache:4.22from
PlaytikaOSS:fix/nsx-lb-404-api-errors
Apr 16, 2026
Merged

fix: LB Creation avoid 404 API errors due to non-needed patches#12835
sureshanaparti merged 1 commit into
apache:4.22from
PlaytikaOSS:fix/nsx-lb-404-api-errors

Conversation

@ZhyliaievD

Copy link
Copy Markdown
Contributor

Description

  • Avoid unnecessary NSX load balancer patch calls when the target resource already exists and does not need updating.
  • Reuse existing LB active monitor profiles instead of patching them again, which prevents avoidable 404 API errors during LB creation.
  • Skip server pool patching when the current NSX pool already has the same members, and skip virtual server patching when the virtual server already exists.
  • Fix createAndAddNsxLbVirtualServer() to check for an existing virtual server using the virtual server name, so existing virtual servers are detected correctly and not patched again

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

FileDescription
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.javaAdd 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.javaAdd 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.

@codecov

codecovBot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 17.99%. Comparing base (23f633a) to head (557d483).
⚠️ Report is 8 commits behind head on 4.22.

Files with missing linesPatch %Lines
...va/org/apache/cloudstack/service/NsxApiClient.java97.72%0 Missing and 1 partial ⚠️
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 
FlagCoverage Δ
uitests3.53% <ø> (-0.18%)⬇️
unittests19.14% <97.72%> (+0.45%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ZhyliaievD
ZhyliaievDforce-pushed the fix/nsx-lb-404-api-errors branch from 9f079d8 to 4ea0f3dCompareMarch 17, 2026 13:04
@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

FileDescription
NsxApiClient.javaAdded existence checks for pools, monitor profiles, and virtual servers before issuing patch calls; fixed virtual server lookup key.
NsxApiClientTest.javaAdded 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.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17174

@ZhyliaievD

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan test

1 similar comment
@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-15714)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 59477 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12835-t15714-kvm-ol8.zip
Smoke tests completed. 145 look OK, 6 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_attach_and_distribute_multiple_volumesFailure88.65test_attach_multiple_volumes.py
test_10_vpc_tier_kubernetes_clusterFailure3752.85test_kubernetes_clusters.py
ContextSuite context=TestListIdsParams>:teardownError1.14test_list_ids_parameter.py
test_01_snapshot_root_diskError4.03test_snapshots.py
test_02_list_snapshots_with_removed_data_storeError47.07test_snapshots.py
test_02_list_snapshots_with_removed_data_storeError47.07test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardownError29.85test_snapshots.py
test_01_snapshot_usageError20.89test_usage.py
test_01_vpn_usageError1.11test_usage.py
test_01_redundant_vpc_site2site_vpnFailure367.37test_vpc_vpn.py
test_01_vpc_site2site_vpn_multiple_optionsFailure416.16test_vpc_vpn.py
test_01_vpc_site2site_vpnFailure248.58test_vpc_vpn.py

@ZhyliaievD

Copy link
Copy Markdown
ContributorAuthor

@weizhouapache@winterhazel a kind reminder about this PR 😅
PS: test failures are not related to suggested changes(not related to nsx at all as far as I see)

@winterhazel
winterhazel self-requested a review April 6, 2026 18:52

@winterhazelwinterhazel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. I just left some minor remarks.

@Pearl1594@nvazquez could you have a look at this one too?

@nvazqueznvazquez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvement @ZhyliaievD! Code LGTM - some minor remarks raised by @winterhazel, could be great if addressed

@ZhyliaievD
ZhyliaievDforce-pushed the fix/nsx-lb-404-api-errors branch from 94cabcd to 5785a43CompareApril 9, 2026 08:46
@ZhyliaievD

Copy link
Copy Markdown
ContributorAuthor

Thanks for the improvement @ZhyliaievD! Code LGTM - some minor remarks raised by @winterhazel, could be great if addressed

Covered all comments, thanks for review

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 17419

@nvazquez

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17422

@nvazquez

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-15839)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 49642 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12835-t15839-kvm-ol8.zip
Smoke tests completed. 151 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

@nvazquez@Pearl1594@ZhyliaievD ccan you advise on testing?

@ZhyliaievD

Copy link
Copy Markdown
ContributorAuthor

@nvazquez@Pearl1594@ZhyliaievD ccan you advise on testing?

Tested on 4.22.0.0 base, see #12834 (comment)

@DaanHoogland

Copy link
Copy Markdown
Contributor

same for this one

@nvazquez@Pearl1594@ZhyliaievD ccan you advise on testing?

Tested on 4.22.0.0 base, see #12834 (comment)

does it then make sense to base ofo of 22 and merge on that?

@weizhouapacheweizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

better to fix into 4.22.1.0
cc @sureshanaparti@rajujith

@sureshanaparti

Copy link
Copy Markdown
Contributor

code lgtm

better to fix into 4.22.1.0 cc @sureshanaparti@rajujith

@ZhyliaievD can re-target to 4.22?

Fix existing lbVirtualServer search by lbVirtualServerName
@ZhyliaievD
ZhyliaievDforce-pushed the fix/nsx-lb-404-api-errors branch from 5785a43 to 557d483CompareApril 15, 2026 14:34
@ZhyliaievD
ZhyliaievD changed the base branch from main to 4.22April 15, 2026 14:34
@ZhyliaievD

Copy link
Copy Markdown
ContributorAuthor

@sureshanaparti Done

@nvazquez

Copy link
Copy Markdown
Contributor

Thanks @ZhyliaievD

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17508

@nvazquez

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-15890)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52500 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12835-t15890-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@sureshanapartisureshanaparti modified the milestones: 4.23.0, 4.22.1Apr 16, 2026
@sureshanapartisureshanaparti moved this from Todo to In Progress in Apache CloudStack 4.22.1Apr 16, 2026
@sureshanaparti
sureshanaparti merged commit 05c5963 into apache:4.22Apr 16, 2026
25 of 28 checks passed
@github-project-automationgithub-project-automationBot moved this from In Progress to Done in Apache CloudStack 4.22.1Apr 16, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants

@ZhyliaievD@DaanHoogland@blueorangutan@sureshanaparti@nvazquez@winterhazel@weizhouapache