Commit graph

463 commits

Author SHA1 Message Date
Eelco Dolstra 81ac547d2b
Move most of AddBuilds to hydra-eval-jobset
Having this stuff in a separate module is a remnant of the time when
hydra-server could add builds to the queue directly. This is no longer
the case.
2017-02-21 17:20:48 +01:00
Eelco Dolstra 7081f97f3a
Pedantry: CLOCK_REALTIME -> CLOCK_MONOTONIC 2017-02-21 16:17:17 +01:00
Eelco Dolstra a12e9478e7 When manually scheduling an eval, force re-instantiation of store derivations
Without this, if (failed or aborted) derivations have been
garbage-collected, there is no way to restart them, which is very
annoying. Now we set a forceEval flag in the jobset to cause it to be
re-evaluated even if none of the inputs have changed.
2016-10-24 20:20:20 +02:00
Eelco Dolstra bbe45ed844 Remove Persona support
Persona is no longer supported by Mozilla, so let's remove it.
2016-10-20 14:14:04 +02:00
Eelco Dolstra e0b2921ff2 Concurrent hydra-evaluator
This rewrites the top-level loop of hydra-evaluator in C++. The Perl
stuff is moved into hydra-eval-jobset. (Rewriting the entire evaluator
would be nice but is a bit too much work.) The new version has some
advantages:

* It can run multiple jobset evaluations in parallel.

* It uses PostgreSQL notifications so it doesn't have to poll the
  database. So if a jobset is triggered via the web interface or from
  a GitHub / Bitbucket webhook, evaluation of the jobset will start
  almost instantaneously (assuming the evaluator is not at its
  concurrency limit).

* It imposes a timeout on evaluations. So if e.g. hydra-eval-jobset
  hangs connecting to a Mercurial server, it will eventually be
  killed.
2016-10-14 14:22:12 +02:00
Eelco Dolstra dd32033657 hydra-update-gc-roots: Only keep outputs when in direct mode
This prevents the server from gradually filling up due to store paths
fetched by hydra-server that then get turned into a GC root by
hydra-update-gc-roots.
2016-07-12 19:23:10 +02:00
Joe Hermaszewski 35a67d19ba Print jobset name when evaluator fails 2016-07-11 17:37:09 +01:00
Eelco Dolstra a55942603a Provide a plugin hook for when build steps finish
Fixes #318.
2016-05-27 14:35:32 +02:00
Shea Levy aa7cc6d599 Declarative projects: Include the fetch info for the declarative input in the project eval 2016-05-09 08:54:27 -04:00
Shea Levy 4392d3e21d Enable declarative projects.
This allows fully declarative project specifications. This is best
illustrated by example:

* I create a new project, setting the declarative spec file to
  "spec.json" and the declarative input to a git repo pointing
  at git://github.com/shlevy/declarative-hydra-example.git
* hydra creates a special ".jobsets" jobset alongside the project
* Just before evaluating the ".jobsets" jobset, hydra fetches
  declarative-hydra-example.git, reads spec.json as a jobset spec,
  and updates the jobset's configuration accordingly:
{
    "enabled": 1,
    "hidden": false,
    "description": "Jobsets",
    "nixexprinput": "src",
    "nixexprpath": "default.nix",
    "checkinterval": 300,
    "schedulingshares": 100,
    "enableemail": false,
    "emailoverride": "",
    "keepnr": 3,
    "inputs": {
        "src": { "type": "git", "value": "git://github.com/shlevy/declarative-hydra-example.git", "emailresponsible": false },
        "nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs.git release-16.03", "emailresponsible": false }
    }
}
* When the "jobsets" job of the ".jobsets" jobset completes, hydra
  reads its output as a JSON representation of a dictionary of
  jobset specs and creates a jobset named "master" configured
  accordingly (In this example, this is the same configuration as
  .jobsets itself, except using release.nix instead of default.nix):
{
    "enabled": 1,
    "hidden": false,
    "description": "js",
    "nixexprinput": "src",
    "nixexprpath": "release.nix",
    "checkinterval": 300,
    "schedulingshares": 100,
    "enableemail": false,
    "emailoverride": "",
    "keepnr": 3,
    "inputs": {
        "src": { "type": "git", "value": "git://github.com/shlevy/declarative-hydra-example.git", "emailresponsible": false },
        "nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs.git release-16.03", "emailresponsible": false }
    }
}
2016-05-09 08:54:27 -04:00
Shea Levy 9b37cb89ae Add buildStarted plugin hook 2016-04-12 14:42:01 -04:00
Eelco Dolstra ae2cc61be6 Fix hydra.queue.machines.total stat
This was broken by the fact that "machines" now also contains
removed/disabled machines.
2015-09-22 12:59:19 +02:00
Eelco Dolstra aea1ed7445 hydra-evaluator: Fix error handling in fetching inputs
This caused bogus "cannot find the input containing the job
expression" errors.
2015-09-11 13:49:46 +02:00
Eelco Dolstra 2b9bf7526d hydra-send-stats: Keep track of the number of machines 2015-08-27 12:05:06 +02:00
Eelco Dolstra a6e3cb53b9 Use /usr/bin/env to find perl
This is nicer in nix-shell.
2015-08-17 14:18:20 +02:00
Eelco Dolstra 3ded87329d Keep track of how many threads are waiting 2015-07-10 19:10:14 +02:00
Eelco Dolstra 3e7bbec40b hydra-evaluator: Send statistics to statsd 2015-07-10 16:40:50 +02:00
Eelco Dolstra bbee81efae Use triggers for all notifications on Builds table changes 2015-07-08 12:05:32 +02:00
Eelco Dolstra e35b704d80 Drop the 5 minute minimum interval between triggered evals 2015-07-01 14:45:39 +02:00
Eelco Dolstra f5e5a1b96e Don't wake up the queue runner for cached evals 2015-06-26 20:59:14 +02:00
Eelco Dolstra 401f5bdce2 Add a unit for hydra-send-stats 2015-06-26 15:24:12 +02:00
Eelco Dolstra c6fcce3b3b Moar stats 2015-06-25 16:47:39 +02:00
Eelco Dolstra 1a0e1eb5a0 More stats 2015-06-24 13:19:27 +02:00
Eelco Dolstra 62219adaf3 Send queue runner stats to statsd
This is currently done by a separate program that periodically
calls "hydra-queue-runner --status". Eventually, I'll do this
in the queue runner directly.

Fixes #220.
2015-06-23 14:56:43 +02:00
Eelco Dolstra a317d24b29 hydra-queue-runner: Send build notifications
Since our notification plugins are written in Perl, sending
notification from C++ requires a small Perl helper named
‘hydra-notify’.
2015-06-23 00:14:49 +02:00
Eelco Dolstra e32ee3d5b9 Remove hydra-build and the old hydra-queue-runner 2015-06-22 15:43:15 +02:00
Eelco Dolstra a984c0badc Merge branch 'master' into build-ng 2015-06-15 18:21:07 +02:00
Eelco Dolstra c08883966c Use PostgreSQL notifications for queue events
Hydra-queue-runner now no longer polls the queue periodically, but
instead sleeps until it receives a notification from PostgreSQL about
a change to the queue (build added, build cancelled or build
restarted).

Also, for the "build added" case, we now only check for builds with an
ID greater than the previous greatest ID. This is much more efficient
if the queue is large.
2015-06-11 17:41:59 +02:00
Eelco Dolstra 672bbb1c67 hydra-update-gc-roots: Get Builds and BuildOutputs in the same query
This greatly reduces the number of roundtrips to the database.
2015-06-11 14:10:21 +02:00
Eelco Dolstra 9989a90e99 Keep the most recent successful build of current jobs
Fixes #140.
2015-06-11 14:10:21 +02:00
Eelco Dolstra e003665146 Split timeSpent query into 2 separate queries, as postgresql isn't able to figure out a decent query plan. With 120k jobs in queue, this makes some queries go from 100s to 1-2s. 2015-05-01 12:28:29 +02:00
Eelco Dolstra 01cd6397cb Better error message 2015-04-14 15:16:24 +02:00
Eelco Dolstra 63306aaf5a hydra-evaluator: Add some debug code 2015-04-09 17:35:04 +02:00
Eelco Dolstra 9e664cf8b0 Fix not-null constraint violation inserting build step
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR:  null value in column "machine" violates not-null constraint
2015-04-07 13:34:00 +02:00
Eelco Dolstra ad2b7646ac Don't show missing paths in logs 2015-03-04 15:44:04 +01:00
Eelco Dolstra adc72d2409 Record which build a failed build step was propagated from 2015-02-25 16:42:32 +01:00
Eelco Dolstra 48af914e28 When propagating failure, propagate the duration and machine
Previously the duration would just show as "0" and you would have to
search for the original build to get the duration.
2015-02-25 16:21:54 +01:00
Eelco Dolstra a12135fc51 Don't use Perl's -w flag 2014-12-12 17:39:52 +01:00
Eelco Dolstra 6a0b9a3476 hydra-build: Handle new trace messages
Now build step duration no longer includes network overhead (i.e.
time to copy closures to the build machine).
2014-12-12 17:20:50 +01:00
Eelco Dolstra c0ca5489e1 Don't use given/when
These give warnings in Perl >= 5.18:

  given is experimental at /home/hydra/src/hydra/src/lib/Hydra/Helper/CatalystUtils.pm line 241.
  when is experimental at /home/hydra/src/hydra/src/lib/Hydra/Helper/CatalystUtils.pm line 242.
  ...
2014-12-12 11:27:17 +01:00
Eelco Dolstra 8523130ebb Use Email::MIME instead of Email::Simple
Email::Simple cannot handle non-ASCII characters.

Fixes #191.
2014-11-19 14:45:46 +01:00
Eelco Dolstra 5a7efc0469 Fix aggregate handling 2014-10-01 15:34:05 +02:00
Eelco Dolstra 9b38b5f134 Remove the longDescription field
It's not useful and takes up a lot of space.
2014-09-30 15:44:09 +02:00
Eelco Dolstra 5b4de2dee6 hydra-evaluator: Reduce verbosity 2014-09-30 15:44:08 +02:00
Eelco Dolstra 09a96c642a hydra-eval-jobs: Use JSON instead of XML
XML::Simple is pretty slow - reading the output for the Nixpkgs jobset
takes half a minute or so. JSON is pretty much instantaneous.
2014-09-30 15:44:08 +02:00
Eelco Dolstra 1c20cfdf24 Drop the errorMsg column in the Jobs table
We're not using it anywhere.
2014-09-29 19:46:11 +02:00
aszlig 9c7f303255 Use mktemp for tempdir creation in prefetchers.
This incorporates the following two commits from <nixpkgs>:

NixOS/nixpkgs@f83af95f8a
NixOS/nixpkgs@5e7a1cf955

Hydra was the original reason why I was fixing tempdir creation in the
first place. Seeing that Hydra ships its own versions of these scripts,
we need to patch them here as well.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-08-29 12:40:11 +02:00
Eelco Dolstra a80bfceaca Remove timeout detection hack 2014-08-17 19:26:03 +02:00
Eelco Dolstra 69e3aa0438 Write Hydra roots as regular files instead of symlinks
Note that this requires at least NixOS/Nix@1c208f2b7e.
2014-08-01 17:24:55 +02:00
Eelco Dolstra 365de86ead Fix hydra-update-gc-roots 2014-07-16 23:20:58 +02:00
Eelco Dolstra fb5f01097b Fix race between hydra-eval-jobs and hydra-update-gc-roots
If hydra-eval-jobs creates a new root, and hydra-update-gc-roots runs
before hydra-evaluator has had a chance to add the corresponding build
to the database, then hydra-update-gc-roots will remove the root. If
subsequently the Nix garbage collector kicks in, it may remove the
build's .drv file before the build is performed. Since evaluation of
the Nixpkgs and NixOS jobsets nowadays takes a lot of time (e.g. an
hour), the probability of this happening is fairly high.

The quick fix is not to delete roots that are less than a day old. So
long as evaluation doesn't take longer than a day, this should be fine
;-)

Fixes #166.
2014-07-14 13:18:07 +02:00
Ludovic Courtès 4471cae07e hydra-eval-guile-jobs: Add "This file is part of Hydra". 2014-04-08 18:22:21 +02:00
Ludovic Courtès cc46456598 hydra-eval-guile-jobs: Register derivations as GC roots.
* src/script/hydra-eval-guile-jobs.in (register-gc-root): New
  procedure.
  (job-evaluations->sxml): Add #:gc-roots-dir parameter.  Call
  'register-gc-root'.
  (job-evaluations->xml): Add #:gc-roots-dir parameter; pass it to
  'job-evaluations->sxml'.
  (eval-guile-jobs): Warn when --gc-roots-dir isn't passed.  Pass
  GC-ROOTS-DIR to 'job-evaluations->xml'.
2014-04-08 18:22:21 +02:00
Ludovic Courtès e3e8c1bc74 hydra-eval-guile-jobs: Honor $NIX_STORE_DIR.
* src/script/hydra-eval-guile-jobs.in (strip-store-path): Honor
  $NIX_STORE_DIR.
2014-04-08 18:22:21 +02:00
Eelco Dolstra 4cf0d7c4b3 hydra-update-gc-roots: Keep derivations of failed builds
By keeping the derivations of failed builds in the most recent
evaluations, we ensure that failed builds can be restarted.
2014-04-08 17:54:11 +02:00
Ludovic Courtès 61448ca2bd guile: Raise default absolute timeout to from 2h to 20h. 2014-02-27 22:19:52 +01:00
Shea Levy a92a57f3b0 hydra-evaluator: When evaluating a single jobset, exit with a failure code if evaluation fails
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-11-27 14:29:05 -05:00
Eelco Dolstra 55f9d23933 Add a command `hydra-create-user' for managing user accounts 2013-11-06 13:36:29 +01:00
Eelco Dolstra 3315d1ea51 Remove obsolete hydra-control script 2013-11-06 11:42:49 +00:00
Eelco Dolstra 7a18e5f0c1 Remove unused file 2013-11-06 11:42:04 +00:00
Eelco Dolstra ecadcef642 Prevent a division by zero in hydra-queue-runner
Fixes #131.
2013-11-06 12:15:11 +01:00
Eelco Dolstra 647d6bc3f1 Force creation of a new uncached eval if jobs have been removed
Previously we only checked if jobs had been added.  We should probably
rename the "hasNewBuilds" field in the database.
2013-11-01 19:24:52 +01:00
Shea Levy 0db950931a Merge remote-tracking branch 'upstream/who-broke-builds' into upstream-master
Include information about who changed the build status in notification
emails, and enable optional per-input notification of said committers.

Conflicts due to two branches modifying the database schema.

Signed-off-by: Shea Levy <shea@shealevy.com>

Conflicts:
	src/lib/Hydra/Schema/Jobsets.pm
	src/sql/upgrade-23.sql
2013-10-15 09:49:20 -04:00
Eelco Dolstra c4e39d4769 Add one-shot jobsets
There are jobsets that are evaluated only once, that is, after they've
been evaluated, they're disabled automatically.  This is primarily
useful for doing releases: for instance, doing an evaluation with
"officialRelease" set to "true" should be done only once.
2013-10-11 12:01:52 +02:00
Eelco Dolstra f592ce0026 Fix extreme slowness in hydra-queue-runner
If there are builds in the queue that depend on another scheduled
build, then hydra-queue-runner will start the dependency first and
block the dependent builds.  This is implemented in
findBuildDependencyInQueue.  However, if there are tens of thousands
of such dependent builds, since each call to
findBuildDependencyInQueue may take a second or so, hydra-queue-runner
will spend hours just deciding which builds *not* to do.  Thus very
little progress is made.

So now, when a build is started, we immediately check which builds are
"blocked" by it (i.e. depend on it), and remove such builds from
consideration.
2013-10-11 10:54:02 +02:00
Shea Levy 26470f1656 Check all inputs for blame but only email selected inputs
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-10-08 14:47:24 -04:00
Shea Levy 3e4a4e3761 Propagate checkresponsible from JobsetInput to BuildInput
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-10-08 13:24:49 -04:00
Eelco Dolstra 720c3892a3 Use delete instead of delete_all
DBIC's delete_all method fetches all rows separately, which is slow.
2013-10-03 19:42:44 +02:00
Eelco Dolstra b1f7096935 Restore old findBuildDependencyInQueue behaviour 2013-10-03 13:08:32 +02:00
Eelco Dolstra b1a26e6caa Revert "Add a dependency_lookup configuration option to enable (slow) dependency lookup in queue. This behaviour was disabled temporarily in accefbb79 due to slowness in very large queues, but some people might be dependent on it, so it is configurable until the previous behaviour is implemented more efficiently."
This reverts commit 24f5a6b15f.
2013-10-03 13:07:32 +02:00
Rob Vermaas 24f5a6b15f Add a dependency_lookup configuration option to enable (slow) dependency lookup in queue. This behaviour was disabled temporarily in accefbb79 due to slowness in very large queues, but some people might be dependent on it, so it is configurable until the previous behaviour is implemented more efficiently. 2013-10-03 09:09:18 +00:00
Eelco Dolstra 4dd1197d89 Fix uninitialized value warning 2013-09-30 10:01:09 +00:00
Eelco Dolstra af2b0c8bad Remove dead code 2013-09-30 11:57:38 +02:00
Eelco Dolstra d46ebeea99 Distinguish between permanent evaluation errors and transient input errors
Fixes #112.
2013-09-25 16:21:16 +02:00
Eelco Dolstra e1c9e28589 Handle UTF-8 characters in eval error messages 2013-09-25 15:51:03 +02:00
Eelco Dolstra a8db329839 Warn against multiple jobs with the same name 2013-09-25 15:30:59 +02:00
Eelco Dolstra a2491f76a4 Use the same start/stop time for the build steps as for the build 2013-09-25 01:00:20 +02:00
Eelco Dolstra f037a318e3 *headdesk*
DBIC::Class helpfully doesn't warn you when you're matching against
unselected columns.  So this query actually returned all builds...
2013-09-25 01:00:20 +02:00
Rob Vermaas b1e29e50a7 Only send email notification of evaluation error when the evaluation error has changed. Fixes #121. 2013-09-24 12:01:57 -04:00
Shea Levy 6d5a3d0580 Derivations with multiple outputs break the 'link name is store path' assumption
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-09-22 21:26:59 -04:00
Eelco Dolstra 77dbf55abb hydra-queue-runner: Tweaked the selection method
Pick the jobset that has used the smallest fraction of its share,
rather than the jobset furthest below its share in absolute terms.
This gives jobsets with a small share a quicker start (but they
will also run out of their share quicker).
2013-09-21 19:54:58 +00:00
Eelco Dolstra cf43c605cd hydra-queue-runner: Cache the lookup of time spent per jobset 2013-09-21 19:54:46 +00:00
Eelco Dolstra 4cdf1a270d hydra-queue-runner: Set the start time properly 2013-09-21 19:38:02 +00:00
Eelco Dolstra 52ce662710 hydra-queue-runner: Don't kill builds we just started 2013-09-21 20:51:43 +02:00
Eelco Dolstra accefbb798 hydra-queue-runner: Disable findBuildDependencyInQueue for now
It's way too slow.
2013-09-21 20:35:02 +02:00
Eelco Dolstra 9602499c1c hydra-evaluator: Do the actual work in a subprocess
This should get rid of the slow memory leaks exhibited by
hydra-evaluator.
2013-09-21 15:49:27 +00:00
Eelco Dolstra 4ed877360b hydra-queue-runner: Improved scheduling
Each jobset now has a "scheduling share" that determines how much of
the build farm's time it is entitled to.  For instance, if a jobset
has 100 shares and the total number of shares of all jobsets is 1000,
it's entitled to 10% of the build farm's time.  When there is a free
build slot for a given system type, the queue runner will select the
jobset that is furthest below its scheduling share over a certain time
window (currently, the last day).  Withing that jobset, it will pick
the build with the highest priority.

So meta.schedulingPriority now only determines the order of builds
within a jobset, not between jobsets.  This makes it much easier to
prioritise one jobset over another (e.g. nixpkgs:trunk over
nixpkgs:stdenv).
2013-09-21 14:57:01 +00:00
Shea Levy 74388353b5 Add a plugin for backing up builds in s3
In your hydra config, you can add an arbitrary number of <s3config>
sections, with the following options:

* name (required): Bucket name
* jobs (required): A regex to match job names (in project:jobset:job
  format) that should be backed up to this bucket
* compression_type: bzip2 (default), xz, or none
* prefix: String to prepend to all hydra-created s3 keys (if this is
  meant to represent a directory, you should include the trailing slash,
  e.g. "cache/"). Default "".

After each build with an output (i.e. successful or failed-with-output
builds), the output path and its closure are uploaded to the bucket as
.nar files, with corresponding .narinfos to enable use as a binary
cache.

This plugin requires that s3 credentials be available. It uses
Net::Amazon::S3, which as of this commit the nixpkgs version can
retrieve s3 credentials from the AWS_ACCESS_KEY_ID and
AWS_SECRET_ACCESS_KEY environment variables, or from ec2 instance
metadata when using an IAM role.

This commit also adds a hydra-s3-backup-collect-garbage program, which
uses hydra's gc roots directory to determine which paths are live, and
then deletes all files except nix-cache-info and any .nar or .narinfo
files corresponding to live paths. hydra-s3-backup-collect-garbage
respects the prefix configuration option, so it won't delete anything
outside of the hierarchy you give it, and it has the same credential
requirements as the plugin. Probably a timer unit running the garbage
collection periodically should be added to hydra-module.nix

Note that two of the added tests fail, due to a bug in the interaction
between Net::Amazon::S3 and fake-s3. Those behaviors work against real
s3 though, so I'm committing this even with the broken tests.

Signed-off-by: Shea Levy <shea@shealevy.com>
2013-09-18 18:32:58 +02:00
Eelco Dolstra 4705af48b8 hydra-build: Hack to handle timeouts 2013-09-18 13:06:35 +00:00
Eelco Dolstra e54b536bb7 hydra-update-gc-roots: Don't keep the most recent successful view result
Views are deprecated.
2013-09-18 11:12:33 +00:00
Eelco Dolstra 2845d46d21 hydra-update-gc-roots: Keep more evals
We now keep *all* unfinished evaluations of a jobset, in addition to
the <keepnr> most recent finished evaluations.

The main motivation is to ensure that mirror-{nixos,nixpkgs} work
properly: if building an evaluation takes too long, some of its builds
may already have been garbage-collected by the time the others finish.
2013-09-18 11:10:10 +00:00
Eelco Dolstra 3f68076577 hydra-build: Don't send a giant query to the database
We had Postgres barfing with this error:

  DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: stack depth limit exceeded

because the ‘drvpath => [ @dependentDrvs ]’ in failDependents can
cause a query of unbounded size.  (In this specific case there was a
failure of Bison, which has > 10000 dependent derivations.)  So now we
just get all scheduled builds from the DB.
2013-09-10 11:01:29 +00:00
Eelco Dolstra 35aad40692 Kill builds that produce more than 64 MiB of log output 2013-09-10 10:33:55 +00:00
Rob Vermaas bf42392fe4 Fix typo. 2013-08-27 15:12:41 +02:00
Eelco Dolstra a57957df84 Handle job aliases in AggregateConstituents
Aggregate constituents are derivations.  However there can be multiple
builds in an evaluation that have the same derivation, i.e. they can
alias each other (e.g. "emacs", "emacs24" and "emacs24Packages.emacs"
in Nixpkgs).  Previously we picked a build arbitrarily for the
AggregateConstituents table.  Now we pick the one with the shortest
name (e.g. "emacs").
2013-08-27 11:48:02 +02:00
Eelco Dolstra 46f8b25c1f Keep builds that failed with output
The user may want to look at the output, so they shouldn't be
GC'ed right away.
2013-08-16 16:36:06 +02:00
Eelco Dolstra d16738e130 hydra-update-gc-roots: Keep the most recent evaluations
We now keep all builds in the N most recent evaluations of a jobset,
rather than the N most recent builds of every job.  Note that this
means that typically fewer builds will be kept (since jobs may be
unchanged across evaluations).
2013-08-16 16:21:30 +02:00
Eelco Dolstra 1776d9118f Rename aggregate members to constituents 2013-08-15 02:33:10 +02:00
Eelco Dolstra d58142b3f0 Store aggregate members in the database
For presentation purposes, we need to know what builds are part of an
aggregate build.  So at evaluation time, look at the "members"
attribute, find the corresponding builds in the eval, and create a
mapping in the AggregateMembers table.
2013-08-14 01:59:29 +02:00
Eelco Dolstra 452c8e36d1 Materialize the number of finished builds
The NrBuilds table tracks the value of ‘select count(*) from Builds
where finished = 0’, keeping it up to date via a trigger.  This is
necessary to make the /all page fast, since otherwise it needs to do a
sequential scan on the Builds table.
2013-08-12 20:19:10 +02:00
Shea Levy 166d56088f Call buildFinished when a cached build is added
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-07-08 13:35:34 -04:00
Eelco Dolstra d18fc4fc38 Include names of committers in HipChat notifications
HipChat notification messages now say which committers were
responsible, e.g.

  Job patchelf:trunk:tarball: Failed, probably due to 2 commits by Eelco Dolstra
2013-07-02 13:54:18 +02:00
Eelco Dolstra 7e11d01abf Remove tabs 2013-07-02 11:37:16 +02:00
Eelco Dolstra 98a105fe69 hydra-build: Give a nicer error message if the derivation is gone 2013-06-14 11:01:53 +00:00
Eelco Dolstra cceab7308b hydra-queue-runner: Handle restarted builds whose derivation is gone
Restarted builds whose derivation has been garbage-collected in the
meantime caused hydra-queue-runner to get stuck in a loop saying:

Jun 14 11:54:25 lucifer hydra-queue-runner[31844]: system type `x86_64-darwin': 0 active, 2 allowed, started 2 builds
Jun 14 11:54:25 lucifer hydra-queue-runner[31844]: {UNKNOWN}: path `/nix/store/wcizsch2garjlvs4pswrar47i1hwjaia-inconsolata.drv' is not valid at
/nix/store/ypkdm4v13yrk941rvp8h0y425a5ww6nm-hydra-0.1pre1353-40debf1/bin/.hydra-queue-runner-wrapped line 51. at
/nix/store/kjpsc2zdaxnd44azxyw60f2px839m1cd-hydra-perl-deps/lib/perl5/site_perl/5.16.2/Catalyst/Model/DBIC/Schema.pm line 501
2013-06-14 11:00:05 +00:00
Eelco Dolstra 40debf1515 hydra-queue-runner: Don't unlock builds we just started
This happens if the previous iteration took more than 60 seconds.
Then the queue runner may think that builds failed to start properly
and unlock them, e.g.

build 5264936 pid 19248 died, unlocking
build 5264951 pid 19248 died, unlocking
build 5257073 pid 19248 died, unlocking
...
2013-06-07 20:15:37 +00:00
Eelco Dolstra 5d9b7c6ab2 Speed up findBuildDependencyInQueue
This was taking a long time due to the giant SQL query.

Issue #99.
2013-06-07 20:15:32 +00:00
Eelco Dolstra 8e36343b62 hydra-queue-runner: Start as many builds as possible on each iteration
Because we don't start a build if a dependency is already building,
it's possible that some or all of the $extraAllowed highest-priority
builds in the queue are not eligible.  E.g. with $extraAllowed = 32,
we might start only 3 builds even though there are thousands in the
queue.  The fix is to try all queued builds until $extraAllowed have
been started.

Issue #99.
2013-06-07 20:15:20 +00:00
Eelco Dolstra 1f1615e80b Support revision control systems via plugins 2013-05-25 15:36:58 -04:00
Eelco Dolstra 9ac363d32a Fill in starttime/stoptime for cached builds 2013-05-24 12:43:02 -04:00
Eelco Dolstra 57b2bb0674 Let Builds.timestamp refer to the time the build was added
Previously, for scheduled builds, "timestamp" contained the time the
build was added to the queue, while for finished builds, it was the
time the build finished.  Now it's always the former.
2013-05-23 10:45:49 -04:00
Rob Vermaas 43785dfca9 Merge pull request #85 from peti/dont-clutter-system-log-with-debug-messages
hydra-queue-runner: don't clutter the system log with debug message
2013-05-10 14:52:13 -07:00
Eelco Dolstra 3939974df8 Set build status to 1 if the primary build failed 2013-05-10 00:51:45 +02:00
Eelco Dolstra 102359bf44 Add separate build step status codes for cached failures and timeouts 2013-05-09 22:13:01 +00:00
Eelco Dolstra a6d8566faf If a build aborts, mark any remaining active build steps as aborted
See e.g. http://hydra.nixos.org/build/4915744.

P.S. existing active build steps of finished builds can be marked as
aborted by running:

update buildsteps set busy = 0, status = 4
  where (build, stepnr) in
    (select s.build, s.stepnr from buildsteps s join builds b on s.build = b.id where b.finished = 1 and s.busy = 1);
2013-05-09 18:03:34 +02:00
Eelco Dolstra 038db3abeb Pass failing dependent builds to buildFinished 2013-05-08 18:54:01 +02:00
Eelco Dolstra 44b8d6f449 Use OO-style plugins
This is mostly so we don't have to pass around common parameters like
"db" and "config", and we don't have to check for the existence of
methods.

A plugin now looks like this:

  package Hydra::Plugin::TwitterNotification;

  use parent 'Hydra::Plugin';

  sub buildFinished {
      my ($self, $build, $dependents) = @_;
      print STDERR "tweeting about build ", $build->id, "\n";
      # Send tweet...
      # Hydra database is $self->{db}.
  }
2013-05-08 18:35:24 +02:00
Eelco Dolstra a420a33f66 Use "can" to check whether a plugin supports buildFinished 2013-05-08 17:57:48 +02:00
Eelco Dolstra 1d8bb0764b Add a plugin mechanism
You can now add plugins to Hydra by writing a module called
Hydra::Plugin::<whatever> and putting it in Perl's search path.  The
only plugin operation currently supported in buildFinished, called
when hydra-build has finished doing a build.

For instance, a Twitter notification plugin would look like this:

  package Hydra::Plugin::TwitterNotification;

  sub buildFinished {
      my ($self, $db, $config, $build, $dependents) = @_;
      print STDERR "tweeting about build ", $build->id, "\n";
      # send tweet...
  }

  1;
2013-05-08 17:30:30 +02:00
Eelco Dolstra 9947415ef0 Remove Twitter notification support
Turns out Twitter is not an ideal medium for sending build
notifications :-)
2013-05-03 18:33:11 +02:00
Eelco Dolstra f762d111f1 If a build step fail, immediately fail all queued builds that depend on it
This prevents unnecessary work, but it's mostly a refactoring to
support combining notification emails.
2013-05-03 18:30:13 +02:00
Eelco Dolstra 507e5bb190 Drop unused "disabled" columns 2013-05-03 16:39:17 +02:00
Eelco Dolstra 906b129f6a Fix findBuildDependencyInQueue
Previously this function didn't actually have a lot of effect.  If a
build A had a dependency B, Hydra would start B first.  But on the
next scan through the queue, it would start A anyway, because of the
"busy => 0" restriction.

Now the queue runner won't start a build if a dependency is already
running.  (This is not necessarily optimal, since the build may have
other dependencies that don't correspond to a build in the queue but
could run.  One day we'll start all Hydra builds in parallel...)

Also, for performance, use computeFSClosure instead of "nix-store
-qR".  And don't bother with topological sorting because it didn't
have an effect anyway since the database returns dependencies in
arbitrary order.
2013-05-03 16:27:26 +02:00
Eelco Dolstra e96916533f Allow a per-jobset check interval
This allows checking a jobset (say) at most once a day.  It's also
possible to disable polling by setting the interval to 0.  This is
useful for jobsets that use push notification or are manually
evaluated.
2013-05-02 17:55:47 +02:00
Shea Levy adb9ad83dd hydra-evaluator: Respect triggers of disabled jobsets
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-05-02 11:32:25 -04:00
Ludovic Courtès bd5454d5d9 hydra-eval-guile-jobs: Use `--fresh-auto-compile'.
* src/script/hydra-eval-guile-jobs.in (main): Run `guile' with
  `--fresh-auto-compile'.
2013-04-13 18:59:42 +02:00
Peter Simons ccbe75781b hydra-queue-runner: don't clutter the system log with debug message
Avoid the frequently printed

  hydra-queue-runner[10293]: system type `x86_64-linux': 2 active, 2 allowed, starting 0 builds

message. That information is only interesting when some build are
actually started.
2013-04-11 10:56:40 +02:00
Eelco Dolstra b8369a6a5f Put build status in front of the notification mail subject 2013-04-02 10:40:50 +02:00
Ludovic Courtès f3aa48978e hydra-eval-guile-jobs: Allow use of the installed Guix.
* src/script/hydra-eval-guile-jobs.in: Leave GUILE_LOAD_PATH and
  GUILE_LOAD_COMPILED_PATH unchanged.
2013-03-27 00:07:57 +01:00
Ludovic Courtès 9a9f37f209 hydra-eval-guile-jobs: Adjust to multiple-output format.
This is a followup to commit
10882a1ffd ("Add multiple output
support").

* src/script/hydra-eval-guile-jobs.in (job-evaluations->sxml): Return
  several `output' tags in the body, and remove the `outPath' attribute
  of `job'.
2013-03-27 00:07:57 +01:00
Ludovic Courtès 9da89dd32b hydra-eval-guile-jobs: Adjust to <license> objects.
* src/script/hydra-eval-guile-jobs.in (job-evaluations->sxml): Output
  the license name, not the external representation of <license>
  objects.
2013-03-27 00:07:57 +01:00
Peter Simons 5ffc925ae7 hydra-queue-{runner,evaluator}: don't clutter the system log with debug messages 2013-03-26 11:03:15 +01:00
Shea Levy 152c392198 Whoops 2013-03-07 10:52:31 -05:00
Eelco Dolstra 6d131719be Respect SystemTypes if defined 2013-03-05 18:01:44 +01:00
Shea Levy d764c135ce hydra-queue-runner: Use nix.machines instead of the SystemTypes table to determine how many build jobs are allowed per system type.
Note that on machines that support multiple system types, EACH system type gets the full number of build slots, which is almost certainly not what we want.
2013-03-04 17:44:19 -05:00
Eelco Dolstra a77161e40a Allow users to edit their own settings
Also, don't use the flash anymore for going back to the referer.
2013-03-04 15:25:23 +01:00
Eelco Dolstra f51b93da03 Remove debug line 2013-02-25 21:18:29 +01:00
Eelco Dolstra 42d2015357 Support push notification of repository changes
External machines can now notify Hydra that it should check a
repository by sending a GET or PUSH request to /api/push, providing a
list of jobsets to be checked and/or a list of repository URLs.  In
the latter case, all jobsets that have any of the specified
repositories as an input will be checked.

For instance, you can configure GitHub or BitBucket to send a request
to the URL

  http://hydra.example.org/api/push?repos=git://github.com/NixOS/nixpkgs.git

to trigger evaluation of all jobsets that have
git://github.com/NixOS/nixpkgs.git as an input, or to the URL

  http://hydra.example.org/api/push?jobsets=patchelf:trunk,nixpkgs:trunk

to trigger evaluation of just the specified jobsets.
2013-02-25 21:10:32 +01:00
Eelco Dolstra ddcb9f1d5d Handle the case where a jobset has never been evaluated 2013-02-25 19:38:11 +00:00
Eelco Dolstra 24de044c55 hydra-evaluator: Always pick the jobset that hasn't been evaluated longest 2013-02-25 18:47:54 +01:00
Eelco Dolstra 10882a1ffd Add multiple output support
This requires turning the outPath columns in the Builds and BuildSteps
tables into separate tables, and so requires a schema upgrade.
2013-02-13 16:49:28 +00:00
Eelco Dolstra ecdbce1a61 Handle active build steps of aborted builds properly 2013-01-22 23:01:29 +01:00
Eelco Dolstra 30e5185acf Remove the logfile and logSize columns from the database
It's pointless to store these, since Nix knows where the logs are.
Also handle (in fact require) Nix's new log storage scheme.  Also some
cleanups in the build page.
2013-01-22 22:48:02 +01:00
Eelco Dolstra 67aefde62c Remove trailing whitespace 2013-01-22 14:41:02 +01:00
Eelco Dolstra f188fe5683 hydra-evaluator: Don't require $HYDRA_CONFIG 2013-01-22 13:19:28 +01:00
Ludovic Courtès 183078131a Capture the path to `guile', when available. 2012-10-17 16:25:49 +02:00
Ludovic Courtès f27ae1d566 Add support for Guile & Guix. 2012-10-17 16:23:00 +02:00
Rob Vermaas 90c9b5dd60 Do not send emails when build is cancelled/aborted. Also, ignore aborted/cancelled builds in comparing to previous build. 2012-08-06 00:00:07 +02:00
Eelco Dolstra 2ab4c7d597 Update queryPathInfo calls 2012-07-18 23:14:45 +02:00
Rob Vermaas a2f56ce574 * Read logs using logContents function in stead of handling it everywhere separately. 2012-06-26 12:00:18 +02:00
Rob Vermaas b591c443b0 Keep builds of disabled jobsets that are not hidden. Fixes #18. 2012-05-11 09:11:07 +02:00
Eelco Dolstra 854513be8e I should test first 2012-04-30 17:57:13 +02:00
Eelco Dolstra dcc570f454 Set the build status properly for failing local builds
If a build has ‘preferLocalBuilds = true’ (or we're not using remote
building), and the build has a non-permanent failure, then the build
status should be "Aborted" rather than "Failed".  This is denoted by
an exit status of 100 from nix-store.
2012-04-30 17:15:35 +02:00
Rob Vermaas 4a1a2203ac I should sleep... grmbl 2012-04-26 09:37:48 +02:00
Rob Vermaas 3c465c3661 Revert nix-prefetch-git changes merged in earlier from Merge request #3, which broke git describe functionality used in GNU jobsets. 2012-04-26 09:31:00 +02:00
Rob Vermaas b49e138e9c Merge pull request #3 from nbp/candidates/fetch-git
Optimize fetch-git.
2012-04-24 10:18:28 -07:00
Rob Vermaas 966cc22131 Fix query for certain postgresql versions. 2012-04-22 08:30:48 +02:00
Eelco Dolstra 8f31935ffa Handle the case where there are no builds and no previous eval 2012-04-17 12:32:44 +02:00
Eelco Dolstra ec87ad2bf2 Missing part of aaacf9eda3 2012-04-15 22:57:10 +00:00
Eelco Dolstra fd50ac1d4e Store the inputs of each evaluation in the database
Achtung: this requires a schema upgrade via "hydra-init".
2012-04-15 18:36:36 +00:00
Eelco Dolstra 80705c8a20 hydra-init: show SQL commands being executed 2012-04-15 18:34:32 +02:00
Nicolas Pierron 19d9955e89 Optimize fetch-git. 2012-04-14 18:17:35 -07:00
Eelco Dolstra f52ca0c588 Add a redirect to the latest view result for which the underlying evaluation has finished completely
This will be useful for the Nixpkgs channel mirror script:

  http://hydra.nixos.org/view/nixpkgs/unstable/latest-finished/channel

is the channel containing the latest, consistent, tested set of builds.
2012-04-03 17:45:03 +02:00
Eelco Dolstra 2c677ec71a Always record inputs passed through -I in the BuildInputs table
We currently have no way to determine if the Nix evaluator used a
specific -I input, so we need to record all of them as inputs.
2012-04-03 10:10:45 +00:00
Eelco Dolstra 2f9153c640 Prevent multiple builds with the same (job, outPath) tuple from being added
This happened in a pathological case in Nixpkgs: the "grub" job is
evaluated for i686-linux and x86_64-linux, but in the latter case it
returns the same derivation as in the former case.  So only one build
should be added.
2012-04-02 15:56:29 +00:00
Eelco Dolstra d8f8143cc2 No wonder our disk was filling up 2012-03-26 17:13:50 +02:00
Eelco Dolstra 1f268d2d43 Update isCurrent properly 2012-03-13 13:09:10 +01:00
Eelco Dolstra 179b012a8e Open the DB using Hydra::Model::DB->new
This gets rid of the openHydraDB function and ensures that we
open the database in a consistent way.

Also drop the PostgreSQL sequence hacks.  They don't seem to be
necessary anymore.
2012-03-13 12:10:19 +01:00
Eelco Dolstra 13f4636436 hydra-evaluator: handle the case where there is no previous jobset eval 2012-03-12 21:13:28 +01:00
Eelco Dolstra a4cda5e337 Don't use the Switch module
It was removed in Perl 5.14.
2012-03-12 20:47:30 +01:00
Eelco Dolstra 87e4d43848 Fix the jobset unchanged check
When checking whether the jobset is unchanged, we need to compare with
the previous JobsetEval regardless of whether it had new builds.
Otherwise we'll keep adding new JobsetEval rows.
2012-03-12 20:47:30 +01:00
Eelco Dolstra 6526d4a65f hydra-build: only send email if the status differs from the previous build
This isn't perfect because it doesn't handle the case where a
previous build hasn't finished yet.  But at least it won't send mail
for old builds that fail while a newer build has already succeeded.
2012-03-12 20:47:29 +01:00
Eelco Dolstra 47f877c5bb Evaluator cleanups
* Don't use isCurrent anymore; instead look up builds in the previous
  jobset evaluation.  (The isCurrent field is still maintained because
  it's still used in some other places.)

* To determine whether to perform an evaluation, compare the hash of
  the current inputs with the inputs of the previous jobset
  evaluation, rather than checking if there was ever an evaluation
  with those inputs.  This way, if the inputs of an evaluation change
  back to a previous state, we get a new jobset evaluation in the
  database (and thus the latest jobset evaluation correctly represents
  the latest state of the jobset).

* Improve performance by removing some unnecessary operations and
  adding an index.
2012-03-12 20:47:29 +01:00
Eelco Dolstra bc82a82593 Fix a race condition in hydra-update-gc-roots
Since it read the actual roots after determining the set of desired
roots, there was a possibility that it would delete roots added by
hydra-evaluator or hydra-build while hydra-update-gc-roots was
running.  This could cause a derivation to be garbage-collected before
the build was performed, for instance.  Now the actual roots are read
first, so any root added after that time is not deleted.
2012-03-12 20:47:29 +01:00
Eelco Dolstra 29d5a02b94 Speed up hydra-update-gc-roots
The hydra-update-gc-roots script is taking around 95 minutes on our
Hydra instance (though a lot of that is I/O wait).  This patch
significantly reduces the number of database queries.  In particular,
the N most recent successful builds for each job in a jobset are now
determined in a single query.  Also, it removes the calls to
readlink().
2012-03-12 20:47:29 +01:00
Eelco Dolstra 8d65ab6158 Don't use a prepared statement for the active build steps query
Prepared statements are sometimes much slower than unprepared
statements, because the planner doesn't have access to the query
parameters.  This is the case for the active build steps query (in
/status), where a prepared statement is three orders of magnitude
slower.  So disable the use of prepared statements in this case.

(Since the query parameters are constant here, it would be nicer if we
could tell DBIx::Class to prepare a statement with those parameters
fixed.  But I don't know an easy way to do so.)
2012-03-12 20:47:29 +01:00
Eelco Dolstra 68a867da67 Merge the BuildResultInfo table into the Builds table 2012-03-12 20:47:29 +01:00
Eelco Dolstra 25334715f8 Merge the BuildSchedulingInfo table into the Builds table
This simplifies the code and improves performance since it reduces
the number of joins.
2012-03-12 20:47:29 +01:00
Eelco Dolstra 19fe4b9b4a Add hydra-init to the tarball 2012-03-05 15:35:13 +01:00
Eelco Dolstra 541238030d Provide a command ‘hydra-init’ to initialise/upgrade the database
For schema upgrades, hydra-init executes the files
src/sql/upgrade-<N>.sql, each of which upgrades the schema from
version N-1 to N.  The upgrades are wrapped in a transaction.
2012-02-28 20:16:16 +01:00
Eelco Dolstra da26294fdb Don't install hydra-create
It doesn't do anything useful for users.
2012-02-28 15:33:28 +01:00
Ludovic Courtès 1f448673f0 hydra-build: Do not send email following an abortion. 2012-02-14 11:48:44 +01:00
Eelco Dolstra a3cc2ce796 Remove redundant dot in status emails
E.g.:

  This is to let you know that Hydra build 1998534 of job patchelf:trunk:deb_ubuntu1110x86_64 is 'Success'..
2012-02-07 14:51:47 +01:00
Ludovic Courtès 5644c1c7d9 hydra-build: Add system info to the subject and extra headers. 2012-01-31 18:27:33 +01:00
Eelco Dolstra b1da85140d Fix sysbuild input type handling 2011-12-05 17:13:20 +01:00
Eelco Dolstra 3b9a62c964 Pass inputs to release expressions using -I
This means that you can now write (for instance)

  with <nixpkgs> { ... };

in release.nix, rather than

  { nixpkgs } :

  with nixpkgs { ... };
2011-12-05 13:08:43 +01:00
Eelco Dolstra 29846d7f2f Do incremental SVN checkouts
In hydra-evaluator, reuse an SVN working copy between runs (similar to
what we do with Git and other input types).  This reduces network
traffic in the common case.

Also, don't use nix-prefetch-svn.  It doesn't do anything useful.
2011-12-04 22:05:43 +01:00
Ludovic Courtès 6c4e83d454 More command renaming. 2011-12-02 15:58:26 +01:00
Eelco Dolstra be1935f66a Rename hydra_eval_jobs to hydra-eval-jobs 2011-11-30 18:14:48 +01:00
Eelco Dolstra 82d17a2d0b Rename hydra_*.pl to hydra-*
The underscores are ugly and the .pl extension is an implementation
detail that shouldn't be visible to the outside.

Also, get rid of the *.in files.  It's not really necessary to
generate them.  And I was always modifying the wrong file.
2011-11-30 18:14:48 +01:00
Eelco Dolstra 2c328e4b20 Forgot to change Nix to Nix::Store in one place 2011-11-30 17:22:31 +01:00
Eelco Dolstra c613b885f2 Use the new Nix Perl bindings 2011-11-30 15:25:28 +01:00
Rob Vermaas 41c649a2fd remove .hg-archival.txt in nix-prefetch-hg 2011-11-03 19:44:05 -04:00
Rob Vermaas ab81ce689d add nix-prefetch- scripts for now, were externals in svn 2011-10-28 22:12:51 -04:00
Eelco Dolstra 5f93e6437f * Update to Catalyst 5.9. 2011-10-07 13:45:23 +00:00
Rob Vermaas f34ec401ba fix for buildsteps starting at 0, probably something changed in catalyst 2011-09-08 22:48:38 +00:00
Eelco Dolstra 9f78a942bc 2011-08-19 16:09:14 +00:00
Ludovic Courtès dcbdd0ad26 hydra_build.pl: Honor `$build->timeout'. 2011-07-04 13:55:02 +00:00
Rob Vermaas 5d166150f9 using backquote as argument resulted in only first line as first argument to removeAsciiEscapes 2011-06-10 10:48:51 +00:00
Rob Vermaas 48b435c2de remove ascii escapes from log in tail page and emails 2011-06-10 09:53:15 +00:00