Add command ‘hydra-queue-runner --status’ to show current status
[?]
Jun 22, 2015, 12:06 PM
PLOZBRTR6USSGJX7GR2RZKNPVYG2Q6QM7LW6IA35MKL63ZTQVD7QCDependencies
- [2]
JFD25IUUhydra-queue-runner: Implement --unlock - [3]
NNOCZ4ROhydra-queue-runner: Improve dispatcher - [4]
GS4BE6TBAsynchronously compress build logs - [5]
7LB6QBXYKeep track of the number of build steps that are being built - [6]
PQFOMNTLhydra-queue-runner: More stats - [7]
RQUAATWBAdd status dump facility - [8]
NJJ7H64SVery basic multi-threaded queue runner - [9]
WKJFPR77hydra-queue-runner: Maintain count of active build steps - [10]
XV4AEKJChydra-queue-runner: Handle status queries on the main thread - [11]
T2EIYJNGOn SIGINT, shut down the builder threads - [12]
IWB3F4Z6Fail builds with previously failed steps early - [13]
FQQRJUO4Mark builds as busy - [14]
24BMQDZAStart of single-process hydra-queue-runner - [15]
YZAI5GQUImplement a database connection pool - [16]
62MQPRXCPass null values to libpqxx properly - [17]
5AIYUMTBBasic remote building - [18]
GKZN4UV7Make the queue monitor more robust, and better debug output - [19]
OCZ4LSGGAutomatically retry aborted builds - [*]
N22GPKYT* Put info about logs / build products in the DB. - [*]
RYTQLATYKeep track of failed paths in the Hydra database - [*]
KSBB33REAdd a dashboard - [*]
D5QIOJGP* Move everything up one directory.
Change contents
- edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 28
#include "value-to-json.hh" - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 259
~State(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 260
void clearBusy(time_t stopTime);private: - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 262
private:void clearBusy(Connection & conn, time_t stopTime); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 309
void dumpStatus(Connection & conn); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 313
void showStatus(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 316
void dumpStatus();void unlock(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 331[6.7507]→[6.7507:7535](∅→∅),[6.7535]→[6.167:237](∅→∅),[6.237]→[6.109:137](∅→∅),[6.109]→[6.109:137](∅→∅),[6.137]→[6.7676:7731](∅→∅),[6.330]→[6.7676:7731](∅→∅),[6.7676]→[6.7676:7731](∅→∅),[6.7731]→[6.7893:7895](∅→∅)
State::~State(){try {printMsg(lvlInfo, "clearing active builds / build steps...");clearBusy(time(0));} catch (...) {ignoreException();}} - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 376
void State::clearBusy(time_t stopTime)void State::clearBusy(Connection & conn, time_t stopTime) - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 378
auto conn(dbPool.get());pqxx::work txn(*conn);pqxx::work txn(conn); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1399
void State::dumpStatus()void State::dumpStatus(Connection & conn) - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1401
std::ostringstream out; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1404
auto builds_(builds.lock());printMsg(lvlError, format("%1% queued builds") % builds_->size());JSONObject root(out);root.attr("status", "up");root.attr("time", time(0));root.attr("pid", getpid());{auto builds_(builds.lock());root.attr("nrQueuedBuilds", builds_->size());}{auto steps_(steps.lock());for (auto i = steps_->begin(); i != steps_->end(); )if (i->second.lock()) ++i; else i = steps_->erase(i);root.attr("nrUnfinishedSteps", steps_->size());}{auto runnable_(runnable.lock());for (auto i = runnable_->begin(); i != runnable_->end(); )if (i->lock()) ++i; else i = runnable_->erase(i);root.attr("nrRunnableSteps", runnable_->size());}root.attr("nrActiveSteps", nrActiveSteps);root.attr("nrStepsBuilding", nrStepsBuilding);root.attr("nrBuildsRead", nrBuildsRead);root.attr("nrBuildsDone", nrBuildsDone);root.attr("nrStepsDone", nrStepsDone);root.attr("nrRetries", nrRetries);root.attr("maxNrRetries", maxNrRetries);root.attr("nrQueueWakeups", nrQueueWakeups);root.attr("nrDispatcherWakeups", nrDispatcherWakeups);root.attr("nrDbConnections", dbPool.count());{root.attr("machines");JSONObject nested(out);auto machines_(machines.lock());for (auto & m : *machines_) {nested.attr(m->sshName);JSONObject nested2(out);nested2.attr("currentJobs", m->currentJobs);nested2.attr("maxJobs", m->maxJobs);}} - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1446
- replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1448
auto steps_(steps.lock());for (auto i = steps_->begin(); i != steps_->end(); )if (i->second.lock()) ++i; else i = steps_->erase(i);printMsg(lvlError, format("%1% pending/active build steps") % steps_->size());pqxx::work txn(conn);// FIXME: use PostgreSQL 9.5 upsert.txn.exec("delete from SystemStatus where what = 'queue-runner'");txn.parameterized("insert into SystemStatus values ('queue-runner', $1)")(out.str()).exec();txn.exec("notify status_dumped");txn.commit(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1455
}void State::showStatus(){auto conn(dbPool.get());receiver statusDumped(*conn, "status_dumped");string status;bool barf = false;/* Get the last JSON status dump from the database. */ - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1468
auto runnable_(runnable.lock());for (auto i = runnable_->begin(); i != runnable_->end(); )if (i->lock()) ++i; else i = runnable_->erase(i);printMsg(lvlError, format("%1% runnable build steps") % runnable_->size());pqxx::work txn(*conn);auto res = txn.exec("select status from SystemStatus where what = 'queue-runner'");if (res.size()) status = res[0][0].as<string>();}if (status != "") {/* If the status is not empty, then the queue runner isrunning. Ask it to update the status dump. */{pqxx::work txn(*conn);txn.exec("notify dump_status");txn.commit();}/* Wait until it has done so. */barf = conn->await_notification(5, 0) == 0;/* Get the new status. */{pqxx::work txn(*conn);auto res = txn.exec("select status from SystemStatus where what = 'queue-runner'");if (res.size()) status = res[0][0].as<string>();} - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1494[6.934]→[6.277:351](∅→∅),[6.351]→[5.618:706](∅→∅),[6.351]→[6.431:644](∅→∅),[5.706]→[6.431:644](∅→∅),[6.934]→[6.431:644](∅→∅),[6.644]→[6.6398:6781](∅→∅),[6.934]→[6.6398:6781](∅→∅)
printMsg(lvlError, format("%1% active build steps") % nrActiveSteps);printMsg(lvlError, format("%1% build steps currently building") % nrStepsBuilding);printMsg(lvlError, format("%1% builds read from queue") % nrBuildsRead);printMsg(lvlError, format("%1% builds done") % nrBuildsDone);printMsg(lvlError, format("%1% build steps done") % nrStepsDone);printMsg(lvlError, format("%1% build step retries") % nrRetries);printMsg(lvlError, format("%1% most retries for any build step") % maxNrRetries);printMsg(lvlError, format("%1% queue wakeups") % nrQueueWakeups);printMsg(lvlError, format("%1% dispatcher wakeups") % nrDispatcherWakeups);printMsg(lvlError, format("%1% database connections") % dbPool.count());if (status == "") status = R"({"status":"down"})";std::cout << status << "\n";if (barf)throw Error("queue runner did not respond; status information may be wrong");}void State::unlock(){auto conn(dbPool.get());clearBusy(*conn, 0); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1511[6.1030]→[6.1030:1109](∅→∅),[6.1163]→[6.1163:1232](∅→∅),[6.1232]→[3.3663:3724](∅→∅),[3.3724]→[6.1292:1302](∅→∅),[6.1292]→[6.1292:1302](∅→∅)
auto machines_(machines.lock());for (auto & m : *machines_) {printMsg(lvlError, format("machine %1%: %2%/%3% active")% m->sshName % m->currentJobs % m->maxJobs);}pqxx::work txn(*conn);txn.exec("delete from SystemStatus where what = 'queue-runner'");txn.commit(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1520
clearBusy(0);{auto conn(dbPool.get());clearBusy(*conn, 0);dumpStatus(*conn);} - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1543
State::dumpStatus();State::dumpStatus(*conn); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1566
bool status = false; - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1571
else if (*arg == "--status")status = true; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1585
if (unlock)state.clearBusy(0);if (status)state.showStatus();else if (unlock)state.unlock(); - edit in src/sql/hydra.sql at line 532
create table SystemStatus (what text primary key not null,status json not null); - file addition: upgrade-34.sql[24.3004]
create table SystemStatus (what text primary key not null,status json not null);