hydra-queue-runner: better error message if nix-store can not be started

The hydra-queue-runner opens a connection to the builder. If the
builder is 'localhost' it starts `nix-store`, otherwise it starts
'ssh'.

Currently, if the hydra-queue-runner can not start `nix-store` (not in
the PATH for instance), the error message is:

  cannot connect to ‘localhost’: error: cannot start ssh: No such file
  or directory

This is not useful since ssh is actually not started:/

With this patch the error message is now:

  cannot connect to ‘localhost’: error: cannot start nix-store: No such file
  or directory
This commit is contained in:
Antoine Eiche 2019-01-22 17:27:36 +01:00
parent e0d8dcfe2d
commit 9a73ec6455

View file

@ -29,6 +29,7 @@ static void append(Strings & dst, const Strings & src)
static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Child & child)
{
string pgmName;
Pipe to, from;
to.create();
from.create();
@ -47,9 +48,12 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil
throw SysError("cannot dup stderr");
Strings argv;
if (machine->sshName == "localhost")
if (machine->sshName == "localhost") {
pgmName = "nix-store";
argv = {"nix-store", "--serve", "--write"};
}
else {
pgmName = "ssh";
argv = {"ssh", machine->sshName};
if (machine->sshKey != "") append(argv, {"-i", machine->sshKey});
if (machine->sshPublicHostKey != "") {
@ -66,7 +70,7 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil
execvp(argv.front().c_str(), (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast
throw SysError("cannot start ssh");
throw SysError("cannot start %s", pgmName);
});
to.readSide = -1;