Merge pull request #632 from nlewo/localhost-error-message

hydra-queue-runner: better error message if nix-store can not be started
This commit is contained in:
Eelco Dolstra 2019-01-23 10:46:30 +01:00 committed by GitHub
commit 5dd4736aed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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) static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Child & child)
{ {
string pgmName;
Pipe to, from; Pipe to, from;
to.create(); to.create();
from.create(); from.create();
@ -47,9 +48,12 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil
throw SysError("cannot dup stderr"); throw SysError("cannot dup stderr");
Strings argv; Strings argv;
if (machine->sshName == "localhost") if (machine->sshName == "localhost") {
pgmName = "nix-store";
argv = {"nix-store", "--serve", "--write"}; argv = {"nix-store", "--serve", "--write"};
}
else { else {
pgmName = "ssh";
argv = {"ssh", machine->sshName}; argv = {"ssh", machine->sshName};
if (machine->sshKey != "") append(argv, {"-i", machine->sshKey}); if (machine->sshKey != "") append(argv, {"-i", machine->sshKey});
if (machine->sshPublicHostKey != "") { 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 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; to.readSide = -1;