feat: per-tenant BackendStorageRouting emit (part 2/2) - #336
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pair with ASAPQuery-backend PR #107.
Adds an explicit
tenantfield to the controller-emittedBackendStorageRoutingJSON document so multi-tenant deploys canpush per-tenant routing tables to the backend's
POST /api/v1/storage_routingendpoint.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
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 theemitted JSON's top-level
tenantfield, e.g.{ "tenant": "tenant-a", "default_engine": "sketch_warm_tier", "metrics": [ ... ] }emit_backend_storage_routing/emit_backend_storage_routing_with_prometheus) delegate tothe per-tenant variants with
DEFAULT_TENANT = "default"—existing single-tenant
main.rscallers remain unchanged.Test coverage
storage_routing_default_tenant_for_single_tenant_emit— thelegacy 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 ofthe JSON (alphabetical key order in
serde_json::Value::Map).Out of scope (matches backend part 1/2)
defaulttenant through the controller'sworkload registry / planner —
main.rsstill calls thesingle-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) passescargo test --release— allstage_configtests green(42/42 stage-config; 10 pre-existing failures elsewhere
on
origin/mainare unrelated to this change)Related
🤖 Generated with Claude Code