From 019176137f49eba826e08c6b0f0a5c35ecdde81d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 13 Jan 2009 11:39:09 +0000 Subject: * When using a build hook, distinguish between transient failures (e.g. an SSH connection problem) and permanent failures (i.e. the builder failed). This matters to Hydra (it wants to know whether it makes sense to retry a build). --- src/libstore/build.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/libstore') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index db2bed6d01f8..aea4ccdc437b 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -648,6 +648,9 @@ private: /* Pipe for the builder's standard output/error. */ Pipe logPipe; + /* Whether we're building using a build hook. */ + bool usingBuildHook; + /* Pipes for talking to the build hook (if any). */ Pipe toHook; Pipe fromHook; @@ -970,6 +973,7 @@ void DerivationGoal::tryToBuild() try { /* Is the build hook willing to accept this job? */ + usingBuildHook = true; switch (tryBuildHook()) { case rpAccept: /* Yes, it has started doing so. Wait until we get @@ -1003,6 +1007,7 @@ void DerivationGoal::tryToBuild() /* Acquire locks and such. If we then see that the build has been done by somebody else, we're done. */ + usingBuildHook = false; PrepareBuildReply preply = prepareBuild(); if (preply == prDone) { amDone(ecSuccess); @@ -1019,8 +1024,12 @@ void DerivationGoal::tryToBuild() } catch (BuildError & e) { printMsg(lvlError, e.msg()); if (printBuildTrace) { - printMsg(lvlError, format("@ build-failed %1% %2% %3% %4%") - % drvPath % drv.outputs["out"].path % 0 % e.msg()); + if (usingBuildHook) + printMsg(lvlError, format("@ hook-failed %1% %2% %3% %4%") + % drvPath % drv.outputs["out"].path % 0 % e.msg()); + else + printMsg(lvlError, format("@ build-failed %1% %2% %3% %4%") + % drvPath % drv.outputs["out"].path % 0 % e.msg()); } amDone(ecFailed); return; @@ -1122,8 +1131,15 @@ void DerivationGoal::buildDone() } catch (BuildError & e) { printMsg(lvlError, e.msg()); if (printBuildTrace) { - printMsg(lvlError, format("@ build-failed %1% %2% %3% %4%") - % drvPath % drv.outputs["out"].path % status % e.msg()); + /* When using a build hook, the hook will return a + remote build failure using exit code 100. Anything + else is a hook problem. */ + if (usingBuildHook && (!WIFEXITED(status) || WEXITSTATUS(status) != 100)) + printMsg(lvlError, format("@ hook-failed %1% %2% %3% %4%") + % drvPath % drv.outputs["out"].path % status % e.msg()); + else + printMsg(lvlError, format("@ build-failed %1% %2% %3% %4%") + % drvPath % drv.outputs["out"].path % status % e.msg()); } amDone(ecFailed); return; -- cgit 1.4.1