Asynchronously compress build logs
[?]
Jun 19, 2015, 12:51 PM
GS4BE6TB6GH2JUZJHDPHL6YG7J7YYESF3YOZJZ2CFABXUTO4VYPQCDependencies
- [2]
5LBMP7GAFix remote building - [3]
PQFOMNTLhydra-queue-runner: More stats - [4]
XV4AEKJChydra-queue-runner: Handle status queries on the main thread - [5]
WHULPA6SHandle failure with output - [6]
O776XDS2Make getDrvLogPath work with both bucketed and non-bucketed nix logs. - [7]
NJJ7H64SVery basic multi-threaded queue runner - [8]
T2EIYJNGOn SIGINT, shut down the builder threads - [9]
5AIYUMTBBasic remote building - [10]
ENXUSMSVMake concurrency more robust - [11]
24BMQDZAStart of single-process hydra-queue-runner - [12]
OCZ4LSGGAutomatically retry aborted builds - [13]
NNOCZ4ROhydra-queue-runner: Improve dispatcher - [14]
FQQRJUO4Mark builds as busy - [15]
YZAI5GQUImplement a database connection pool - [16]
HHOMBU7Ghydra-queue-runner: Implement timeouts - [*]
RQUAATWBAdd status dump facility - [*]
RYTQLATYKeep track of failed paths in the Hydra database - [*]
2GK5DOU7* Downloading closures.
Change contents
- replacement in src/hydra-queue-runner/build-remote.cc at line 120
Path logFile = logDir + "/" + string(base, 0, 2) + "/" + string(base, 2);result.logFile = logDir + "/" + string(base, 0, 2) + "/" + string(base, 2);AutoDelete autoDelete(result.logFile, false); - replacement in src/hydra-queue-runner/build-remote.cc at line 123
createDirs(dirOf(logFile));createDirs(dirOf(result.logFile)); - replacement in src/hydra-queue-runner/build-remote.cc at line 125
AutoCloseFD logFD(open(logFile.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0666));if (logFD == -1) throw SysError(format("creating log file ‘%1%’") % logFile);AutoCloseFD logFD(open(result.logFile.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0666));if (logFD == -1) throw SysError(format("creating log file ‘%1%’") % result.logFile); - replacement in src/hydra-queue-runner/build-remote.cc at line 150
throw Error(format("cannot connect to ‘%1%’: %2%") % sshName % chomp(readFile(logFile)));string s = chomp(readFile(result.logFile));throw Error(format("cannot connect to ‘%1%’: %2%") % sshName % s); - edit in src/hydra-queue-runner/build-remote.cc at line 168
autoDelete.cancel(); - edit in src/hydra-queue-runner/build-remote.hh at line 16
nix::Path logFile; - replacement in src/hydra-queue-runner/build-result.cc at line 61
/* Ensure that the path exists and points into theNix store. *//* Ensure that the path exists and points into the Nixstore. */ - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 5
#include <queue> - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 13
#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h> - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 236
std::condition_variable_any runnableWakeup; - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 257
/* Log compressor work queue. */Sync<std::queue<Path>> logCompressorQueue;std::condition_variable_any logCompressorWakeup; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 267
void loadMachines();void clearBusy(time_t stopTime); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 269
void clearBusy(time_t stopTime);private:void loadMachines(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 314
/* Thread that asynchronously bzips logs of finished steps. */void logCompressor();public: - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 968
dispatcherWakeup.notify_all();dispatcherWakeup.notify_one(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1080
/* Do the build. */ - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1094
/* Asynchronously compress the log. */if (result.logFile != "") {{auto logCompressorQueue_(logCompressorQueue.lock());logCompressorQueue_->push(result.logFile);}logCompressorWakeup.notify_one();} - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1346
- edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1348
void State::logCompressor(){while (true) {try { - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1353
Path logPath;{auto logCompressorQueue_(logCompressorQueue.lock());while (logCompressorQueue_->empty())logCompressorQueue_.wait(logCompressorWakeup);logPath = logCompressorQueue_->front();logCompressorQueue_->pop();}if (!pathExists(logPath)) continue;printMsg(lvlChatty, format("compressing log file ‘%1%’") % logPath);Path tmpPath = logPath + ".bz2.tmp";AutoCloseFD fd = open(tmpPath.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0644);// FIXME: use libbz2Pid pid = startProcess([&]() {if (dup2(fd, STDOUT_FILENO) == -1)throw SysError("cannot dup output pipe to stdout");execlp("bzip2", "bzip2", "-c", logPath.c_str(), nullptr);throw SysError("cannot start ssh");});int res = pid.wait(true);if (res != 0)throw Error(format("bzip2 returned exit code %1% while compressing ‘%2%’")% res % logPath);if (rename(tmpPath.c_str(), (logPath + ".bz2").c_str()) != 0)throw SysError(format("renaming ‘%1%’") % tmpPath);if (unlink(logPath.c_str()) != 0)throw SysError(format("unlinking ‘%1%’") % logPath);} catch (std::exception & e) {printMsg(lvlError, format("log compressor: %1%") % e.what());sleep(5);}}} - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1446
/* Run a log compressor thread. If needed, we could start morethan one. */std::thread(&State::logCompressor, this).detach(); - replacement in src/lib/Hydra/Helper/Nix.pm at line 137
for ($fn2 . $bucketed, $fn . $bucketed . ".bz2", $fn . $bucketed, $fn . $base . ".bz2", $fn . $base) {for ($fn2 . $bucketed, $fn2 . $bucketed . ".bz2", $fn . $bucketed . ".bz2", $fn . $bucketed, $fn . $base . ".bz2", $fn . $base) {