From ddd4556574328dc8698126cff49c9a18790594d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Thu, 13 Aug 2020 05:17:57 +0200 Subject: [PATCH] Tell in detail why remote building fails on -v. See #1572 Also further improve the final error message, giving a practical example of how to set machine features because that's what most people need to succeed in building large packages remotely. --- src/build-remote/build-remote.cc | 30 +++++++++++++++++++----------- src/libstore/build.cc | 11 ++++++++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index cec7b369b171..fe33259abdd9 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -101,6 +101,13 @@ static int _main(int argc, char * * argv) auto amWilling = readInt(source); auto neededSystem = readString(source); drvPath = store->parseStorePath(readString(source)); + + string drvstr; + if (drvPath.has_value()) + drvstr = drvPath->to_string(); + else + drvstr = ""; + auto requiredFeatures = readStrings>(source); auto canBuildLocally = amWilling @@ -123,11 +130,18 @@ static int _main(int argc, char * * argv) for (auto & m : machines) { debug("considering building on remote machine '%s'", m.storeUri); - if (m.enabled && std::find(m.systemTypes.begin(), - m.systemTypes.end(), - neededSystem) != m.systemTypes.end() && - m.allSupported(requiredFeatures) && - m.mandatoryMet(requiredFeatures)) { + if (!m.enabled) { + debug("declined remote machine '%s' because it is disabled", storeUri); + } else if (std::find(m.systemTypes.begin(), m.systemTypes.end(), neededSystem) + == m.systemTypes.end()) { + printInfo("declined remote machine '%s' for building '%s' because it does not have the needed system type '%s", m.storeUri, drvstr, neededSystem); + } else if (!m.allSupported(requiredFeatures)) { + std::string joinedFeatures = concatStringsSep(" ", requiredFeatures); // includes leading space + printInfo(format("declined remote machine '%1%' for building '%2%' because it does not have all required features: [ %3% ]") % m.storeUri % drvstr % joinedFeatures); + } else if (!m.mandatoryMet(requiredFeatures)) { + std::string joinedFeatures = concatStringsSep(" ", requiredFeatures); // includes leading space + printInfo(format("declined remote machine '%1%' for building '%2%' because the derivation does not have all mandatory features to build on that machine: [ %3% ]") % m.storeUri % drvstr % joinedFeatures); + } else { rightType = true; AutoCloseFD free; uint64_t load = 0; @@ -181,12 +195,6 @@ static int _main(int argc, char * * argv) } // add the template values. - string drvstr; - if (drvPath.has_value()) - drvstr = drvPath->to_string(); - else - drvstr = ""; - auto hint = hintformat(hintstring); hint % drvstr diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 76baa1a6e181..33b1e1dbed9b 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -4882,9 +4882,14 @@ void Worker::run(const Goals & _topGoals) "or enable remote builds." "\nhttps://nixos.org/nix/manual/#chap-distributed-builds"); else - throw Error("unable to start any build; remote machines may not have " - "all required system features." - "\nhttps://nixos.org/nix/manual/#chap-distributed-builds"); + throw Error("unable to start any build; either increase '--max-jobs' " + "to also allow building locally, or ensure that the configured" + "remote builder machines have all required system features." + "For example, to enable the 'big-parallel' feature, use:" + "\n --builders 'yourbuilderhostname - - - - big-parallel'" + "\nhttps://nixos.org/nix/manual/#chap-distributed-builds" + "\nYou can enable -v verbosity to see why any machine " + "was declined for any given build."); } assert(!awake.empty());