Skip to content

Conversation

@wolfchkov
Copy link

@wolfchkov wolfchkov commented Dec 11, 2025

Fix for NSX plugin.

Description

NSX SDK list operations are pageable: the API returns a non-null and non-empty cursor field when more pages are available. The previous implementation only fetched the first page and ignored pagination.

This change updates the list retrieval flow to:

  • follow the cursor chain until no further pages exist
  • accumulate items from all pages
  • return a single merged result to the caller

This ensures that list operations return the complete dataset rather than just the first page.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • [ x] 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
  • [x ] Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • [ x] Minor

Bug Severity

  • BLOCKER
  • [ x] Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

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

@boring-cyborg
Copy link

boring-cyborg bot commented Dec 11, 2025

Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
Here are some useful points:

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 25.85034% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.46%. Comparing base (3c64847) to head (070b956).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...va/org/apache/cloudstack/service/NsxApiClient.java 0.00% 106 Missing ⚠️
...va/org/apache/cloudstack/service/PagedFetcher.java 92.68% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              main   #12241       +/-   ##
============================================
+ Coverage     3.58%   17.46%   +13.88%     
- Complexity       0    15525    +15525     
============================================
  Files          445     5914     +5469     
  Lines        37552   529493   +491941     
  Branches      6914    64685    +57771     
============================================
+ Hits          1347    92488    +91141     
- Misses       36039   426584   +390545     
- Partials       166    10421    +10255     
Flag Coverage Δ
uitests 3.58% <ø> (ø)
unittests 18.52% <25.85%> (?)

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.

Copy link
Contributor

Copilot AI left a comment

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 fixes NSX SDK list operations to properly handle pagination by following cursor chains until all pages are fetched. Previously, only the first page of results was retrieved, which could lead to incomplete data when the result set exceeded a single page.

Key Changes:

  • Introduced a new PagedFetcher utility class that implements cursor-based pagination logic
  • Updated multiple list operations in NsxApiClient to use PagedFetcher for complete result retrieval
  • Added comprehensive unit tests for the pagination functionality

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
PagedFetcher.java New utility class implementing cursor-based pagination with a fluent builder pattern for fetching all pages of results
PagedFetcherTest.java Comprehensive unit tests covering single-page, multi-page, and edge cases for the pagination logic
NsxApiClient.java Updated list operations (NAT rules, transport zones, segment ports, LB monitors, groups, services, etc.) to use PagedFetcher; refactored methods to return Optional for cleaner null handling; improved logging consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… and non-empty

`cursor` field when more pages are available. The previous implementation only
fetched the first page and ignored pagination.

This change updates the list retrieval flow to:
- follow the `cursor` chain until no further pages exist
- accumulate items from all pages
- return a single merged result to the caller

This ensures that list operations return the complete dataset rather than just
the first page.
@wolfchkov wolfchkov force-pushed the fix-nsx-sdk-list-pagenation branch from de4cf14 to 070b956 Compare December 11, 2025 13:48
Copy link
Contributor

@Pearl1594 Pearl1594 left a comment

Choose a reason for hiding this comment

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

code lgtm.

@Pearl1594
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

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

@wolfchkov
Copy link
Author

This fix is currently undergoing testing. When the test results are ready, I will update the description accordingly.

@blueorangutan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants