From f57d0b0c54684231e7a49f14a334db7d94287159 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 18 Jun 2015 00:24:56 +0200 Subject: [PATCH] hydra-queue-runner: Maintain count of active build steps --- src/hydra-queue-runner/build-remote.cc | 2 ++ src/hydra-queue-runner/hydra-queue-runner.cc | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index f0adccf5..39529e1a 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -39,6 +39,8 @@ static void openConnection(const string & sshName, const string & sshKey, if (dup2(stderrFD, STDERR_FILENO) == -1) throw SysError("cannot dup stderr"); + // FIXME: ensure no password prompt. + // FIXME: connection timeouts Strings argv({"ssh", sshName, "-i", sshKey, "-x", "-a", "--", "nix-store", "--serve", "--write"}); execvp("ssh", (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index aae081b4..417c5202 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -39,6 +39,13 @@ bool has(const C & c, const V & v) typedef std::atomic counter; +struct MaintainCount +{ + counter & c; + MaintainCount(counter & c) : c(c) { c++; } + ~MaintainCount() { c--; } +}; + typedef enum { bsSuccess = 0, @@ -229,6 +236,7 @@ private: counter nrBuildsRead{0}; counter nrBuildsDone{0}; counter nrStepsDone{0}; + counter nrActiveSteps{0}; counter nrRetries{0}; counter maxNrRetries{0}; counter nrQueueWakeups{0}; @@ -957,6 +965,8 @@ void State::builder(Step::ptr step, MachineReservation::ptr reservation) { bool retry = true; + MaintainCount mc(nrActiveSteps); + try { auto store = openStore(); // FIXME: pool retry = doBuildStep(store, step, reservation->machine); @@ -1252,6 +1262,7 @@ void State::dumpStatus() if (i->lock()) ++i; else i = runnable_->erase(i); printMsg(lvlError, format("%1% runnable build steps") % runnable_->size()); } + printMsg(lvlError, format("%1% active build steps") % nrActiveSteps); printMsg(lvlError, format("%1% builds read from queue") % nrBuildsRead); printMsg(lvlError, format("%1% builds done") % nrBuildsDone); printMsg(lvlError, format("%1% build steps done") % nrStepsDone);