Replace HYDRA_DBI with HYDRA_DATABASE_URL everywhere - #1851
Merged
Conversation
Hydra grew a second database-connection convention when the Rust queue runner arrived: it takes a standard `postgres://` URL (`db_url` / `HYDRA_DATABASE_URL`), while the Perl and C++ services read `HYDRA_DBI`, a Perl DBI string. Converge on the URL as the single convention before more Rust services appear, rather than teaching each of them the legacy DBI syntax. The two formats are equally expressive — the PostgreSQL URI scheme accepts every libpq keyword as a query parameter — so nothing is lost, and each consumer needs only a small change: - Perl: `Hydra::Model::DB` converts the URL to a DBI DSN with `URI::db` (new dependency). See the comment there for the user/password caveat. - C++ (`hydra-evaluator`): libpq accepts a `postgres://` URL verbatim, so the DBI-to-conninfo translation code is deleted outright. - NixOS module: the `dbi` option is replaced by `dbUrl`, and all services now get `HYDRA_DATABASE_URL` with a per-service `application_name` query parameter. Neither hydra.nixos.org nor staging ever set `dbi`, so the option's removal breaks no known deployment. - The foreman dev scripts, test harness, and manual switch accordingly. The test harness already exported both variables; the `HYDRA_DBI` half is now dropped. The Perl and C++ in-code default becomes `postgres:///hydra`, which is byte-for-byte equivalent to the old `dbi:Pg:dbname=hydra;` (local socket, OS-user auth). The NixOS module default matches the queue runner's explicit `postgres://hydra@%2Frun%2Fpostgresql:5432/hydra`.
Mic92
approved these changes
Aug 4, 2026
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.
Hydra grew a second database-connection convention when the Rust queue runner arrived: it takes a standard
postgres://URL (db_url/HYDRA_DATABASE_URL), while the Perl and C++ services readHYDRA_DBI, a Perl DBI string. Converge on the URL as the single convention before more Rust services appear, rather than teaching each of them the legacy DBI syntax.The two formats are equally expressive — the PostgreSQL URI scheme accepts every libpq keyword as a query parameter — so nothing is lost, and each consumer needs only a small change:
Perl:
Hydra::Model::DBconverts the URL to a DBI DSN withURI::db(new dependency). See the comment there for the user/password caveat.C++ (
hydra-evaluator): libpq accepts apostgres://URL verbatim, so the DBI-to-conninfo translation code is deleted outright.NixOS module: the
dbioption is replaced bydbUrl, and all services now getHYDRA_DATABASE_URLwith a per-serviceapplication_namequery parameter. Neither hydra.nixos.org nor staging ever setdbi, so the option's removal breaks no known deployment.The foreman dev scripts, test harness, and manual switch accordingly. The test harness already exported both variables; the
HYDRA_DBIhalf is now dropped.The Perl and C++ in-code default becomes
postgres:///hydra, which is byte-for-byte equivalent to the olddbi:Pg:dbname=hydra;(local socket, OS-user auth). The NixOS module default matches the queue runner's explicitpostgres://hydra@%2Frun%2Fpostgresql:5432/hydra.