From 6567ab95a0b5cdca3f8b22dbbcd98ec5d18b63b0 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sat, 25 Nov 2017 01:03:23 +0100 Subject: [PATCH] build-remote: Fix missing log output The storeUri variable in the build-remote hook is declared very much to the start of the main function and a bunch of lines later, the same variable gets checked via hasPrefix() but it gets assigned *after* that check when the most suitable machine for the build was choosen. So I guess this was just a typo in d16fd2497374671c92cb877f9570d65783a7 and what we really want is to either checkd the prefix *after* assigning storeUri or use bestMachine->storeUri directly. I choose the latter, because the former could introduce even more regressions if the try block where the variable gets assigned terminates early. Nevertheless, the reason why the log output didn't work is because hasPrefix() checked for "ssh://" in front of storeUri, but if the storeUri isn't set correctly (or at all), we don't get the log file descriptor set up properly, leading to no log output. I've adjusted the remote-builds test to include a regression test for this, so that we can make sure we get a build output when using remote builds. In addition to that I've tested this with two of my build farms and the build logs are emitted correctly again. Signed-off-by: aszlig --- src/build-remote/build-remote.cc | 2 +- tests/remote-builds.nix | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index 6e05e1655..445006b32 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -177,7 +177,7 @@ int main (int argc, char * * argv) Activity act(*logger, lvlTalkative, actUnknown, fmt("connecting to '%s'", bestMachine->storeUri)); Store::Params storeParams; - if (hasPrefix(storeUri, "ssh://")) { + if (hasPrefix(bestMachine->storeUri, "ssh://")) { storeParams["max-connections"] ="1"; storeParams["log-fd"] = "4"; if (bestMachine->sshKey != "") diff --git a/tests/remote-builds.nix b/tests/remote-builds.nix index 39bd090e4..58a26d8b6 100644 --- a/tests/remote-builds.nix +++ b/tests/remote-builds.nix @@ -85,7 +85,10 @@ in } # Perform a build and check that it was performed on the slave. - my $out = $client->succeed("nix-build ${expr nodes.client.config 1}"); + my $out = $client->succeed( + "nix-build ${expr nodes.client.config 1} 2> build-output", + "grep -q Hello build-output" + ); $slave1->succeed("test -e $out"); # And a parallel build.