|
|
|
@ -496,12 +496,36 @@ void Laminar::assignNewJobs() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setup run completion handler
|
|
|
|
|
run->notifyCompletion = [=,&node](const Run* r) {
|
|
|
|
|
node.busyExecutors--;
|
|
|
|
|
run->notifyCompletion = [this](const Run* r) { runFinished(r); };
|
|
|
|
|
|
|
|
|
|
// trigger the first step of the run
|
|
|
|
|
if(stepRun(run)) {
|
|
|
|
|
// should never happen
|
|
|
|
|
KJ_LOG(INFO, "No steps for run");
|
|
|
|
|
run->complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assigned = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(assigned) {
|
|
|
|
|
activeJobs.insert(*it);
|
|
|
|
|
it = queuedJobs.erase(it);
|
|
|
|
|
} else
|
|
|
|
|
++it;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Laminar::runFinished(const Run * r) {
|
|
|
|
|
Node* node = r->node;
|
|
|
|
|
|
|
|
|
|
node->busyExecutors--;
|
|
|
|
|
KJ_LOG(INFO, "Run completed", r->name, to_string(r->result));
|
|
|
|
|
time_t completedAt = time(0);
|
|
|
|
|
db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?)")
|
|
|
|
|
.bind(r->name, r->build, node.name, r->queuedAt, r->startedAt, completedAt, int(r->result),
|
|
|
|
|
.bind(r->name, r->build, node->name, r->queuedAt, r->startedAt, completedAt, int(r->result),
|
|
|
|
|
r->log, r->parentName, r->parentBuild, r->reason())
|
|
|
|
|
.exec();
|
|
|
|
|
|
|
|
|
@ -527,28 +551,8 @@ void Laminar::assignNewJobs() {
|
|
|
|
|
waiters.erase(r);
|
|
|
|
|
|
|
|
|
|
// remove the workdir
|
|
|
|
|
fs::remove_all(wd);
|
|
|
|
|
fs::remove_all(r->wd);
|
|
|
|
|
|
|
|
|
|
// will delete the job
|
|
|
|
|
activeJobs.get<2>().erase(r);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// trigger the first step of the run
|
|
|
|
|
if(stepRun(run)) {
|
|
|
|
|
// should never happen
|
|
|
|
|
KJ_LOG(INFO, "No steps for run");
|
|
|
|
|
run->complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assigned = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(assigned) {
|
|
|
|
|
activeJobs.insert(*it);
|
|
|
|
|
it = queuedJobs.erase(it);
|
|
|
|
|
} else
|
|
|
|
|
++it;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|