diff --git a/src/hydra-queue-runner/dispatcher.cc b/src/hydra-queue-runner/dispatcher.cc index b5f65a78..2b03cc88 100644 --- a/src/hydra-queue-runner/dispatcher.cc +++ b/src/hydra-queue-runner/dispatcher.cc @@ -89,6 +89,7 @@ system_time State::doDispatch() auto machines_(machines.lock()); for (auto & m : *machines_) { auto info(m.second->state->connectInfo.lock()); + if (!m.second->enabled) continue; if (info->consecutiveFailures && info->disabledUntil > now) { if (info->disabledUntil < sleepUntil) sleepUntil = info->disabledUntil; diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 553c80de..66bdb855 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -74,8 +74,14 @@ void State::parseMachines(const std::string & contents) } for (auto & m : oldMachines) - if (newMachines.find(m.first) == newMachines.end()) + if (newMachines.find(m.first) == newMachines.end()) { printMsg(lvlInfo, format("removing machine ‘%1%’") % m.first); + /* Add a disabled Machine object to make sure stats are + maintained. */ + auto machine = std::make_shared(*(m.second)); + machine->enabled = false; + newMachines[m.first] = machine; + } auto machines_(machines.lock()); *machines_ = newMachines; @@ -489,6 +495,7 @@ void State::dumpStatus(Connection & conn, bool log) auto & s(m->state); nested.attr(m->sshName); JSONObject nested2(out); + nested2.attr("enabled", m->enabled); nested2.attr("currentJobs", s->currentJobs); if (s->currentJobs == 0) nested2.attr("idleSince", s->idleSince); diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index 5e1bcd0b..29350bd9 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -201,6 +201,8 @@ struct Machine { typedef std::shared_ptr ptr; + bool enabled{true}; + std::string sshName, sshKey; std::set systemTypes, supportedFeatures, mandatoryFeatures; unsigned int maxJobs = 1;