2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/guix-cuirass.git synced 2023-12-14 06:03:04 +01:00
Commit graph

144 commits

Author SHA1 Message Date
Ludovic Courtès
e656f42571 base: Remove useless 'log-message' calls.
* src/cuirass/base.scm (build-packages): Remove useless 'log-message'
calls.
2018-02-05 23:01:26 +01:00
Ludovic Courtès
dd75b5bec9 http: /jobsets returns a list of jobsets.
Reported by Danny Milosavljevic.

* src/cuirass/http.scm (url-handler) <"jobsets"> Return the result of
'db-get-specifications' as-is, not just the car.
2018-02-05 23:01:26 +01:00
Ludovic Courtès
e5220dbed3 base: Log the number of builds performed.
* src/cuirass/base.scm (spawn-builds): Log the number of builds
performed, not the number of remaining builds.
2018-02-05 23:01:26 +01:00
Ludovic Courtès
161d6abef8 base: Work around Fibers I/O scheduling bug.
Works around <https://github.com/wingo/fibers/issues/19>.

The effect in practice would be that we'd usually not reach the
'close-pipe' call in 'evaluate', leaving zombie processes behind us,
never executing the continuation, and additionally spinning fast on a
sequence of epoll_wait/epoll_ctl calls.

* src/cuirass/base.scm <top level>: Monkey-patch (fibers internal).
2018-01-30 23:58:47 +01:00
Ludovic Courtès
e0588239d2 base: Make build log processing non-blocking.
We used to have 'build-derivations' write to the custom binary port
returned by 'build-event-output-port'.  However, custom binary ports
constitute continuation barriers, thereby preventing fibers from being
suspended.

To make build log processing non-blocking, we therefore invert this
inversion of control and use a suspendable I/O procedure,
'read-line/non-blocking', when reading the build log.

* src/cuirass/base.scm (read-line/non-blocking, process-build-log)
(build-derivations&): New procedures.
(%newline, build-event-output-port): Remove.
(spawn-builds): Use 'build-derivations&' instead of 'build-derivations'
with 'build-event-output-port'.
2018-01-29 18:06:47 +01:00
Ludovic Courtès
0bf61ef1ff http: Evaluate DB requests in 'non-blocking'.
* src/cuirass/http.scm (handle-builds-request): Wrap 'db-get-builds'
into 'non-blocking'.
2018-01-29 18:06:47 +01:00
Ludovic Courtès
23fecf8f3d cuirass: Log resource usage statistics regularly.
* src/cuirass/logging.scm (log-monitoring-stats): New procedure.
* bin/cuirass.in (main): Add a fiber that calls it regularly.
2018-01-29 18:06:47 +01:00
Ludovic Courtès
fcd1bc13bc http: /api/queue returns builds sorted by status.
* src/cuirass/database.scm (db-get-builds)[format-order-clause]: Add
'status+submission-time'.
* src/cuirass/http.scm (url-handler) <"queue">: Use it.
2018-01-29 18:06:47 +01:00
Ludovic Courtès
5e959dd8f2 base: 'spawn-builds' shuffles jobs.
* src/cuirass/base.scm (shuffle-jobs): New procedure.
(spawn-builds): Use it.
2018-01-29 18:06:47 +01:00
Ludovic Courtès
1e539e10cc base: 'spawn-builds' logs the beginning of each new batch.
* src/cuirass/base.scm (spawn-builds): Add 'log-message' call.
2018-01-29 18:06:47 +01:00
Ludovic Courtès
0098e613db cuirass: Add 'essential-task' and wrap the main fibers in it.
* src/cuirass/utils.scm (essential-task): New procedure.
* bin/cuirass.in (main): Wrap each fiber in 'essential-task'.
2018-01-27 16:04:31 +01:00
Ludovic Courtès
4558d1c869 http: Reject methods other than GET.
* src/cuirass/http.scm (url-handler): Check whether REQUEST's method is
'GET, and return 405 if not.
2018-01-26 22:41:22 +01:00
Ludovic Courtès
8b26874cac http: Provide the correct values for 'finished' and 'busy'.
This should placate 'guix-hydra-queued-builds', for instance, which
checks these values to choose between "Running" and "Scheduled".

* src/cuirass/http.scm (build->hydra-build): Provide the correct value
for #:finished and #:busy.
2018-01-26 18:28:32 +01:00
Ludovic Courtès
f3335e880c database: Open the database in "write-ahead log" mode.
Suggested by Ricardo Wurmus.

* src/cuirass/database.scm (wal-mode): New procedure.
(db-open): Use it.
2018-01-26 18:21:56 +01:00
Ludovic Courtès
e11bcf926d base: 'build-event-output-port' no longer reads past the buffer.
Fixes a bug whereby 'build-event-output-port' would sometimes read more
than COUNT from BV, which would usually result in a 'decoding-error'
exception from 'utf8->string'.

* src/cuirass/base.scm (build-event-output-port)[write!]: Use
'bytevector-range' to honor COUNT and OFFSET.
2018-01-26 15:56:40 +01:00
Ludovic Courtès
777ef99dd7 utils: Add 'bytevector-range'.
* src/cuirass/utils.scm (%weak-references): New variable.
(bytevector-range): New procedure.
2018-01-26 15:56:12 +01:00
Ludovic Courtès
39cf6e6ed0 base: Make repository fetching and compilation non-blocking.
Previously these calls would effectively suspend execution of all the
fibers until they had completed.

* src/cuirass/base.scm (process-specs): Wrap 'fetch-repository' and
'compile' calls in 'non-blocking'.
2018-01-26 14:43:48 +01:00
Ludovic Courtès
8d44590099 utils: Add 'non-blocking' macro.
* src/cuirass/utils.scm (%non-blocking): New procedure.
(non-blocking): New macro.
2018-01-26 14:43:29 +01:00
Ludovic Courtès
5d559f8021 logging: Add 'with-time-logging' and use it.
* src/cuirass/logging.scm (call-with-time-logging): New procedure.
(with-time-logging): New macro.
* src/cuirass/http.scm (handle-builds-request): Use it.
2018-01-26 14:17:18 +01:00
Ludovic Courtès
44f95d407c base: Do not restart builds that turn out to have succeeded already.
* src/cuirass/base.scm (restart-builds): Mark as succeeded the subset of
VALID with at least one valid output.
2018-01-26 14:06:09 +01:00
Ludovic Courtès
047e927126 base: Do not pass bogus store file names to 'db-update-build-status!'.
* src/cuirass/base.scm (handle-build-event)[valid?]: New procedure.
Use it when handling 'build-started', 'build-succeeded', and
'build-failed' events.
2018-01-26 14:04:41 +01:00
Ludovic Courtès
1af31c3200 http: Log incoming connections and requests.
* src/web/server/fiberized.scm (socket-loop): Add 'log-message' call.
* src/cuirass/http.scm (url-handler): Likewise.
2018-01-26 11:23:07 +01:00
Ludovic Courtès
77769c29e7 http: Use our own 'fiberized' web server backend.
* src/web/server/fiberized.scm: New file.
* Makefile.am (dist_pkgmodule_DATA): Add it.
* src/cuirass/http.scm (run-cuirass-server): Use it.
2018-01-25 11:54:40 +01:00
Ludovic Courtès
c2cbee8b4f base: Delete duplicate builds when restarting them.
* src/cuirass/base.scm (build-derivation=?): New procedure.
(restart-builds): Call 'delete-duplicates' on BUILDS.
2018-01-25 11:31:06 +01:00
Ludovic Courtès
71fb7eac92 base: Remove unneeded import.
* src/cuirass/base.scm: Remove unneeded #:use-module.
2018-01-25 10:41:37 +01:00
Ludovic Courtès
a97665672a http: Sort /api/latestbuilds and /api/queue by time.
* src/cuirass/database.scm (db-get-builds)[format-order-clause]: Add
'order' clauses.
* src/cuirass/http.scm (url-handler): Default to (order finish-time) for
/latestbuilds and (order submission-time) for /queue.
2018-01-25 10:39:18 +01:00
Ludovic Courtès
c4963deca1 database: Turn 'sqlite-exec' into a macro.
* src/cuirass/database.scm (%sqlite-exec): New procedure.
(sqlite-exec): New macro.
2018-01-25 10:38:53 +01:00
Ludovic Courtès
49a341866a base: Build derivations in batches.
This works around a scalability issue in guix-daemon when passing a long
list of derivations to 'build-derivations'.

* src/cuirass/base.scm (spawn-builds): New procedure.
(restart-builds, build-packages): Use it.
2018-01-25 10:36:24 +01:00
Ludovic Courtès
c9ae80a757 base: Buffer input pipe of the 'evaluate' process.
* src/cuirass/base.scm (read/non-blocking): Add 'setvbuf' call.
2018-01-25 09:48:18 +01:00
Ludovic Courtès
9c96852c60 base: Extract 'read/non-blocking'.
* src/cuirass/base.scm (read/non-blocking): New procedure.
(evaluate): Use it instead of inline code.
2018-01-25 09:47:48 +01:00
Ludovic Courtès
8675d6309b database: 'db-update-build-status!' takes a #:log-file parameter.
* src/cuirass/database.scm (sqlite-exec): Use (ice-9 format).
(db-update-build-status!): Add #:log-file parameter and honor it.
* tests/database.scm ("database")["db-update-build-status!"]: Test it.
2018-01-24 23:41:24 +01:00
Ludovic Courtès
1d7f4f07d9 base: Be more verbose about restarted builds.
* src/cuirass/base.scm (handle-build-event): Remove unused 'log-port'
parameter.
(restart-builds): Wrap 'build-derivations' in 'guard'.  Add
'log-message' calls.
2018-01-24 14:09:28 +01:00
Ludovic Courtès
b349678589 ui: Bump copyright year in '--version' output.
* src/cuirass/ui.scm (show-version): Update year.
2018-01-24 14:02:53 +01:00
Ludovic Courtès
c89c117c12 http: /build: Include the derivation.
* src/cuirass/http.scm (build->hydra-build): Add #:derivation.
2018-01-24 14:01:45 +01:00
Ludovic Courtès
c62bb26e81 base: Populate the 'Outputs' table.
Fixes a regression introduced in
d7306a4f48 whereby 'register' would pass
the empty list as #:outputs to 'db-add-build'.

* src/cuirass/base.scm (build-packages)[register]: Always include
outputs.
2018-01-24 14:00:11 +01:00
Ludovic Courtès
74f3abfba3 http: /build: Gracefully handle empty output list.
* src/cuirass/http.scm (url-handler): Add case for empty #:outputs.
2018-01-24 13:59:28 +01:00
Ludovic Courtès
4306667a49 base: Always set 'keep-going' when opening the store.
Previously 'restart-builds' would lack it, for instance.

* src/cuirass/base.scm (process-specs): Move 'set-build-options' call
to...
(with-store): ... here.
2018-01-23 23:53:41 +01:00
Ludovic Courtès
d544f3e6ba cuirass: Fix scope mismatch.
Previously STORE would be closed on the first context switch, before
'restart-builds' has completed, leading to an error (writing to a closed
port).

* src/cuirass/base.scm (restart-builds): Remove 'store' parameter.  Wrap
body in 'with-store'.
* bin/cuirass.in (main): Adjust accordingly.
2018-01-23 23:45:24 +01:00
Ludovic Courtès
496b624dda http: Implement /api/queue.
* src/cuirass/http.scm (url-handler): Add /api/queue handler.
* tests/http.scm ("http"): Add a BUILD2 and DERIVATION2, and rename
BUILD and DERIVATION accordingly.
("/build/2", "/build/2/log/raw"): Rename to /42.
("/api/queue?nr=100"): New test.
2018-01-23 23:40:07 +01:00
Ludovic Courtès
dd30a1a25c base: Restart pending builds upfront.
* src/cuirass/database.scm (db-get-builds)[format-where-clause]:
Honor (status pending) filter.
* src/cuirass/base.scm (restart-builds): New procedure.
* bin/cuirass.in (main): Fetch pending builds.  Start fiber that invokes
'restart-builds' on them.
2018-01-23 23:40:07 +01:00
Ludovic Courtès
06b8af00fb http: /api/latestbuilds only returns finished builds.
* src/cuirass/database.scm (db-get-builds)[format-where-clause]:
Honor (status done) filter.
* src/cuirass/http.scm (url-handler): Always add (status done)
to the filters passed to 'handle-builds-request'.
2018-01-23 23:39:13 +01:00
Ludovic Courtès
6fb7118839 database: Use US spelling for "canceled".
* src/cuirass/database.scm (build-status): Use US spelling for
"canceled".
2018-01-23 23:39:13 +01:00
Ludovic Courtès
fdf47d6df3 base: Add missing argument.
* src/cuirass/base.scm (build-packages): In 'filter-map' call, add
missing argument to 'db-get-build'.
2018-01-23 22:22:22 +01:00
Ludovic Courtès
f1b3a12c1d base: Use 'log-message' some more.
* src/cuirass/base.scm (build-packages): Use 'log-message' instead of
'format'.
2018-01-23 18:31:35 +01:00
Ludovic Courtès
d7306a4f48 base: Update build status and start/stop time according to build log.
Now the database is updated as things are built, rather than after the
whole batch of derivation builds has completed.

* src/cuirass/base.scm (handle-build-event): Call
'db-update-build-status!'.
(build-packages)[register]: Set #:starttime and #:stoptime to 0.
Set #:status to 'scheduled'.
Define 'build-ids' and use it to determine the overall result.
2018-01-23 18:29:38 +01:00
Ludovic Courtès
fe0a98315d database: Add 'db-update-build-status!'.
* src/cuirass/database.scm (build-status): Add 'scheduled' and
'started'.
(db-add-build): Make sure #:timestamp, #:starttime, #:stoptime, and
 #:status are integers.
(db-update-build-status!): New procedure.
* tests/database.scm ("database")["db-update-build-status!"]: New test.
2018-01-23 18:17:31 +01:00
Ludovic Courtès
b0f1a438ff Add a 'build-status' enumeration.
* src/cuirass/utils.scm (define-enumeration): New macro.
* src/cuirass/database.scm (build-status): New macro.
* src/cuirass/base.scm (build-packages)[hydra-build-status]: Remove.
Use the 'build-status' macro instead.
2018-01-23 17:37:08 +01:00
Ludovic Courtès
f92ad7001f Fix scope mismatch.
* src/cuirass/base.scm (process-specs): Add new 'with-database' within
the fiber.
2018-01-23 09:31:11 +01:00
Ludovic Courtès
ee11ba1d93 Introduce concurrency with Fibers.
* README: Mark Fibers as required.
* configure.ac: Check for Guile 2.2 only.  Check for (fibers).
* bin/cuirass.in (main): Use (fibers).  Run 'process-specs' and web
server in separate fibers.
* src/cuirass/base.scm (with-store): New macro.
(non-blocking-port): New procedure.
(evaluate): Use 'non-blocking-port'.  Use 'read-string' followed by 'read'.
(process-specs): Move 'db-add-stamp' right after 'string=?' comparison.
Run evaluation and subsequent builds in a separate fiber.
* src/cuirass/http.scm (run-cuirass-server): Pass 'fibers as the second
argument to 'run-server'.  Use 'log-message' instead of 'format'.
* src/cuirass/database.scm (with-database): Remove 'dynamic-wind'.
2018-01-22 23:39:51 +01:00
Ludovic Courtès
f9481e2222 database: Change default file name to /var/run/cuirass/cuirass.db.
* src/cuirass/database.scm (%package-database): Change default file name
from /var/cuirass.db (or similar) to /var/run/cuirass/cuirass.db.
2018-01-22 14:51:14 +01:00