Repository navigation
grafana: one-command local run — from checkout to a rendering dashboard (fixes #421) - #422
Conversation
python3 grafana/run_local.py --project P --dataset D replaces the seven-step manual chain: downloads a pinned Grafana (12.3.0, satisfying the plugin's >=12.2.5 floor), installs the BigQuery datasource plugin, provisions auth (ADC by default, --sa-key for the documented JWT path with a real block-scalar private key), writes a patched copy of bqaa-dashboard.json with all six constants filled, creates adk_* views when bq-agent-sdk is on PATH, and launches with the plugin preinstaller disabled (a failed preinstall breaks all plugin loading with an opaque react/jsx-runtime 404). --stop tears it down; grafana/.local/ is disposable and gitignored; committed sources are never mutated. Safety: identifiers validated with the repository's identifier rules, prices restricted to plain decimals (they are interpolated into panel arithmetic), and the patcher refuses non-constant variables so the dashboard's constants-stay-constants contract is enforced in code. Verified end to end against a live 100,023-event table: provisioning, views, plugin install, health, and a datasource query all green; --stop kills cleanly. Tests cover validation, patching, provisioning shapes, the platform matrix, the version-floor pin, and a no-network --provision-only run: 40 passed.
Independent review at
|
Fresh review at
|
Independent spot-check of the changes-requested review — all five P1s reproduce from codeI re-verified each blocker against the worktree rather than taking the review at face value:
The P2 list is also accurate from code: For the record: my earlier review caught the prefix bug and the checksum gap but missed the bind-address and file-permission exposures — this round's review is the more complete one, and I concur with "not ready to merge" until the five P1s land and are reverified. |
…in, keep cost cap All five P1s from review, each verified live after fixing: - GF_SERVER_HTTP_ADDR=127.0.0.1 (empty http_addr binds every interface); netstat now shows 127.0.0.1-only LISTEN; env pinned by a test. - Credential-bearing datasource YAML written atomically as 0600 inside a 0700 directory (JWT path copies a private key); permissions asserted. - --view-prefix forwarded to bq-agent-sdk views create-all --prefix; the exact command is built by a pure function and tested. - processingLocation omitted by default (plugin auto-selects the job location; hard-coded US broke every non-US dataset), with a validated --processing-location override. - MaxBytesBilled preserved from datasource.example.yaml (100 MB default, validated --max-bytes-billed override) in both ADC and JWT shapes, placed under jsonData before the secure block. P2s: plugin pinned to 3.3.1 (installing latest could silently raise the floor #421 exists to eliminate); one-sided --time-from/--time-to rejected; downloads verified against the published .sha256 (plus --grafana-sha256 for independently pinned hashes on local archives); --stop verifies the pid still belongs to this homepath, waits for exit, and the printed stop hint includes a custom --workdir; tarfile data filter feature-detected for pre-3.10.12 interpreters. Live reverification: launch on :3007 with checksum verification, netstat loopback-only, datasource health OK, jsonData carries the 100 MB cap and no location, live query under the cap returned 100023, --stop clean. Tests: 57 in the runner suite, 83 with the dashboard suite.
…grafana/one-command-local
|
All five P1s and every P2 are fixed at the new head ( P1s
P2sPlugin pinned to ReverificationFull live rerun on |
Re-review at
|
…che-pin integrity Both P1 reproductions from review closed, plus the two cache paths: - Pre-3.10.12 fallback extraction validates every member (regular files/dirs only, no absolute paths, no traversal, no links) and fails loudly instead of falling back to unrestricted extractall; regression tests cover ../ traversal, absolute paths, symlinks, and a benign archive through the fallback path itself. - --stop verifies a strong launch identity: the command must start with the exact recorded grafana executable AND carry the --homepath argument AND the process start time must equal the one recorded at launch (defeats pid reuse). A live end-to-end test proves an unrelated process whose argv merely mentions the home path is never signalled; identity matching is pure and covered for lookalike, recycled-pid, and prefix-spoofed cases. - Cached plugin manifests are checked against the 3.3.1 pin; mismatched or corrupt manifests reinstall instead of silently bypassing the pin. - Extractions record archive-hash provenance; an explicitly supplied --grafana-sha256 is always honored — a cached home with different provenance is discarded and the archive re-verified (fails closed on mismatch), covered end to end with tiny synthetic archives.
Round-3 review at
|
Full fresh review at
|
The workdir holds one grafana.pid; a second launch overwrote it and orphaned the first instance - --stop then tore down only the newer process and reported success while an admin/admin Grafana kept running with no record left to stop it (review repro at 4542f4b). live_instance() now runs before any provisioning or launch: the pidfile is checked with the same strong identity matcher --stop uses; a live launcher-owned instance refuses the run with its pid, port, and the exact stop command; a stale record is removed and the run proceeds. The pidfile also records the port for that message. Regressions: a live identity-matching fake (bash exec'd by literal path, compound command so it cannot exec-optimize away) proves a second run exits 1, leaves the record and process untouched, and writes nothing; a stale record is cleared and the run proceeds. Verified live with real Grafana 12.3.0: second launch refused with the first instance healthy, then --stop clean.
|
The duplicate-launch P1 is closed at
Tests: 67 runner / 93 combined, all passing. Everything from all three review rounds is now closed; awaiting maintainer review. |
Heads-up: CI is red at
|
Full fresh review at
|
Independent confirmation of the round-4 findingsThe concurrent-launch race is real by construction — verified from the code layout: The Linux CI failure diagnosis converges with mine. I reported the same red matrix last cycle and pointed at the ps-rendering side; your narrowing to the recorded-exe prefix mismatch on Ubuntu is consistent — the helper records Nothing to add on the P2 (body test counts) — agreed it should be refreshed with the final numbers after the blockers close. |
…y fake - The live_instance() check alone was check-then-act: two overlapping launches could both observe no pidfile and the loser's overwrite orphaned the winner's Grafana (review repro at fea1726). An exclusive non-blocking flock on workdir/launch.lock is now taken BEFORE the liveness check and held through process launch and pidfile publication; a losing contender exits 1 with a clear message, and --stop takes the same lock so it cannot race a launch in flight. Regressions: same-process lock exclusivity, and two real contender processes with a deterministic test-only hold proving exactly one owner ([0, 1] exit codes, loser told a launch is in progress, provisioning written exactly once). - The Linux CI failure: the identity fake recorded /bin/bash while Ubuntu's ps reports a different canonical prefix, so the guard treated the record as stale and CI's regression exited 0. The fake now records the executable exactly as ps reports it (probe-derived), making the regression platform-stable; the real-Grafana path was unaffected. Live reverification with real Grafana 12.3.0: launch, duplicate refusal with pid/port/stop-hint, first instance healthy throughout, clean stop. Tests: 69 runner / 95 combined.
|
Both P1s closed at
All required checks should go green on this head; local combined suite is 95 passed with zero warnings. |
CI still red at
|
… stale
The CI diagnostic showed procps cutting the probed command at ~80
columns ('--homepath /'), so the --homepath containment check failed
and the guard treated a live record as stale. This was a real Linux
bug, not only a test artifact: a genuine grafana under a long workdir
path would have been mis-judged the same way by --stop and the
duplicate-launch guard. -ww requests unlimited width on both procps
and BSD ps.
|
Both P1s are now closed with all required checks green at The Linux investigation deserves an honest correction and a credit: the red matrix was not merely the test fake's identity, as I first fixed. A CI diagnostic dump showed Ubuntu's Recap of the round at this head:
Awaiting maintainer review. |
CI green at
|
Root cause confirmed:
|
…configurator (#450) * chore(release): 0.5.1 — evalbench reader, canonical rubrics, single-input configurator Version bump 0.5.0 -> 0.5.1 and the changelog cut for everything merged since v0.5.0 (2026-08-11). In the wheel: the EvalBench BigQuery run reader (#444), canonical evaluation rubrics in core (#431), and the CLI judge-feedback escaping fix (#438). Repo/live-template side: the single fully-qualified table-ID configurator entrance (#449), Console table-link paste (#424), the attested external-access contract with its staleness workflow (#446), the end-user manual (#425), Grafana metric and scan-bound fixes (#433) with the one-command local run (#422), and the documentation and CI follow-ups. * chore(release): fold #432 golden-matching into the 0.5.1 cut The release branch was cut one commit before #432 landed on main; the synthetic merge CI builds would already ship golden_matching.py in the 0.5.1 wheel, so the module and its three top-level exports must be in the release section. Merges main and documents the module in Release highlights and Added.
Summary
Fixes #421. The Grafana e2e path collapses from seven manual steps (plus two undocumented failure modes) to:
The script (stdlib-only, macOS/Linux, amd64/arm64) downloads, checksum-verifies, and caches a pinned Grafana, installs the pinned BigQuery datasource plugin (3.3.1, manifest-verified on every rerun), provisions auth, patches a copy of
bqaa-dashboard.jsonwith all six constants, creates the prefixed views whenbq-agent-sdkis on PATH, launches bound to 127.0.0.1, health-polls, and prints the dashboard URL.--stoptears it down with strong process-identity verification. Everything generated lives in gitignoredgrafana/.local/; committed sources are never mutated.Hardening (both review rounds)
GF_SERVER_HTTP_ADDR=127.0.0.1, env pinned by test) — never a wildcard listener with admin/admin.0600in a0700dir (JWT path carries a private key).processingLocationomitted (plugin auto-selects); validated--processing-locationoverride.MaxBytesBilled: 100000000default fromdatasource.example.yaml, validated override, both auth shapes.datafilter where available; on pre-3.10.12/3.11.4 the fallback validates every member (no traversal, no absolute paths, no links/special files) and fails loudly — regression-tested with malicious archives.--stopcannot kill an unrelated process: exact-executable +--homepathargument + recorded process start time (defeats PID reuse); a live test proves a lookalike process whose argv mentions the home path is never signalled.flockon the workdir is taken before the liveness check and held through pidfile publication — concurrent launches yield exactly one owner (two-contender regression), a second launch is refused with the pid/port/stop command while an instance lives, and--stoptakes the same lock so it cannot race a launch in flight.--grafana-sha256is always honored — mismatched caches are discarded and fail closed..sha256; one-sided--time-from/--time-torejected; identifiers/prices validated before any write; the patcher refuses non-constant variables (the dashboard's injection-safety contract, enforced in code).Verification
netstat) → datasource health OK →jsonDatacarries the cost cap and no pinned location → live query under the cap returned 100,023 →--stopclean.Files
grafana/run_local.py— the launchertests/test_grafana_local_runner.py— 69 testsgrafana/README.md— Quick-start + known pitfalls.gitignore—grafana/.local/