Skip to content

feat: per-tenant BackendStorageRouting emit (part 2/2) - #336

Merged
zzylol merged 1 commit into
mainfrom
feat/per-tenant-routing-controller
May 8, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/per-tenant-routing-controller

Conversation

@zzylol

@zzylol zzylol commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Pair with ASAPQuery-backend PR #107.
Adds an explicit tenant field to the controller-emitted
BackendStorageRouting JSON document so multi-tenant deploys can
push per-tenant routing tables to the backend's
POST /api/v1/storage_routing endpoint.

This is part 2/2 — the controller emit path. Part 1 (the
data model + per-tenant lookup + per-tenant hot-reload swap) has
already merged on ASAPQuery-backend@main.

Controller emit shape

  • New emit_backend_storage_routing_for_tenant(tenant, plans)
    and emit_backend_storage_routing_with_prometheus_for_tenant( tenant, plans, mode3) entry points. The tenant lands in the
    emitted JSON's top-level tenant field, e.g.
{
  "tenant": "tenant-a",
  "default_engine": "sketch_warm_tier",
  "metrics": [ ... ]
}
  • The single-tenant aliases (emit_backend_storage_routing /
    emit_backend_storage_routing_with_prometheus) delegate to
    the per-tenant variants with DEFAULT_TENANT = "default"
    existing single-tenant main.rs callers remain unchanged.

Test coverage

  • storage_routing_default_tenant_for_single_tenant_emit — the
    legacy entry point still emits tenant: "default".
  • storage_routing_for_tenant_emits_explicit_tenant_field
    the per-tenant entry point threads the explicit tenant id.
  • storage_routing_with_prometheus_for_tenant_emits_explicit_tenant_field
    — same shape extends to the Mode-3 (Prometheus archive)
    emit path.
  • storage_routing_three_metric_snapshot_stable (existing) —
    updated to include the tenant: "default" field at the end of
    the JSON (alphabetical key order in serde_json::Value::Map).

Out of scope (matches backend part 1/2)

  • Tenant-aware AUTH.
  • Per-tenant sketch state isolation.
  • Threading a non-default tenant through the controller's
    workload registry / planner — main.rs still calls the
    single-tenant alias. Multi-tenant planning is a follow-up
    that needs the controller's workload registry to grow a
    tenant axis (separate from the routing-table follow-up).

Test plan

  • cargo build --release (controller) passes
  • cargo test --release — all stage_config tests green
    (42/42 stage-config; 10 pre-existing failures elsewhere
    on origin/main are unrelated to this change)
  • Pairs with backend PR DEBS 2022 Case Study #107 (merged)

Related

🤖 Generated with Claude Code

Pair with ASAPQuery-backend's per-tenant `BackendStorageRouting`
data-model + lookup change. Adds an explicit `tenant` field to
the controller-emitted JSON document the backend's
`POST /api/v1/storage_routing` endpoint consumes.

* New `emit_backend_storage_routing_for_tenant(tenant, plans)`
  and `emit_backend_storage_routing_with_prometheus_for_tenant(
  tenant, plans, mode3)` entry points. Tenant lands in the
  emitted JSON's top-level `tenant` field; the backend's
  per-tenant swap routes to the named slot.
* The single-tenant aliases (`emit_backend_storage_routing` /
  `emit_backend_storage_routing_with_prometheus`) keep emitting
  the `default` tenant id so existing single-tenant deploys are
  source-compatible.
* `DEFAULT_TENANT` constant mirrors the backend's value so the
  controller doesn't take a build-time dep on the backend crate.
* Snapshot test updated for the new `tenant: "default"` field;
  three new unit tests cover the per-tenant emit path.

Out of scope (matches backend part 1/2):
* Tenant-aware AUTH.
* Per-tenant sketch state isolation.

Closes the per-tenant follow-up flagged in PR #333.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 1f7cf63 into main May 8, 2026
@zzylol
zzylol deleted the feat/per-tenant-routing-controller branch May 9, 2026 18:00
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