queue-runner: resolve CA derivations after dependency outputs land#1629
Conversation
There was a problem hiding this comment.
At the point where we try_resolve before, we do this:
-
If result is
Noneor "same derivation":just continue with this step, same as we always did
-
If result is
Some(drv)and thatdrvis not the same as the current drv:Step finished, status "resolved", fill in the DB pointer to the new step, and the new step now builds, this step is done.
the current "try resolve reverse dependencies" is a possible optimisation --- incrementally resolve reverse dependencies, reminiscent of union find --- but that's a more complex thing we shouldn't worry about at this time.
ae692ac to
05eef39
Compare
05eef39 to
de9aed8
Compare
0768499 to
80430bf
Compare
|
I think I have this working, but there are a few things I'm unclear on and would like to figure out:
I also believe my change needs substantial refactoring, as I'm using only parts of several functions (e.g. |
3c7b586 to
7eb2319
Compare
|
Rebased onto #1642 |
7eb2319 to
62abe6f
Compare
| } else { | ||
| None | ||
| } | ||
| }; | ||
|
|
||
| if let Some(resolved_path) = resolved { |
There was a problem hiding this comment.
I think we can combine this with the previous branch? Or at least we could compute a "do we want to resolve" bool, and then have the actual resolving (which much succeed) and this stuff in the same branch.
There was a problem hiding this comment.
This is doable, though it will take out a lock on the step's derivation for longer than strictly necessary.
4be2bbb to
0344518
Compare
|
Unfortunately, once #1667 is merged in, this PR will hang. |
1f18bcf to
f040eaa
Compare
90af869 to
3e6dae1
Compare
3e6dae1 to
9c67fd6
Compare
df3f3e9 to
7c69e41
Compare
Instead of resolving at `StepInfo` construction and carrying two drv identities through the gRPC layer, resolve in `realise_drv_on_valid_machine` once all deps are built. If resolution yields a different drv, the original step is marked `Resolved` and a new `Step` is created and punted back to the scheduler. This grants more flexibility and can be extended to dynamic derivations, which won't map 1:1 with the original derivations. The unresolved-to-resolved drv path mapping is kept in an in-memory `HashMap` on `State`, and `try_resolve` translates dependency drv paths through this map before querying the database for outputs. This avoids a schema migration for now, at the cost of losing the mapping on restart. CA derivations that cannot be fully resolved are treated as build failures, avoiding builder-dependent inconsistencies. All dependency outputs of a `CAFloating` derivation must be recorded in the hydra database for resolution to work. Outputs built or substituted by hydra are, but outputs only on the local nix store (e.g. part of the system configuration) are not. Record these upon creating a step, making it possible to build derivations from `contentAddressedByDefault` nixpkgs. Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems> Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems> Co-Authored-By: Amaan Qureshi <git@amaanq.com>
7c69e41 to
3cbcdbe
Compare
Ericson2314
left a comment
There was a problem hiding this comment.
I realized we can temporarily do this without a DB changes, allowing it to go in right away.
(Without a DB migration, and without hydra.nixos.org enabling CA derivations, it is functionally a no-op there.)
Instead of resolving at dispatch time and carrying two drv identities through the gRPC layer, resolve in
succeed_steponce outputs are in the DB. The resolved drv becomes a freshStepthat dispatch picks up normally; the builder only ever sees one drv. A newresolvedFromBuild/resolvedFromStepforeign keyBuildStepsties the resolved step back to the dependency that triggered it.