Skip to content

feat(ctl): filter frontend list by cluster id - #1321

Open
KannarFr wants to merge 1 commit into
mainfrom
feat/ctl-frontend-list-cluster-filter
Open

feat(ctl): filter frontend list by cluster id#1321
KannarFr wants to merge 1 commit into
mainfrom
feat/ctl-frontend-list-cluster-filter

Conversation

@KannarFr

@KannarFr KannarFr commented Sep 9, 2026

Copy link
Copy Markdown
Member

What

sozu frontend list could only be narrowed by protocol and by domain. Answering "which frontends belong to this cluster, and what access-log tags do they carry?" meant dumping every frontend and filtering client-side.

FrontendFilters gains an optional cluster_id (proto tag 5), wired to sozu frontend list -i/--cluster-id <id>:

$ sozu frontend list -i MyCluster
┌─────────────────┬─────────────────┬─────────────┬──────────────────────────────────────────┬────────┬──────────┬────────────────────────────────────┐
│ HTTP frontends  │                 │             │                                          │        │          │                                    │
├─────────────────┼─────────────────┼─────────────┼──────────────────────────────────────────┼────────┼──────────┼────────────────────────────────────┤
│ cluster_id      │ address         │ hostname    │ path                                     │ method │ position │ tags                               │
├─────────────────┼─────────────────┼─────────────┼──────────────────────────────────────────┼────────┼──────────┼────────────────────────────────────┤
│ MyCluster       │ 127.0.0.1:18080 │ lolcatho.st │ PathRule { kind: Prefix, value: "/api" } │ None   │ 0        │ key=value, owner_id=MyOrganisation │
└─────────────────┴─────────────────┴─────────────┴──────────────────────────────────────────┴────────┴──────────┴────────────────────────────────────┘

ConfigState::list_frontends applies the filter to HTTP, HTTPS, TCP and UDP frontends, ANDed with the existing protocol and --domain filters. TCP and UDP frontends are keyed by cluster id in the state, so the filter is applied to the map key; HTTP/HTTPS frontends carry an optional cluster id, and a frontend that denies traffic (no cluster id) therefore never matches.

Protocol / security impact

  • Protocol: additive proto change only — a new optional field on FrontendFilters at an unused tag. An older client omits it and gets the previous (unfiltered) behaviour; an older main process ignores it. No worker-facing message changes.
  • Security: none. Read-only control-plane query, no new state mutation, no new network-facing parsing.

Tests

Added list_frontends_filters_by_cluster_id (command/src/state.rs), asserting both the positive and the negative space: the wanted frontend of every protocol is listed, no other cluster's frontend leaks through, an unknown id matches nothing, a Deny frontend is never selected, and cluster_id composes with (rather than replaces) the protocol and domain filters.

Commands run

cargo build --locked
cargo +nightly fmt --all -- --check
cargo clippy --all-targets --locked -- -D warnings
cargo test --locked -p sozu-command-lib -p sozu     # 306 passed, 5 ignored

Also exercised against a running proxy: frontend list -i MyCluster narrows a two-cluster state to one cluster's frontends, and frontend list -i nope returns nothing.

Docs

CHANGELOG.md[Unreleased] / ✨ Added.

🤖 Generated with Claude Code

`sozu frontend list` could only be narrowed by protocol and by domain, so
answering "which frontends belong to this cluster, and what access-log
tags do they carry?" meant dumping every frontend and filtering
client-side.

`FrontendFilters` gains an optional `cluster_id` (proto tag `5`), wired
to `sozu frontend list -i/--cluster-id <id>`.
`ConfigState::list_frontends` applies it to HTTP, HTTPS, TCP and UDP
frontends, ANDed with the existing protocol and `--domain` filters. TCP
and UDP frontends are keyed by cluster id in the state, so the filter is
applied to the map key; HTTP/HTTPS frontends carry an optional cluster
id, and a frontend that denies traffic (no cluster id) therefore never
matches.

Covered by `list_frontends_filters_by_cluster_id`, which asserts both the
positive and the negative space: the wanted frontend of every protocol is
listed, no other cluster's frontend leaks through, an unknown id matches
nothing, a `Deny` frontend is never selected, and `cluster_id` composes
with (rather than replaces) the protocol and domain filters.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: kannar <kannarfr@gmail.com>
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.

1 participant