Fix NSX SDK list handling to fetch all paginated results#12834
Fix NSX SDK list handling to fetch all paginated results#12834ZhyliaievD wants to merge 1 commit intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes incomplete NSX SDK “list” handling by introducing a generic pagination helper that follows NSX cursor values across pages, merges results, and returns a single combined result to callers (so list operations return the full dataset, not just the first page).
Changes:
- Added a
PagedFetcherutility to iterate through cursor-based pages and accumulate all items. - Updated several NSX
list(...)call sites inNsxApiClientto usePagedFetcherand return merged results. - Added unit tests covering single-page, empty-cursor, multi-page, and null-first-page-items scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/PagedFetcher.java |
New pagination helper that fetches pages via cursor and merges items into the first-page result. |
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java |
Switches multiple NSX list operations to fetch and merge all paginated results; also updates some logging and “first item” lookups to use Optional. |
plugins/network-elements/nsx/src/test/java/org/apache/cloudstack/service/PagedFetcherTest.java |
New JUnit tests validating pagination and edge cases for the helper. |
💡 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/PagedFetcher.java
Show resolved
Hide resolved
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/PagedFetcher.java
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12834 +/- ##
==========================================
Coverage 18.02% 18.03%
- Complexity 16450 16461 +11
==========================================
Files 5968 5969 +1
Lines 537086 537194 +108
Branches 65961 65967 +6
==========================================
+ Hits 96820 96858 +38
- Misses 429346 429413 +67
- Partials 10920 10923 +3
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:
|
… 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.
f60b99d to
48e63a3
Compare
Description
NSX SDK list operations are pageable: the API returns a non-null and non-empty
cursorfield when more pages are available. The previous implementation only fetched the first page and ignored pagination.This change updates the list retrieval flow to:
cursorchain until no further pages existThis ensures that list operations return the complete dataset rather than just the first page.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity