Skip to content

Speed up sandbox pool listing and add app/service filters - #1426

Merged
phinze merged 1 commit into
mainfrom
phinze/mir_2191-miren-sandbox-pool-list-takes-10s-on-garden-and-has-no
Nov 4, 2026
Merged

phinze merged 1 commit into
mainfrom
phinze/mir_2191-miren-sandbox-pool-list-takes-10s-on-garden-and-has-no

Conversation

@phinze

@phinze phinze commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Listing sandbox pools takes about 10 seconds on a cluster with a few hundred app versions. Most of that is the released CLI, which resolves every app version's config from the client just to fill in the MODE column. Main already fixed the big part by moving the work behind the SandboxPools RPC, so the next release gets it for free. That path still made three store calls per pool in sequence, though, which takes it to about 0.8s against the same cluster.

This trims the server side. Each version is now resolved once, no matter how many pools share it. Scaling mode now comes from the stored config, since addon bindings only add variables and disks. That drops a round trip per pool, and inventory no longer loads addon credentials it was never going to show.

debug sandbox-pool list also gets --app and --service filters, matching sandbox list, plus an APP column. Addon pools have no owner field, only an app label, so they used to show up blank. The RPC now reports that label as their app and its app filter matches the reported name, so --app shop includes shop's database pool. The label is read after authorization and grants nothing. --service filters client-side.

Adding flags broke the pool CLI tests even though nothing they check changed, because they restated each command's option struct, tags and all. They now go through RunCommand with real flags. MIR-2193 tracks the same cleanup in the other test files.

Closes MIR-2191
Closes MIR-1361

miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze force-pushed the phinze/mir_2191-miren-sandbox-pool-list-takes-10s-on-garden-and-has-no branch from 4f9828e to bd6087f Compare November 3, 2026 22:21
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze marked this pull request as ready for review November 3, 2026 22:38
@phinze
phinze requested a review from a team as a code owner November 3, 2026 22:38

@evanphx evanphx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find

On a cluster with a few hundred app versions, the v0.17.2 CLI takes
about 10s to list pools because it resolves the runtime config of
every app version from the client. Main already moved that work
behind the SandboxPools RPC, but the server still made three serial
store calls per pool. Resolve each version once and read concurrency
from the stored config: addon bindings only supply variables and
disks, so resolving them cost a round trip and loaded credentials
without changing the scaling mode.

The list also gains --app and --service filters, matching `sandbox
list`, and an APP column so pools without a version or service are
identifiable (MIR-1361). Addon pools have no owner field, only an app
label, so the RPC now reports that label as their app and its app
filter matches the reported name. Labels are not indexed, which means
a filtered list walks every pool, but it skips version lookups for
excluded pools. The label grants nothing: it is read after
authorization, and app-bound callers still cannot see unowned pools.

The pool command tests now drive the commands through RunCommand
instead of restating each command's option struct, tags included, so
adding a flag no longer breaks them.
@phinze
phinze force-pushed the phinze/mir_2191-miren-sandbox-pool-list-takes-10s-on-garden-and-has-no branch from bd6087f to f381862 Compare November 4, 2026 16:52

@miren-code-agent miren-code-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍪 biscuit: ✅ ready to merge — auto-review, non-blocking

Approval recommended, not submitted: this repository is not enabled for autonomous approvals. This review is a comment, not a GitHub approval.

Nothing of substance has changed since my last review, and I still recommend approval. The branch is now a single commit, f381862, with the same content I reviewed at bd6087f. In servers/sandbox/pools.go:

  • filterInventoryApp still runs against each pool's real owner before the app label is read.
  • The label is used only to display ownerless pools and to match them against the app filter.
  • poolVersion reads concurrency through coreutil.ResolveConfig. That's safe for MODE because ResolveAddonConfig only touches Variables and service Disks.
  • TestPoolInventoryAddonPoolApp still pins the deny case for app-bound callers, and TestSandboxPoolListFilters still runs an addon pool through the real CLI flags.

There are no new comments or threads, and evanphx has approved this head.

Who sees addon pools under --app shop. Only cluster admins see shop's database pool there. A caller who owns shop but isn't a cluster admin still won't see it, because ownerless pools need admin rights. That matches what this code did before, so it isn't a regression. I'm mentioning it in case someone reads the description as "app owners now see their addon pools."

Older servers. On servers without the RPC, the legacy fallback filters --app client-side against pool.App(). That path never reads the label, so addon pools there still show - and drop out of a filtered listing. This only affects servers that predate the RPC, so I don't think it needs to block.

Why I'd skip another human pass: the only security-relevant change is moving authorization from a single upfront check to a per-pool check, and that check still runs before any label is read. A test covers the case where an app-bound caller must be denied. Everything else is a contained CLI and inventory change, and each new behavior has its own test.


🍪 full review note · reviewed at f381862

@phinze
phinze merged commit dde3ecb into main Nov 4, 2026
43 of 45 checks passed
@phinze
phinze deleted the phinze/mir_2191-miren-sandbox-pool-list-takes-10s-on-garden-and-has-no branch November 4, 2026 23:17
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