[CF-4208] Add --page-size to on-prem Flink list commands - #3424
[CF-4208] Add --page-size to on-prem Flink list commands#3424Paras Negi (paras-negi-flink) wants to merge 3 commits into
--page-size to on-prem Flink list commands#3424Conversation
|
❌ Error getting contributor login(s). |
There was a problem hiding this comment.
Pull request overview
This PR closes CF-4208 by adding user-facing pagination control (--limit) across on-prem Flink “list” commands and introducing flink application list filtering (--name, --status). It also refactors the CMF REST client to centralize paging behavior (including limit short-circuiting) and updates test server behavior plus integration fixtures accordingly.
Changes:
- Add a shared
--limitflag (default 0 = unlimited) to on-prem Flink list commands, applying it server-side where endpoints are paginated and client-side for non-paginated exception listing. - Add
--name/--statusfiltering toflink application listby composing CMF’s genericfilterquery parameter. - Refactor duplicated CMF paging loops into a generic
listAllPageshelper and add unit + integration coverage (with updated goldens).
Reviewed changes
Copilot reviewed 46 out of 47 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test-server/flink_onprem_handler.go | Adds CMF applications filter query emulation in the test server. |
| test/flink_onprem_test.go | Adds integration coverage for --limit and application list filtering flags. |
| test/fixtures/output/flink/statement/list-limit-json.golden | New golden output for statement list with --limit. |
| test/fixtures/output/flink/statement/list-help-onprem.golden | Updates help golden to include --limit. |
| test/fixtures/output/flink/statement/list-env-missing-failure.golden | Updates failure/help golden to include --limit. |
| test/fixtures/output/flink/statement/exception/list-help-onprem.golden | Updates help golden to include --limit for exception list. |
| test/fixtures/output/flink/secret/list-help-onprem.golden | Updates help golden to include --limit for secret list. |
| test/fixtures/output/flink/secret-mapping/list-help-onprem.golden | Updates help golden to include --limit for secret-mapping list. |
| test/fixtures/output/flink/savepoint/list-help-onprem.golden | Updates help golden to include --limit for savepoint list. |
| test/fixtures/output/flink/savepoint/list-fail-both.golden | Updates failure/help golden to include --limit. |
| test/fixtures/output/flink/environment/list-help-onprem.golden | Updates help golden to include --limit for environment list. |
| test/fixtures/output/flink/detached-savepoint/list-limit-json.golden | New golden output for detached-savepoint list with --limit. |
| test/fixtures/output/flink/detached-savepoint/list-help-onprem.golden | Updates help golden to include --limit. |
| test/fixtures/output/flink/compute-pool/list-missing-env-flag-failure.golden | Updates failure/help golden to include --limit. |
| test/fixtures/output/flink/compute-pool/list-help-onprem.golden | Updates help golden to include --limit. |
| test/fixtures/output/flink/catalog/list-help-onprem.golden | Updates help golden to include --limit. |
| test/fixtures/output/flink/catalog/database/list-help-onprem.golden | Updates help golden to include --limit. |
| test/fixtures/output/flink/application/list-status-no-match-json.golden | New golden output for application list status filter no-match case. |
| test/fixtures/output/flink/application/list-status-filter-json.golden | New golden output for application list status filter match case. |
| test/fixtures/output/flink/application/list-name-filter-json.golden | New golden output for application list name filter case. |
| test/fixtures/output/flink/application/list-limit-json.golden | New golden output for application list with --limit. |
| test/fixtures/output/flink/application/list-limit-invalid.golden | New golden output for invalid --limit value. |
| test/fixtures/output/flink/application/list-help-onprem.golden | Updates help golden to include --name, --status, and --limit. |
| test/fixtures/output/flink/application/list-env-missing.golden | Updates env-missing output to include new flags in help text. |
| test/fixtures/output/flink/application/instance/list-help-onprem.golden | Updates help golden to include --limit for instance list. |
| test/fixtures/output/flink/application/instance-list-env-missing.golden | Updates failure/help golden to include --limit. |
| test/fixtures/output/flink/application/instance-list-app-missing.golden | Updates failure/help golden to include --limit. |
| test/fixtures/output/flink/application/event/list-help-onprem.golden | Updates help golden to include --limit for event list. |
| test/fixtures/output/flink/application/event-list-missing-flags.golden | Updates failure/help golden to include --limit. |
| test/fixtures/output/flink/application/event-list-app-missing.golden | Updates failure/help golden to include --limit. |
| pkg/flink/test/mock/cmf_client_mock.go | Updates generated CMF client mock for the new ListStatements(..., limit) signature. |
| pkg/flink/cmf_rest_client.go | Refactors paging into listAllPages and threads limit through CMF list calls. |
| pkg/flink/cmf_rest_client_test.go | Adds unit tests for listAllPages behavior across limits and paging scenarios. |
| internal/flink/command.go | Adds shared --limit flag registration and parsing helper (getLimit). |
| internal/flink/command_statement_list_onprem.go | Wires --limit into on-prem statement list via CMF client. |
| internal/flink/command_statement_exception_list_onprem.go | Adds --limit and truncates exceptions client-side for non-paginated endpoint. |
| internal/flink/command_secret_mapping_list.go | Wires --limit into secret-mapping list. |
| internal/flink/command_secret_list.go | Wires --limit into secret list. |
| internal/flink/command_savepoint_list.go | Wires --limit into savepoint list. |
| internal/flink/command_environment_list.go | Wires --limit into environment list. |
| internal/flink/command_detached_savepoint_list.go | Wires --limit into detached-savepoint list. |
| internal/flink/command_compute_pool_list_onprem.go | Wires --limit into compute-pool list. |
| internal/flink/command_catalog_list.go | Wires --limit into catalog list. |
| internal/flink/command_catalog_database_list.go | Wires --limit into catalog database list. |
| internal/flink/command_application_list.go | Adds --name/--status filtering and wires --limit into application list. |
| internal/flink/command_application_instance_list.go | Wires --limit into application instance list. |
| internal/flink/command_application_event_list.go | Wires --limit into application event list. |
Files not reviewed (1)
- pkg/flink/test/mock/cmf_client_mock.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The on-prem Flink (CPF/CMF) list commands loop over a hardcoded 100-item page size with no way to control it, so listing a large environment costs many serial round trips (~51 requests for 5000 applications). Add a --page-size flag to every paginated on-prem list command so callers can fetch the full list in fewer, larger requests. It defaults to 100, which preserves today's behavior and output. Collapse the 12 duplicated pagination loops in the CMF client into a single generic listAllPages helper that takes the page size. The requested size is passed through to the CMF page/size API; the loop still terminates on the first empty page. Server-side filtering for `application list` is deliberately left out and will follow in a separate PR stacked on this one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bba9ac2 to
1ecbfcb
Compare
--limit pagination and application list filtering to on-prem Flink--page-size to on-prem Flink list commands
…logical pagination cases - Reword the --page-size help so it reads as a per-request batch size, not a cap on total results (regenerate the affected help/usage goldens). - Add an integration case for --page-size > MaxInt32 (3000000000), exercising the previously untested upper-bound branch of getPageSize (reuses the invalid golden). - Drop the statement/detached-savepoint --page-size cases: those mock handlers ignore the size param, so the cases only verified flag plumbing (already covered by the help goldens) rather than pagination. The applications case (mock genuinely pages) plus TestListAllPages remain the real coverage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Steven Gagniere (sgagniere)
left a comment
There was a problem hiding this comment.
Hi, just a few comments. Otherwise lgtm
| } | ||
|
|
||
| func addPageSizeFlag(cmd *cobra.Command) { | ||
| cmd.Flags().Int("page-size", 0, "Number of results to fetch per API request while paginating; does not cap the total results returned. Defaults to 100.") |
There was a problem hiding this comment.
| cmd.Flags().Int("page-size", 0, "Number of results to fetch per API request while paginating; does not cap the total results returned. Defaults to 100.") | |
| cmd.Flags().Int("page-size", 100, "Number of results to fetch per API request while paginating; does not cap the total results returned. Defaults to 100.") |
I think we can set this to 100 to match the description.
There was a problem hiding this comment.
Done.
| func getPageSize(cmd *cobra.Command) (int32, error) { | ||
| pageSize, err := cmd.Flags().GetInt("page-size") | ||
| if err != nil { | ||
| return 0, err | ||
| } | ||
| if pageSize < 0 || pageSize > math.MaxInt32 { | ||
| return 0, fmt.Errorf("`--page-size` must be between 0 and %d", math.MaxInt32) | ||
| } | ||
| return int32(pageSize), nil | ||
| } |
There was a problem hiding this comment.
Generally we want to avoid client side validation for things that aren't recorded in the spec, so I think we should remove these checks and treat this like a regular flag read.
There was a problem hiding this comment.
Good catch, fixed in the latest commit.
…e validation Per review on #3424: - Default the flag to 100 (matching the documented behavior) instead of the 0 sentinel, and drop the redundant "Defaults to 100." text since pflag now renders "(default 100)". - Change the flag type to Int32 and read it directly, removing the hand-rolled range validation. Out-of-range input is now rejected by the flag parser itself (no client-side validation not backed by the spec), which also closes the int32-overflow concern. Non-positive values fall back to the default page size in listAllPages. Regenerated the affected help and usage goldens. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Release Notes
New Features
--page-sizeflag to the on-prem (Confluent Platform / CMF)confluent flink ... listcommands, to fetch large result sets in fewer, larger API requests. Defaults to 100 — existing behavior is unchanged.Checklist
Whatsection below whether this PR applies to Confluent Cloud, Confluent Platform, or both.Test & Reviewsection below.Blast Radiussection below.What
Confluent Platform (CMF on-prem) only — part of CF-4208; Confluent Cloud
flinkcommands are untouched.On-prem Flink list commands paginate at a hardcoded
size=100and always fetch every page, so large environments cost many serial round trips (~51 requests for 5000 applications — CF-4202).--page-sizeto all paginated on-prem list commands (application/event/instance/catalog/catalog database/compute-pool/detached-savepoint/environment/savepoint/secret/secret-mapping/statementlist). SharedaddPageSizeFlag/getPageSizeincommand.govalidate0..MaxInt32;0= the default 100.pkg/flink/cmf_rest_client.gointo one genericlistAllPageshelper (net −84 lines).statement exception listis untouched (non-paginated).Blast Radius
--page-size 0reproduces today's output exactly. Non-breaking, easy to revert.listAllPagesunit test plus multi-page integration coverage.References
--name/--statusfiltering to on-prem application list #3428.Test & Review
TestListAllPages: default / custom / large size (fewer round trips), size > total, empty, error propagation.--page-sizeon application / statement / detached-savepoint list (full list fetched across multiple pages) + invalid--page-size -1; help goldens regenerated.make lintclean.