Skip to content

Cap CLI page-size chunking to the server's max_find_by_ids across paged commands #2872

Description

@chet

Every paged get_all_* wrapper in the admin-cli's ApiClient chunks ids by the CLI's page_size, but the server's *ByIds handlers reject any request whose id count exceeds runtime_config.max_find_by_ids. The two limits are configured independently, so a deployment with page_size > max_find_by_ids makes those list commands fail with InvalidArgument. The pattern is latent across ~18 paged wrappers (machines, instances, racks, switches, power-shelves, network-segments, VPCs, DPAs, partitions, keysets, NSGs, instance-types, remediations, explored managed-hosts/endpoints, mlx devices, …), and ~23 server *ByIds handlers enforce the cap. Surfaced by CodeRabbit on PR #2833.

What this involves

  • Add a shared ApiClient helper -- effective_chunk_size(page_size) -- that reads the server's max_find_by_ids from RuntimeConfig (already on forge.proto field 30, and already fetched via the version RPC; see dpu/versions/cmd.rs) and returns min(page_size, max_find_by_ids).
  • Route every paged get_all_* wrapper through it, replacing the bare .chunks(page_size) with the capped size.
  • Guard the unset case: if the server reports max_find_by_ids == 0 (default/unset), fall back to page_size -- chunks(0) panics.
  • Fetch the cap once per command (a single version call per get_all_*), not per page.

Follow-up to PR #2833 / #2765.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

Status
Verify

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions