Skip to content

Commit

Permalink
Tell in detail why remote building fails on -v. See #1572
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nh2 committed Aug 18, 2020
1 parent 574bf60 commit 7468a80
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
30 changes: 19 additions & 11 deletions src/build-remote/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<unknown>";

auto requiredFeatures = readStrings<std::set<std::string>>(source);

auto canBuildLocally = amWilling
Expand All @@ -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(format("declined remote machine '%1%' because it is disabled") % m.storeUri);
} else if (std::find(m.systemTypes.begin(), m.systemTypes.end(), neededSystem)
== m.systemTypes.end()) {
printInfo(format("declined remote machine '%1%' for building '%2%' because it does not have the needed system type: '%3%") % m.storeUri % drvstr % neededSystem);
} else if (!m.allSupported(requiredFeatures)) {
std::string joinedFeatures = concatStringsSep(" ", requiredFeatures);
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);
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;
Expand Down Expand Up @@ -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 = "<unknown>";

auto hint = hintformat(hintstring);
hint
% drvstr
Expand Down
11 changes: 8 additions & 3 deletions src/libstore/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 configred"
"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());
Expand Down

0 comments on commit 7468a80

Please sign in to comment.