Support multiple machines files
[?]
Aug 25, 2015, 12:11 PM
O3NM62IZE5EMW4KY56TV53BUZZL2NHAC55W7NBPTD7A4CKT4CHUQCDependencies
- [2]
YVCZP2ZMUse /etc/nix/machines - [3]
OG3Z3QGCNamespace cleanup - [4]
PLOZBRTRAdd command ‘hydra-queue-runner --status’ to show current status - [5]
EYR3EW6JKeep stats for the Hydra auto scaler - [6]
T2EIYJNGOn SIGINT, shut down the builder threads - [7]
ARATXDQ4Remove dead code - [8]
PMNWRTGJAdd multiple output support - [9]
5AIYUMTBBasic remote building - [10]
DBBI2P4NWake the dispatcher when the machines file has changed - [11]
SODOV2CMAutomatically reload $NIX_REMOTE_SYSTEMS when it changes - [12]
FQQRJUO4Mark builds as busy - [13]
FULDVXE2Periodically dump/log status - [14]
CNLNT3T4Allow only 1 thread to send a closure to a given machine at the same time - [15]
TTBLPQAJKeep track of wait time per system type - [16]
24BMQDZAStart of single-process hydra-queue-runner - [17]
HTL6HIBMmachine-status: Read /etc/nix.machines instead of using the BuildMachines table - [18]
YZAI5GQUImplement a database connection pool - [19]
NJJ7H64SVery basic multi-threaded queue runner - [20]
6ZB4CIW6Security: Improve checking of build products - [21]
SK6WHODMSupport preferLocalBuild - [22]
HJOEIMLRRefactor - [*]
2GK5DOU7* Downloading closures.
Change contents
- edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 25
machinesFile = getEnv("NIX_REMOTE_SYSTEMS", "/etc/nix/machines");machinesFileStat.st_ino = 0;machinesFileStat.st_mtime = 0; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 31
void State::loadMachinesFile()void State::parseMachines(const std::string & contents) - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 33[4.7924]→[4.858:879](∅→∅),[4.879]→[4.8027:8063](∅→∅),[4.8027]→[4.8027:8063](∅→∅),[4.8063]→[4.880:1289](∅→∅),[4.1289]→[4.382:454](∅→∅),[4.454]→[4.1509:1579](∅→∅),[4.1509]→[4.1509:1579](∅→∅),[4.1579]→[4.8063:8064](∅→∅),[4.8063]→[4.8063:8064](∅→∅)
string contents;if (pathExists(machinesFile)) {struct stat st;if (stat(machinesFile.c_str(), &st) != 0)throw SysError(format("getting stats about ‘%1%’") % machinesFile);if (st.st_ino == machinesFileStat.st_ino && st.st_mtime == machinesFileStat.st_mtime)return;printMsg(lvlDebug, "reloading machines");contents = readFile(machinesFile);machinesFileStat = st;} else {contents = "localhost " + concatStringsSep(",", localPlatforms)+ " - " + int2String(settings.maxBuildJobs) + " 1";} - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 87
string defaultMachinesFile = "/etc/nix/machines";auto machinesFiles = tokenizeString<std::vector<Path>>(getEnv("NIX_REMOTE_SYSTEMS", pathExists(defaultMachinesFile) ? defaultMachinesFile : ""), ":");if (machinesFiles.empty()) {parseMachines("localhost " + concatStringsSep(",", localPlatforms)+ " - " + int2String(settings.maxBuildJobs) + " 1");return;}std::vector<struct stat> fileStats;fileStats.resize(machinesFiles.size());for (unsigned int n = 0; n < machinesFiles.size(); ++n) {auto & st(fileStats[n]);st.st_ino = st.st_mtime = 0;}auto readMachinesFiles = [&]() {/* Check if any of the machines files changed. */bool anyChanged = false;for (unsigned int n = 0; n < machinesFiles.size(); ++n) {Path machinesFile = machinesFiles[n];struct stat st;if (stat(machinesFile.c_str(), &st) != 0) {if (errno != ENOENT)throw SysError(format("getting stats about ‘%1%’") % machinesFile);st.st_ino = st.st_mtime = 0;}auto & old(fileStats[n]);if (old.st_ino != st.st_ino || old.st_mtime != st.st_mtime)anyChanged = true;old = st;}if (!anyChanged) return;debug("reloading machines files");string contents;for (auto & machinesFile : machinesFiles) {try {contents += readFile(machinesFile);contents += '\n';} catch (SysError & e) {if (e.errNo != ENOENT) throw;}}parseMachines(contents);}; - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 141
readMachinesFiles(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 143
sleep(60);loadMachinesFile();sleep(30); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 622[4.810]→[4.3285:3286](∅→∅),[4.897]→[4.3285:3286](∅→∅),[4.3854]→[4.3285:3286](∅→∅),[4.3285]→[4.3285:3286](∅→∅),[4.3286]→[4.5102:5126](∅→∅)
loadMachinesFile(); - edit in src/hydra-queue-runner/state.hh at line 288[4.5276]→[4.5276:5277](∅→∅),[4.5277]→[3.585:613](∅→∅),[3.613]→[4.5300:5334](∅→∅),[4.5300]→[4.5300:5334](∅→∅)
nix::Path machinesFile;struct stat machinesFileStat; - replacement in src/hydra-queue-runner/state.hh at line 352
/* (Re)load /etc/nix/machines. */void loadMachinesFile();void parseMachines(const std::string & contents); - edit in src/lib/Hydra/Helper/Nix.pm at line 289
my $machinesConf = $ENV{"NIX_REMOTE_SYSTEMS"} || "/etc/nix/machines";# Read the list of machines. - replacement in src/lib/Hydra/Helper/Nix.pm at line 290
if (-e $machinesConf) {open CONF, "<$machinesConf" or die;my @machinesFiles = split /:/, ($ENV{"NIX_REMOTE_SYSTEMS"} || "/etc/nix/machines");for my $machinesFile (@machinesFiles) {next unless -e $machinesFile;open CONF, "<$machinesFile" or die; - edit in src/lib/Hydra/Helper/Nix.pm at line 314