Skip to content

Add keyspace, shard, and tablet-type/alias filters to ListTablets#317

Merged
nickvanw merged 2 commits into
mainfrom
add-tablets-filters
Jun 9, 2026
Merged

Add keyspace, shard, and tablet-type/alias filters to ListTablets#317
nickvanw merged 2 commits into
mainfrom
add-tablets-filters

Conversation

@nickvanw

@nickvanw nickvanw commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Vtctld.ListTablets sent no query parameters, so callers (notably pscale branch list-tablets) had to fetch every tablet on a branch and filter client-side. On large, multi-keyspace branches that makes finding a specific tablet alias painful

Changes

ListBranchTabletsRequest gains four optional filter fields:

  • Keyspace, Shard, TabletType — sent as keyspace / shard / tablet_type query parameters.
  • TabletAliases []string — sent as a single comma-separated tablet_alias query parameter (matching the api-bb contract). When set, the server ignores the other filters.

Only non-empty filters are added to the query string, so an unfiltered ListTablets call behaves exactly as before. The implementation uses the same WithQueryParams pattern as the other Vtctld methods (ListWorkflows, ListKeyspaces).

Testing

Added vtctld_tablets_test.go (there was no test file before):

  • unfiltered request sends no filter params and decodes the grouped response;
  • keyspace + shard + tablet_type are sent as the expected query params;
  • multiple TabletAliases are serialized into one comma-separated tablet_alias value.

go build, go vet, gofmt, and the full ./planetscale/ test suite pass locally.

ListTablets sent no query parameters, so callers had to fetch every
tablet on a branch. The branch tablets API now accepts filters that map
to vtctldclient GetTablets, so expose them on ListBranchTabletsRequest:

- Keyspace, Shard, and TabletType are sent as query parameters.
- TabletAliases is sent as a single comma-separated tablet_alias param.

Only non-empty filters are sent, so an unfiltered request is unchanged.
@nickvanw nickvanw requested a review from a team as a code owner June 8, 2026 23:52
@nickvanw nickvanw merged commit 736b89b into main Jun 9, 2026
6 checks passed
@nickvanw nickvanw deleted the add-tablets-filters branch June 9, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants