forked from lix-project/hydra
Keep machine stats even when a machine is removed from the machines file
This is important for the Hydra provisioner, since it needs to be able to see whether a disabled machine still has jobs running on it.
This commit is contained in:
parent
2d116d758a
commit
7e954aff03
|
@ -89,6 +89,7 @@ system_time State::doDispatch()
|
||||||
auto machines_(machines.lock());
|
auto machines_(machines.lock());
|
||||||
for (auto & m : *machines_) {
|
for (auto & m : *machines_) {
|
||||||
auto info(m.second->state->connectInfo.lock());
|
auto info(m.second->state->connectInfo.lock());
|
||||||
|
if (!m.second->enabled) continue;
|
||||||
if (info->consecutiveFailures && info->disabledUntil > now) {
|
if (info->consecutiveFailures && info->disabledUntil > now) {
|
||||||
if (info->disabledUntil < sleepUntil)
|
if (info->disabledUntil < sleepUntil)
|
||||||
sleepUntil = info->disabledUntil;
|
sleepUntil = info->disabledUntil;
|
||||||
|
|
|
@ -74,8 +74,14 @@ void State::parseMachines(const std::string & contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & m : oldMachines)
|
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);
|
printMsg(lvlInfo, format("removing machine ‘%1%’") % m.first);
|
||||||
|
/* Add a disabled Machine object to make sure stats are
|
||||||
|
maintained. */
|
||||||
|
auto machine = std::make_shared<Machine>(*(m.second));
|
||||||
|
machine->enabled = false;
|
||||||
|
newMachines[m.first] = machine;
|
||||||
|
}
|
||||||
|
|
||||||
auto machines_(machines.lock());
|
auto machines_(machines.lock());
|
||||||
*machines_ = newMachines;
|
*machines_ = newMachines;
|
||||||
|
@ -489,6 +495,7 @@ void State::dumpStatus(Connection & conn, bool log)
|
||||||
auto & s(m->state);
|
auto & s(m->state);
|
||||||
nested.attr(m->sshName);
|
nested.attr(m->sshName);
|
||||||
JSONObject nested2(out);
|
JSONObject nested2(out);
|
||||||
|
nested2.attr("enabled", m->enabled);
|
||||||
nested2.attr("currentJobs", s->currentJobs);
|
nested2.attr("currentJobs", s->currentJobs);
|
||||||
if (s->currentJobs == 0)
|
if (s->currentJobs == 0)
|
||||||
nested2.attr("idleSince", s->idleSince);
|
nested2.attr("idleSince", s->idleSince);
|
||||||
|
|
|
@ -201,6 +201,8 @@ struct Machine
|
||||||
{
|
{
|
||||||
typedef std::shared_ptr<Machine> ptr;
|
typedef std::shared_ptr<Machine> ptr;
|
||||||
|
|
||||||
|
bool enabled{true};
|
||||||
|
|
||||||
std::string sshName, sshKey;
|
std::string sshName, sshKey;
|
||||||
std::set<std::string> systemTypes, supportedFeatures, mandatoryFeatures;
|
std::set<std::string> systemTypes, supportedFeatures, mandatoryFeatures;
|
||||||
unsigned int maxJobs = 1;
|
unsigned int maxJobs = 1;
|
||||||
|
|
Loading…
Reference in a new issue