Skip to content

Fix NSX SDK list handling to fetch all paginated results#12834

Open
ZhyliaievD wants to merge 1 commit intoapache:mainfrom
PlaytikaOSS:fix/nsx-sdk-list-pagenation
Open

Fix NSX SDK list handling to fetch all paginated results#12834
ZhyliaievD wants to merge 1 commit intoapache:mainfrom
PlaytikaOSS:fix/nsx-sdk-list-pagenation

Conversation

@ZhyliaievD
Copy link

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)
  • 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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

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 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 PagedFetcher utility to iterate through cursor-based pages and accumulate all items.
  • Updated several NSX list(...) call sites in NsxApiClient to use PagedFetcher and 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.

@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 25.85034% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.03%. Comparing base (3bd5410) to head (48e63a3).
⚠️ 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   #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     
Flag Coverage Δ
uitests 3.53% <ø> (ø)
unittests 19.19% <25.85%> (+<0.01%) ⬆️

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.

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