hydra-evaluator: Rewrite in Rust - #1608
Open
Ericson2314 wants to merge 1 commit into
Open
Conversation
Ericson2314
force-pushed
the
no-c-plus-plus
branch
5 times, most recently
from
March 29, 2026 16:34
bfdc713 to
56503bd
Compare
Ericson2314
force-pushed
the
no-c-plus-plus
branch
from
March 30, 2026 18:27
56503bd to
2b586c6
Compare
Ericson2314
force-pushed
the
no-c-plus-plus
branch
from
April 8, 2026 16:43
2b586c6 to
a117db6
Compare
Eveeifyeve
approved these changes
Apr 20, 2026
Ericson2314
force-pushed
the
no-c-plus-plus
branch
7 times, most recently
from
May 6, 2026 17:49
2a1c3e0 to
dc93afe
Compare
Lyndeno
reviewed
Jun 11, 2026
Ericson2314
force-pushed
the
no-c-plus-plus
branch
2 times, most recently
from
August 4, 2026 15:58
113b25e to
516add8
Compare
Mic92
reviewed
Aug 4, 2026
| #![forbid(unsafe_code)] | ||
| #![deny( | ||
| clippy::all, | ||
| clippy::pedantic, |
Member
Author
There was a problem hiding this comment.
@Conni2461 Have an opinion? The LLM was imitating what you had done in the other crates :) (if I am interpreting the 7d9f536 squash correctly)
Ericson2314
force-pushed
the
no-c-plus-plus
branch
3 times, most recently
from
August 5, 2026 22:01
502f3bb to
bc2d021
Compare
Port hydra-evaluator from C++ to Rust, removing the last C++ executable from the project. The new implementation uses `sqlx` and `tokio`, matching the async patterns already established by hydra-queue-runner and hydra-builder. The scheduling logic is a fairly direct port; what gets explicit treatment is the error-recovery story, which did not survive translation on its own. The C++ evaluator leaned on pqxx throwing on a broken connection and the process exiting into systemd's `Restart=always`, which resynced all state; `sqlx`'s conveniences paper over connection loss instead. So the `db` crate's listener now disables `sqlx`'s eager reconnect so that connection loss surfaces as a stream error (see the comment there — silently dropped NOTIFYs would otherwise strand user-triggered evaluations), and both the main loop and the DB monitor exit for a supervisor restart on a broken connection. Other behaviors deliberately carried over from the C++: forgetting a disabled or deleted jobset kills its in-flight `hydra-eval-jobset` (the C++ `Pid` destructor did this), a failed spawn runs the same cleanup as a failed eval so `startTime` cannot stick forever, and the reaper holds the scheduler lock across its cleanup transaction so a freshly restarted eval cannot have its `startTime` clobbered. The SQL lives in `src/queries.rs` as compile-time-checked `sqlx::query!` macros on an extension trait over `db::Connection` — kept in this crate rather than the shared `db` crate because this slice of the schema only matters to the evaluator. The `db` crate contributes pooled acquisition (`Database::from_env`, reading `HYDRA_DATABASE_URL` via shared constants the queue runner now also uses) and a `raw()` escape hatch for exactly this pattern. Timestamps are `i32` to match the schema's `INT4` (see the comment on `JobsetSchedulingInfo`). Regenerating the `.sqlx` cache also uncovered a latent bug in the db crate: `get_drv_path_from_build_step` treated `drvPath` as nullable, but the schema declares it `not null`. Build/packaging: the C++ build is removed from `subprojects/hydra/meson.build`; the new `subprojects/hydra-evaluator/package.nix` follows the same per-binary pattern as `hydra-queue-runner` and `hydra-builder` (properly sharing the dep crates between these builds is left for later); the NixOS web-app module gains an `evaluatorExecutable` option matching how the queue runner and builder are discovered via their own modules; and stale references in `hydra-tests/meson.build` and `dev-shell.nix` are cleaned up. Co-authored-by: Jörg Thalheim <joerg@thalheim.io> Co-authored-by: Claude <noreply@anthropic.com>
Ericson2314
force-pushed
the
no-c-plus-plus
branch
from
August 6, 2026 00:19
bc2d021 to
9cd4ac8
Compare
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.
Port hydra-evaluator from C++ to Rust, removing the last C++ executable from the project. The new implementation uses sqlx and tokio, matching the async patterns already established by hydra-queue-runner and hydra-builder.
Build/packaging changes:
subprojects/hydra/meson.buildhydra-queue-runner/package.nixtosubprojects/rust-package.nixwith named outputs (queue_runner,builder,evaluator)evaluatorExecutableoption to the NixOS web-app module, matching how the queue runner and builder are discovered via their own moduleshydra-tests/meson.buildanddev-shell.nix