Skip to content

mvp #46: default archive engine + precompute /jobs API alignment - #119

Merged
zzylol merged 1 commit into
mainfrom
backend/default-archive-and-precompute-jobs
May 9, 2026
Merged

zzylol merged 1 commit into
mainfrom
backend/default-archive-and-precompute-jobs

Conversation

@zzylol

@zzylol zzylol commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Two narrow follow-ons to the controller↔backend wiring work. v7 RoutingTarget flatten was dropped after audit found the controller does emit shape-based multi-target routing (cold S3 fallback for ad-hoc count/topk on http_requests_total{service="payments"} relies on it). Multi-target stays.

4 files, +368 / −12.

(1) Default archive engine

When neither ASAP_THANOS_QUERY_URL nor ASAP_GORILLA_S3_* is set, the backend used to leave the cold-tier slot empty → archive queries returned 503 NoEngineRegistered. Now: engines/no_data_archive.rs registers a stub aliased onto gorilla_archive. Returns empty instant vector for any query with one warn-log at construction.

Opt back into fail-loud via ASAP_REQUIRE_ARCHIVE_ENGINE=1.

(2) Precompute /jobs API

Controller's PrecomputeClient calls POST /api/v1/precompute/jobs and DELETE /api/v1/precompute/jobs/:job_id. Backend only routed POST /api/v1/precompute (different shape). Adds the controller's routes alongside the existing one:

  • PrecomputeJobSpec matches the controller's JobRequest byte-for-byte
  • PrecomputeJobRegistry is an Arc<RwLock<HashMap>> on HttpServer/AppState
  • Registration returns {job_id, status, created_at}; DELETE returns 204 / 404
  • In-memory tracking only; actual precompute scheduling is a later wiring

Test plan

  • cargo build clean
  • cargo test --lib --no-fail-fast: 881 passed / 32 failed / 11 ignored (failures match pre-existing main baseline; 4 new tests pass)
  • Smoke: bring up mvp-multi-stage.yml overlay without ASAP_THANOS_QUERY_URL and confirm cold queries return empty instead of 503

🤖 Generated with Claude Code

Two narrow follow-ons to the controller↔backend wiring work; v7
RoutingTarget flatten was dropped after audit found the controller
**does** emit shape-based multi-target routing (cold S3 fallback for
ad-hoc count/topk on `http_requests_total{service="payments"}`
relies on it). Multi-target stays.

## Default archive engine

When neither `ASAP_THANOS_QUERY_URL` nor the `ASAP_GORILLA_S3_*`
env-var family is configured, the backend used to leave the cold-tier
slot empty → archive queries returned `503 NoEngineRegistered`. New
`engines/no_data_archive.rs` registers a `NoDataArchiveEngine` stub
under `data_source_id = "no_data_archive"`, aliased onto
`gorilla_archive` so the existing `compatible_storage_backends`
failover sequence finds it. Returns an empty instant vector for any
query, with one warn-log at construction.

`ASAP_REQUIRE_ARCHIVE_ENGINE=1` opts back into the original
fail-loud `503` for environments where missing config should be
treated as a deploy error rather than soft-empty.

## Precompute /jobs API

The controller's `PrecomputeClient` (controller/src/config/
precompute.rs) registers + cancels precompute jobs via:

  POST   /api/v1/precompute/jobs            register
  DELETE /api/v1/precompute/jobs/:job_id    cancel

The backend only routed `POST /api/v1/precompute` (different shape).
Adds the controller's `/jobs` routes alongside the existing route:

* `PrecomputeJobSpec` matches the controller's `JobRequest` byte-
  for-byte (`{query, granularity, source, sketch_type, store_path}`).
* `PrecomputeJobRegistry` is an in-memory `Arc<RwLock<HashMap<...>>>`
  on `HttpServer`/`AppState`. Registration returns
  `{job_id (UUID), status: "created", created_at}`; DELETE returns
  204 on hit, 404 on miss. Spec is tracked in memory; precompute
  scheduling is a later wiring.

The legacy `POST /api/v1/precompute` route stays untouched.

Verification:
- `cargo build` clean.
- `cargo test --lib --no-fail-fast`: **881 passed / 32 failed / 11
  ignored**. 32 failures are pre-existing datafusion + schema-
  timeline-dispatch failures unrelated to this PR. New tests pass:
  `engines::no_data_archive::tests::execute_returns_empty_instant_vector`,
  `capabilities_use_no_data_archive_id`,
  `drivers::query::servers::http::tests::http_precompute_jobs_register_then_delete_roundtrip`,
  `http_precompute_jobs_delete_unknown_id_returns_404`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 1d1a0bc into main May 9, 2026
@zzylol
zzylol deleted the backend/default-archive-and-precompute-jobs branch May 9, 2026 19:51
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