Skip to content

Add gateway --bootstrap-config CLI#7380

Closed
AntoineToussaint wants to merge 1 commit into
mainfrom
db-config-bootstrap-cli
Closed

Add gateway --bootstrap-config CLI#7380
AntoineToussaint wants to merge 1 commit into
mainfrom
db-config-bootstrap-cli

Conversation

@AntoineToussaint
Copy link
Copy Markdown
Member

Summary

Adds gateway --bootstrap-config <CONFIG_GLOB>, a one-shot operator command that loads a TOML config, verifies every stored-config table is empty, writes the config to Postgres, and exits. This is the operator-facing mechanism for the "deploy gateway + Postgres, point at a config file once, forget the file" story in the Configuration-in-Database design doc.

Semantics vs. the existing --migrate-config:

  • --migrate-config is the file-authoritative sync path. It appends on top of whatever is already in the DB and is safe to run repeatedly; the file remains source of truth.
  • --bootstrap-config is the "initialize the DB from this file" command. Refuses to run if any stored-config table has rows (override with --force) so an accidental re-run can't silently clobber a live deployment.

Neither command starts the inference server — both exit after writing.

Shared plumbing:

  • Extracts the parse + filesystem-access check + validation pipeline into load_config_for_storage, used by both commands.
  • Parameterizes store_config_in_database on creation_source + command label.
  • Adds find_nonempty_stored_config_table in stored_config_queries — walks every stored-config table and returns the first one that holds rows (or None if all empty). Soft-deleted rows count as present — bootstrap is for fresh schemas, not formerly-populated ones.

Test plan

  • `cargo nextest run --package gateway --bin gateway cli::tests::` — 8 CLI parse tests (5 new)
  • `cargo nextest run -E 'test(find_nonempty_stored_config_table)'` — 2 e2e Postgres tests
  • `cargo clippy --package gateway --package tensorzero-core --tests --all-features -- -D warnings`
  • `cargo fmt`
  • Manual smoke: bootstrap an empty Postgres, verify gateway boots against it in DB-authoritative mode

Follow-ups (not this PR)

This is PR 1 of the spec posted on #7363. Subsequent PRs (2–5) cover the e2e test-harness parameterization, REST-bootstrap CI flavors, and the narrow mutation APIs for Autopilot.

🤖 Generated with Claude Code

Introduces a one-shot command that loads a TOML config glob, verifies
every stored-config table is empty, writes the config to Postgres, and
exits. This is the operator-facing mechanism for the "deploy gateway +
Postgres, point at a config file once, then forget the file" story in
the Configuration-in-Database design doc.

Semantics vs. the existing `--migrate-config`:
- `--migrate-config` is the file-authoritative sync path. It appends on
  top of whatever is already in the DB and is safe to run repeatedly;
  the file remains source of truth.
- `--bootstrap-config` is the "initialize the DB from this file"
  command. It refuses to run if any stored-config table already has
  rows (unless `--force` is passed), so an accidental re-run doesn't
  silently clobber a live deployment.

Neither command starts the inference server — both exit after writing.

Shared plumbing:
- Extracts the parse + filesystem-access check + validation pipeline
  into `load_config_for_storage`, used by both commands.
- Parameterizes `store_config_in_database` on `creation_source` + human
  command label.
- Adds `find_nonempty_stored_config_table` in `stored_config_queries`,
  which walks every stored-config table and returns the first one that
  holds rows (or `None` if all are empty). Soft-deleted rows count as
  present — bootstrap is for fresh schemas, not formerly-populated
  ones.

Tests:
- 5 new CLI parse tests covering arg, conflicts with `--config-file` /
  `--migrate-config`, `--force` gating behavior.
- 2 new e2e Postgres tests for `find_nonempty_stored_config_table`:
  empty DB → `None`; metric-only DB → `Some("tensorzero.metrics_configs")`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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