Add pagination to cloudstack api calls - #102
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #102 +/- ##
==========================================
+ Coverage 50.05% 53.62% +3.57%
==========================================
Files 4 5 +1
Lines 975 1035 +60
==========================================
+ Hits 488 555 +67
+ Misses 473 459 -14
- Partials 14 21 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses CloudStack API list truncation (default default.page.size, typically 500) by introducing a reusable pagination helper and applying it to load balancer–related list calls so large clusters can still correctly discover VMs/rules and reconcile load balancer membership (fixing #99).
Changes:
- Add a generic
listAllpagination helper for CloudStackList*Paramsand unit tests covering paging behavior and edge cases. - Apply paging to load balancer rule lookup, rule instance listing, VM listing for host verification, firewall rule listing, and network ACL listing.
- Add/extend tests to cover pagination regressions and duplicate entries across pages during reconciliation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pagination.go | Introduces generic pagination helper (listAll) for CloudStack list APIs. |
| pagination_test.go | Adds focused unit tests validating paging behavior and error handling for listAll. |
| cloudstack_loadbalancer.go | Switches several CloudStack list calls to use listAll and adds deduplication where paging may return duplicates. |
| cloudstack_loadbalancer_test.go | Adds regression tests for VM/rule-instance pagination and duplicate handling in reconciliation logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
78f631a to
ef5afc7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
cloudstack_loadbalancer.go:967
- listAll can return the same firewall rule on multiple pages if rules are created/deleted while paging (offset shifts). Because updateFirewallRule tracks candidates in a map keyed by *FirewallRule, duplicate entries with the same rule.Id won’t dedupe and can cause the “matching” rule to still be deleted. Deduplicate firewall rules by Id before returning them from listFirewallRules (or change filtering to key by rule.Id).
return rules, nil
}
|
|
||
| var hostIDs []string | ||
| var networkID string | ||
| seen := map[string]bool{} |
There was a problem hiding this comment.
add a comment to justify this variable
|
|
||
| var hostIDs []string | ||
| var networkID string | ||
| seen := map[string]bool{} |
There was a problem hiding this comment.
| seen := map[string]bool{} | |
| seen := map[string]bool{} // used to check whether the changing set of VMs contains one we had already seen in another page. |
| // Paging over a set of VMs that is changing underneath us can return | ||
| // the same VM on more than one page. |
There was a problem hiding this comment.
| // Paging over a set of VMs that is changing underneath us can return | |
| // the same VM on more than one page. |
DaanHoogland
left a comment
There was a problem hiding this comment.
core code looks good. I just wonder if we can structure the test code a little better, as in the loadbalancer test, the new methods are 140 and 110 lines long.
Fixes #99