hydra-queue-runner: Send build notifications
[?]
Jun 22, 2015, 10:14 PM
IE2PRAQUCQVFPJ4CAIJRPXXEFC5VBAE3EO5I5FG4XWEDRNONNHKQCDependencies
- [2]
3YHNO5H2Don't use Perl's -w flag - [3]
HUUZFPPKFix race between the queue monitor and the builder threads - [4]
K5G5GZY7Guard against concurrent invocations of hydra-queue-runner - [5]
XV4AEKJChydra-queue-runner: Handle status queries on the main thread - [6]
NJJ7H64SVery basic multi-threaded queue runner - [7]
ERNOO5ZZ* Reorganising. - [8]
T2EIYJNGOn SIGINT, shut down the builder threads - [9]
24BMQDZAStart of single-process hydra-queue-runner - [10]
HHOMBU7Ghydra-queue-runner: Implement timeouts - [11]
T4LLYESZ* Nix expression for building Hydra. - [12]
Q6SOGMDQHydra/28: Rename "scheduler" to "evaluator" - [13]
FV2M6MOThydra: use autoconf/-make - [14]
ENXUSMSVMake concurrency more robust - [15]
5AIYUMTBBasic remote building - [16]
L4AI5YL6Rename hydra_*.pl to hydra-* - [17]
N22GPKYT* Put info about logs / build products in the DB. - [18]
OCZ4LSGGAutomatically retry aborted builds - [19]
GS4BE6TBAsynchronously compress build logs - [20]
PLOZBRTRAdd command ‘hydra-queue-runner --status’ to show current status - [21]
FULDVXE2Periodically dump/log status - [22]
D5QIOJGP* Move everything up one directory. - [23]
C6HOMHZWDon't try to handle SIGINT - [24]
JK2QWPH6 - [25]
JAUB2FT5getQueuedBuilds(): Handle dependent builds first - [*]
LJILHOJ7Create BuildSteps race-free - [*]
XHOZT4WTAdd a command `hydra-create-user' for managing user accounts - [*]
Y6H7Y3OTCapture the path to `guile', when available.
Change contents
- edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 263
/* Notification sender work queue. FIXME: if hydra-queue-runner iskilled before it has finished sending notifications about abuild, then the notifications may be lost. It would be betterto mark builds with pending notification in the database. */typedef std::pair<BuildID, std::vector<BuildID>> NotificationItem;Sync<std::queue<NotificationItem>> notificationSenderQueue;std::condition_variable_any notificationSenderWakeup; - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 324
/* Thread that asynchronously invokes hydra-notify to send buildnotifications. */void notificationSender(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1199
}/* Send notification about this build. */{auto notificationSenderQueue_(notificationSenderQueue.lock());notificationSenderQueue_->push(NotificationItem(build->id, std::vector<BuildID>())); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1206
notificationSenderWakeup.notify_one(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1234
std::vector<BuildID> dependentIDs; - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1297
dependentIDs.push_back(build2->id); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1324
}/* Send notification about this build and its dependents. */{auto notificationSenderQueue_(notificationSenderQueue.lock());notificationSenderQueue_->push(NotificationItem(build->id, dependentIDs)); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1331
notificationSenderWakeup.notify_one(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1423
throw SysError("cannot start ssh");throw SysError("cannot start bzip2"); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1445
void State::notificationSender(){while (true) {try { - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1451
NotificationItem item;{auto notificationSenderQueue_(notificationSenderQueue.lock());while (notificationSenderQueue_->empty())notificationSenderQueue_.wait(notificationSenderWakeup);item = notificationSenderQueue_->front();notificationSenderQueue_->pop();}printMsg(lvlChatty, format("sending notification about build %1%") % item.first);Pid pid = startProcess([&]() {Strings argv({"hydra-notify", "build", int2String(item.first)});for (auto id : item.second)argv.push_back(int2String(id));execvp("hydra-notify", (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove castthrow SysError("cannot start hydra-notify");});int res = pid.wait(true);if (res != 0)throw Error(format("hydra-build returned exit code %1% notifying about build %2%")% res % item.first);} catch (std::exception & e) {printMsg(lvlError, format("notification sender: %1%") % e.what());sleep(5);}}} - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 1650
auto queueMonitorThread = std::thread(&State::queueMonitor, this);std::thread(&State::queueMonitor, this).detach(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1658
/* Idem for notification sending. */std::thread(&State::notificationSender, this).detach();/* Monitor the database for status dump requests (e.g. from‘hydra-queue-runner --status’). */ - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1676[5.92]→[5.771:772](∅→∅),[5.889]→[5.771:772](∅→∅),[5.14845]→[5.771:772](∅→∅),[5.771]→[5.771:772](∅→∅),[5.772]→[5.890:912](∅→∅),[5.912]→[5.3479:3510](∅→∅),[5.1129]→[5.3479:3510](∅→∅),[5.3479]→[5.3479:3510](∅→∅)
// Never reached.queueMonitorThread.join(); - edit in src/script/Makefile.am at line 12[28.421][29.541]
hydra-notify \ - replacement in src/script/hydra-evaluator at line 1
#! /var/run/current-system/sw/bin/perl#! /run/current-system/sw/bin/perl - file addition: hydra-notify[5.2543]
#! /run/current-system/sw/bin/perluse strict;use utf8;use Hydra::Plugin;use Hydra::Helper::Nix;use Hydra::Helper::PluginHooks;STDERR->autoflush(1);binmode STDERR, ":encoding(utf8)";my $config = getHydraConfig();my $db = Hydra::Model::DB->new();my @plugins = Hydra::Plugin->instantiate(db => $db, config => $config);my $cmd = shift @ARGV or die "Syntax: hydra-notify build BUILD-ID [BUILD-IDs...]\n";if ($cmd eq "build") {my $buildId = shift @ARGV or die;my $build = $db->resultset('Builds')->find($buildId)or die "build $buildId does not exist\n";my @dependents;foreach my $id (@ARGV) {my $dep = $db->resultset('Builds')->find($id)or die "build $id does not exist\n";push @dependents, $dep;}notifyBuildFinished(\@plugins, $build, [@dependents]);}else {die "unknown action ‘$cmd’";}