From 9e162dcf527e18b2c41f93970a40c51fae410277 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 14 Feb 2025 18:00:13 -0500 Subject: [PATCH] Avoid custom logic to copy inputs to the remote builder --- src/hydra-queue-runner/build-remote.cc | 50 ++++---------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index e8cd6d2f..1699b4ca 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -36,42 +36,6 @@ bool ::Machine::isLocalhost() const namespace nix::build_remote { -static void copyClosureTo( - ::Machine::Connection & conn, - Store & destStore, - const StorePathSet & paths, - SubstituteFlag useSubstitutes = NoSubstitute) -{ - StorePathSet closure; - destStore.computeFSClosure(paths, closure); - - /* Send the "query valid paths" command with the "lock" option - enabled. This prevents a race where the remote host - garbage-collect paths that are already there. Optionally, ask - the remote host to substitute missing paths. */ - // FIXME: substitute output pollutes our build log - /* Get back the set of paths that are already valid on the remote - host. */ - auto present = conn.store->queryValidPaths( - closure, true, useSubstitutes); - - if (present.size() == closure.size()) return; - - auto sorted = destStore.topoSortPaths(closure); - - StorePathSet missing; - for (auto i = sorted.rbegin(); i != sorted.rend(); ++i) - if (!present.count(*i)) missing.insert(*i); - - printMsg(lvlDebug, "sending %d missing paths", missing.size()); - - std::unique_lock sendLock(conn.machine->state->sendLock, - std::chrono::seconds(600)); - - conn.store->addMultipleToStoreLegacy(destStore, missing); -} - - // FIXME: use Store::topoSortPaths(). static StorePaths reverseTopoSortPaths(const std::map & paths) { @@ -163,13 +127,13 @@ static BasicDerivation sendInputs( auto now1 = std::chrono::steady_clock::now(); /* Copy the input closure. */ - if (conn.machine->isLocalhost()) { - StorePathSet closure; - destStore.computeFSClosure(basicDrv.inputSrcs, closure); - copyPaths(destStore, localStore, closure, NoRepair, NoCheckSigs, NoSubstitute); - } else { - copyClosureTo(conn, destStore, basicDrv.inputSrcs, Substitute); - } + copyClosure( + destStore, + conn.machine->isLocalhost() ? localStore : *conn.store, + basicDrv.inputSrcs, + NoRepair, + NoCheckSigs, + Substitute); auto now2 = std::chrono::steady_clock::now();