Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,22 @@ conflict with a third party's registered US trademark in cloud services.
- Container images are `ghcr.io/labstack/pitot` and `docker.io/labstack/pitot`.
Update deployment manifests, service names, install URLs and MCP client entries.
The MCP Registry identity is `io.github.labstack/pitot`.
- The server and installer refuse to start if any variable with the exact,
case-sensitive pre-rename prefix is set, including empty assignments,
installer overrides and secret-file settings. The error lists names only.
Rename those variables to `PITOT_*` before upgrading; they no longer silently
use defaults.
- Configure the server and installer with `PITOT_*` environment variables.
- The query language is now **PitotQL**. Existing structured dashboard queries,
MCP `query_telemetry` arguments (`text`, `panel.query`, `panel.sql`), query
keywords, Explore URL parameters and browser storage keys are unchanged.
Previous query HTTP paths, MCP reference URI and error-code reader aliases
are removed. Clients must use canonical PitotQL names. Permanent website
redirects preserve existing documentation links. See
[rename compatibility](site/src/content/docs/docs/reference/rename-compatibility.mdx) for the cutover requirements.
- Before upgrading, stop the service and take a cold backup of the complete
data directory. On startup, Pitot automatically renames the previous control
database and its SQLite WAL, shared-memory and rollback-journal sidecars in
`control/` to `pitot.sqlite` and matching sidecar names, then syncs the directory.
No manual filename change is needed, including for unattended agent upgrades.
If both database names or an incomplete sidecar move exist, startup refuses
before opening SQLite; stop the instance and recover a consistent file set
from the cold backup before retrying. Never delete a database just to bypass
this refusal or create a fresh volume by accident. For rollback to the previous
binary, restore its complete cold backup before starting it; older binaries
do not move the database name back.
- Telemetry spill footer keys retain their persisted format-5 spelling so
existing Parquet files remain valid and byte compatibility stays unchanged.
are removed. Clients must use canonical PitotQL names.
- The control database is `control/pitot.sqlite`; startup opens only this name.
- Telemetry spill footer keys use `pitot.spill.`. Batches with previous spill
keys fail verification and must be replaced before use.
- Sessions use the `pitot_session` cookie (with the `__Host-` prefix over HTTPS),
so users must sign in again. Keyboard shortcut preferences reset. Saved chat
activities using the previous MCP App URI no longer render; begin a new chat.
Reserved diagnostic context metadata now uses `_pitot_diagnostic_context`;
discard pre-rename chat history before resuming chat.
- Published SQL migrations remain unchanged. Existing ingest and OAuth secrets
and their token prefixes remain valid. The image defaults to
`/var/lib/pitot/data`: mount the existing volume there, or set `PITOT_DATA_DIR`
- Existing ingest and OAuth secrets and their token prefixes remain valid.
The image defaults to `/var/lib/pitot/data`: mount the existing volume there, or set `PITOT_DATA_DIR`
to its existing mount location.
- HTTP request headers and metrics use the Pitot name. Update custom clients
using the product request header to `Pitot-Request` (and dashboard deletion confirmation to
Expand Down
8 changes: 0 additions & 8 deletions cmd/pitot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ type loginLinkCommand struct {
}

func main() {
if err := store.RejectPreviousEnvironment(os.Environ()); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

showVersion, loginLink, healthURL, derivedProbe, repair, err := parseCommandLine(os.Args[1:], os.Stderr)
if errors.Is(err, flag.ErrHelp) {
return
Expand Down Expand Up @@ -716,9 +711,6 @@ func createLoginLink(cfg config.Config, rawEmail string, breakGlass bool, output
if err != nil {
return err
}
if err := store.MigrateControlDatabase(cfg.ControlSQLitePath()); err != nil {
return err
}
if _, err := os.Stat(cfg.ControlSQLitePath()); err != nil {
if errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("control database does not exist at %s", cfg.ControlSQLitePath())
Expand Down
68 changes: 0 additions & 68 deletions cmd/pitot/main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"bufio"
"bytes"
"context"
"crypto/ecdsa"
Expand Down Expand Up @@ -825,70 +824,3 @@ func TestApplyConfiguredIngestTokenLogsWithoutToken(t *testing.T) {
t.Fatalf("logs must report both outcomes by setting name: %s", output)
}
}

func TestStartupRefusesRetiredEnvironmentBeforeStores(t *testing.T) {
if os.Getenv("TEST_STARTUP_CHILD") == "1" {
os.Args = []string{"pitot"}
main()
return
}
for _, retired := range []bool{true, false} {
t.Run(map[bool]string{true: "retired", false: "current"}[retired], func(t *testing.T) {
root := filepath.Join(t.TempDir(), "data")
ctx, cancel := context.WithTimeout(t.Context(), 30*time.Second)
defer cancel()
command := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestStartupRefusesRetiredEnvironmentBeforeStores$")
command.Env = []string{"TEST_STARTUP_CHILD=1", "PATH=" + os.Getenv("PATH"), "PITOT_DATA_DIR=" + root, "PITOT_ADDR=127.0.0.1:0", "PITOT_MCP_ENABLED=false", "PITOT_AUTH_CODE_SECRET=" + strings.Repeat("x", 32)}
// Test fixture for the exact retired prefix; production spelling is isolated.
const previous = "FANOUT_"
if retired {
command.Env = append(command.Env, previous+"DATA_DIR=private-value", previous+"TOKEN=")
output, err := command.CombinedOutput()
if err == nil || !strings.Contains(string(output), previous+"DATA_DIR") || !strings.Contains(string(output), previous+"TOKEN") || !strings.Contains(string(output), "rename them to PITOT_") || strings.Contains(string(output), "private-value") {
t.Fatalf("refusal: %s, %v", output, err)
}
if _, err := os.Stat(root); !os.IsNotExist(err) {
t.Fatalf("data directory touched before refusal: %v", err)
}
return
}
pipe, err := command.StderrPipe()
if err != nil {
t.Fatal(err)
}
if err := command.Start(); err != nil {
t.Fatal(err)
}
ready := make(chan bool, 1)
go func() {
scanner := bufio.NewScanner(pipe)
for scanner.Scan() {
if strings.Contains(scanner.Text(), "HTTP and OTLP listening") {
ready <- true
return
}
}
ready <- false
}()
select {
case started := <-ready:
if !started {
_ = command.Wait()
t.Fatal("current environment did not start")
}
if err := command.Process.Signal(os.Interrupt); err != nil {
t.Fatal(err)
}
if err := command.Wait(); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(filepath.Join(root, "control", "pitot.sqlite")); err != nil {
t.Fatal(err)
}
case <-ctx.Done():
_ = command.Wait()
t.Fatal("startup timed out")
}
})
}
}
2 changes: 1 addition & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ After merging the rename pull request:
separately according to registry policy. Do not publish from this branch.
6. Verify the upgrade steps in `CHANGELOG.md`, including the control database
filename, session cookies and saved chat metadata. Telemetry footer keys
retain their persisted format-5 spelling.
use the `pitot.spill.` namespace.
The pre-rename environment variable prefix is no longer read.

## Refresh landing stills
Expand Down
17 changes: 0 additions & 17 deletions internal/api/pitotql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,20 +458,3 @@ func TestPitotQLParseOffersSeenDottedKey(t *testing.T) {
}
}
}

func TestRetiredQueryRoutesAreNotRegistered(t *testing.T) {
for _, action := range []string{"parse", "format", "complete", "reference"} {
method := http.MethodPost
if action == "reference" {
method = http.MethodGet
}
path := "/api/fanql/" + action
if _, ok := classifyRoute(method, path); ok {
t.Fatalf("retired route classified: %s", path)
}
response := servePitotQL(t, &fakePitotQLParser{}, &fakePitotQLPanels{}, method, path, `{}`)
if response.Code != http.StatusNotFound {
t.Fatalf("retired route: %d %s", response.Code, response.Body)
}
}
}
1 change: 0 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ func (c Config) ControlDir() string {
}

func (c Config) ControlSQLitePath() string {
// Startup migrates the previous filename before opening this control database.
return filepath.Join(c.ControlDir(), "pitot.sqlite")
}

Expand Down
2 changes: 1 addition & 1 deletion internal/db/migrations/20260930000000_initial.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- +goose Up
-- Fanout control schema. sqlc reads these migrations to generate query bindings.
-- Pitot control schema. sqlc reads these migrations to generate query bindings.
-- DuckDB maintains its own telemetry query schema.

CREATE TABLE alert_rules (
Expand Down
2 changes: 1 addition & 1 deletion internal/db/migrations/20261004000000_dashboard_specs.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- +goose Up
-- Dashboards become typed v1 specs with a version history. The widget model
-- is replaced outright: Fanout is pre-release, so existing dashboards are
-- is replaced outright: Pitot is pre-release, so existing dashboards are
-- dropped and each owner receives the new default dashboard on next visit.
DROP TABLE dashboard_widgets;
DROP TABLE dashboards;
Expand Down
4 changes: 2 additions & 2 deletions internal/db/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
// never change or remove a checksum for a migration already published.
func TestMigrationChecksums(t *testing.T) {
checksums := map[string]string{
"migrations/20260930000000_initial.sql": "2f256d45df0a604c198e165af00b66f63d9f36b13e27f2898c485da524883203",
"migrations/20261004000000_dashboard_specs.sql": "11894224e7c3ef0efcacae9a6f5f8f6d4af27ddd81ed8868b96b44fb9bbf7d36",
"migrations/20260930000000_initial.sql": "4e944361f785f869c855a9677987dd73c15edc694c2c0e41e4fcc05569711961",
"migrations/20261004000000_dashboard_specs.sql": "8b51ab3a02cf1acc9709bae2b29cfaba9320555293d17cd30b7092caf4107704",
"migrations/20261008000001_dashboard_origins.sql": "6e7e89adf6e51633da0d73b052b12eec08ae3e7dd21ca315a4ac2fecfa703501",
"migrations/20261009000000_user_profile_status.sql": "aed4c0a316a5fb67b1e60c82d45c6b3ec34a2fbb44721ef772f6b5d3df546659",
"migrations/20261030000000_alert_last_evaluated_at.sql": "577ef95a1964aebf72d8ecb9610c310910121f7bb735dbb287966525b2fb537a",
Expand Down
21 changes: 0 additions & 21 deletions internal/mcp/pitotql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,24 +285,3 @@ func TestQueryTelemetryKeepsInvalidPanelProblems(t *testing.T) {

}
}

func TestRetiredQueryReferenceIsUnavailable(t *testing.T) {
const previousURI = "pitot://fanql/reference"
client := connectTestClient(t, newPanelServer(t), nil)
listed, err := client.ListResources(t.Context(), nil)
if err != nil {
t.Fatal(err)
}
for _, resource := range listed.Resources {
if resource.URI == previousURI {
t.Fatal("read alias advertised")
}
}
if _, err := client.ReadResource(t.Context(), &mcp.ReadResourceParams{URI: previousURI}); err == nil {
t.Fatal("retired resource resolved")
}
result, err := client.ReadResource(t.Context(), &mcp.ReadResourceParams{URI: pitotqlReferenceURI})
if err != nil || len(result.Contents) != 1 || result.Contents[0].Text != pitotql.Reference() {
t.Fatalf("current resource = %+v, %v", result, err)
}
}
11 changes: 7 additions & 4 deletions internal/pitotql/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,15 @@ func (c *Completer) schema(ctx context.Context, key completionKey) (*query.Schem
if c.source == nil {
return nil, false, false
}
req := query.SchemaRequest{Window: key.window, Namespace: key.namespace, Cached: true}
if schema, err := c.source.Schema(ctx, req); err == nil && schema != nil {
return schema, true, false
}
c.mu.Lock()
defer c.mu.Unlock()
// Read the cache while holding the same lock that retires an in-flight
// fetch, so a stale miss cannot admit a duplicate after that fetch finishes.
schema, err := c.source.Schema(ctx, query.SchemaRequest{Window: key.window, Namespace: key.namespace, Cached: true})
if err == nil && schema != nil {
// Recheck after locking: a fetch may have populated the cache and retired
// its in-flight entry since the first lookup missed.
if schema, err := c.source.Schema(ctx, req); err == nil && schema != nil {
delete(c.failed, key)
return schema, true, false
}
Expand Down
90 changes: 90 additions & 0 deletions internal/pitotql/complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,93 @@ func TestCompleteMarksIndexedKeys(t *testing.T) {
}
t.Fatalf("labels %v", completionLabels(r))
}

func TestCompleteCacheHitDoesNotWaitForAdmissionLock(t *testing.T) {
c := warmCompleter(t)
done := make(chan CompleteResponse, 1)
c.mu.Lock()
go func() { done <- c.Complete(context.Background(), completionRequest("spans ")) }()
select {
case response := <-done:
c.mu.Unlock()
if !response.Schema.Warm {
t.Fatal("cached schema was not returned")
}
case <-time.After(time.Second):
c.mu.Unlock()
<-done
t.Fatal("cache hit waited for the admission lock")
}
}

// A cache miss may race with a fetch publishing its result and retiring its
// in-flight entry. Admission must recheck that miss before starting more work.
type delayedCacheMiss struct {
*fakeSchemas
delay atomic.Bool
missed chan struct{}
resume chan struct{}
}

func (s *delayedCacheMiss) Schema(ctx context.Context, req query.SchemaRequest) (*query.Schema, error) {
schema, err := s.fakeSchemas.Schema(ctx, req)
if req.Cached && schema == nil && s.delay.CompareAndSwap(true, false) {
close(s.missed)
<-s.resume
}
return schema, err
}

func TestCompleteStaleMissDoesNotDuplicateFetch(t *testing.T) {
var calls atomic.Int32
fetchGate := make(chan struct{})
source := &delayedCacheMiss{
fakeSchemas: completionSchemaFunc(func(context.Context, query.SchemaRequest) (*query.Schema, error) {
calls.Add(1)
<-fetchGate
return completionFixtureSchema(), nil
}),
missed: make(chan struct{}), resume: make(chan struct{}),
}
c := NewCompleter(source)
key := completionKey{window: "1h"}
var fetched chan struct{}
deadline := time.Now().Add(3 * time.Second)
for fetched == nil && time.Now().Before(deadline) {
c.schema(context.Background(), key)
c.mu.Lock()
fetched = c.inflight[key]
c.mu.Unlock()
if fetched == nil {
time.Sleep(time.Millisecond)
}
}
if fetched == nil {
close(fetchGate)
t.Fatal("schema fetch was not admitted")
}
source.delay.Store(true)
done := make(chan struct{})
go func() { c.schema(context.Background(), key); close(done) }()
<-source.missed
close(fetchGate)
select {
case <-fetched:
case <-time.After(time.Second):
close(source.resume)
<-done
<-fetched
t.Fatal("cache lookup blocked fetch retirement")
}
close(source.resume)
<-done
c.mu.Lock()
pending := c.inflight[key]
c.mu.Unlock()
if pending != nil {
<-pending
}
if calls.Load() != 1 {
t.Fatalf("stale cache miss admitted %d fetches, want 1", calls.Load())
}
}
Loading
Loading