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

527 commits

Author SHA1 Message Date
Mathieu Othacehe
44df41ca7a
remote: Make sure new messages are created for each send.
* src/cuirass/remote-server.scm (zmq-start-proxy): Make sure new messages are
created for each send.
2021-02-26 12:06:46 +01:00
Mathieu Othacehe
fa191d877e
remote: Use message API.
* src/cuirass/remote-server.scm (zmq-start-proxy): Use the message API.
2021-02-26 11:39:48 +01:00
Mathieu Othacehe
e1c21224ae
remote: Use an EINTR safe message receive procedure.
* src/cuirass/remote.scm (zmq-message-receive*): New procedure.
* src/cuirass/remote-server.scm (start-fetch-worker, zmq-start-proxy): Use it.
2021-02-26 09:43:08 +01:00
Mathieu Othacehe
5f77c39f32
remote: Use copies of message contents.
* src/cuirass/remote-server.scm (zmq-start-proxy): Use copies of message
contents.
2021-02-26 09:39:22 +01:00
Mathieu Othacehe
d4acc6f566
remote: Print a warning if the poll loop is blocked.
* src/cuirass/remote-server.scm (zmq-start-proxy): Print a warning if the poll
loop is blocked for more than 5 seconds.
2021-02-26 09:35:35 +01:00
Mathieu Othacehe
d2e64f6a3d
remote: Use ZMQ message API.
* src/cuirass/remote-server.scm (start-fetch-worker): Use the message API.
2021-02-26 09:32:56 +01:00
Mathieu Othacehe
30b6dbb293
database: Ignore duplicated BuildProducts.
* src/cuirass/database.scm (db-add-build-product): Ignore duplicated
BuildProducts.
2021-02-25 09:13:47 +01:00
Mathieu Othacehe
0b19e82adc
Restart the builds on unresponsive workers.
* src/cuirass/database.scm (db-remove-unresponsive-workers): Restart the
builds that are started on unresponsive workers.
* tests/database.scm ("db-remove-unresponsive-workers"): Test it.
2021-02-24 12:42:29 +01:00
Mathieu Othacehe
370a4ad2ca
notification: Catch notifications errors.
* src/cuirass/notification.scm (notification-email, notification-mastodon):
Catch notification errors.
2021-02-24 12:10:32 +01:00
Mathieu Othacehe
76191f55c1
remote: Add log message.
* src/cuirass/remote-server.scm (run-fetch): Add log message.
2021-02-23 17:39:27 +01:00
Mathieu Othacehe
182011b60d
Keep notification text on one line.
src/cuirass/notification.scm (notification-text): Keep it on one line.
2021-02-22 16:28:16 +01:00
Mathieu Othacehe
543e26addc
Move mu-debug to parameters module.
* src/cuirass/mail.scm (mu-debug): Remove it.
* src/cuirass/utils.scm (mu-debug): Ditto.
* src/cuirass/parameters.scm (mu-debug): New variable.
* src/cuirass/remote-server.scm (start-fetch-worker): Force parameters module
load.
* tests/database.scm: Load parameters module.
2021-02-22 14:14:15 +01:00
Mathieu Othacehe
f768b53a52
Fix zabbix module.
* src/cuirass/zabbix.scm (%zabbix-uri): Remove it.
(zabbix-available?): Replace %zabbix-uri by %zabbix-url.
2021-02-22 11:57:45 +01:00
Mathieu Othacehe
27917657dd
Move mu-debug definition.
* tests/database.scm (mu-debug): Move to ...
* src/cuirass/utils.scm: ... here.
2021-02-22 11:52:24 +01:00
Mathieu Othacehe
3e65617409
Fix db-get-specifications.
* src/schema.sql: Reorder fields.
* src/cuirass/database.scm (db-get-specifications): Ditto.
2021-02-22 11:12:00 +01:00
Mathieu Othacehe
342c5edfe8
Use parameters for the Mastodon crendentials.
* src/cuirass/parameters.scm (%mastodon-instance-name, %mastodon-instance-url,
%mastodon-instance-token): New variables.
* src/cuirass/mastodon.scm (send-status): Remove "instance-name",
"instance-url" and "instance-token" parameters.
* src/cuirass/notification (notification-mastodon): Adapt accordingly.
2021-02-22 10:15:58 +01:00
Mathieu Othacehe
a0e12c382b
Make notifications field optional.
* src/cuirass/database.scm (db-add-specification): Make notifications field
optional.
2021-02-22 10:07:57 +01:00
Mathieu Othacehe
f0e0c3454f
Add parameters support.
* src/cuirass/parameters.scm: New file.
* Makefile.am (dist_pkgmodule_DATA): Add it.
* bin/cuirass.in: Add "parameters" argument.
* src/cuirass/base.scm (read-parameters): New procedure.
* src/cuirass/notification.scm (build-details-url): New procedure.
(notification-text): Use it.
* src/cuirass/rss.scm (build-details-url): New procedure.
(build->rss-item): Use it.
(rss-feed): Remove "base-url" argument.
* src/cuirass/remote-server.scm: Add "parameters" argument.
* src/cuirass/zabbix.scm (%zabbix-uri, %zabbix-uri, %zabbix-password): Remove
them.
(zabbix-request, zabbix-login): Adapt accordingly.
2021-02-22 09:05:27 +01:00
Mathieu Othacehe
f6fdb13b50
Add Mastodon support.
* src/cuirass/mastodon.scm: New file.
* Makefile.am (dist_pkgmodule_DATA): Add it.
* src/cuirass/notification.scm (notification-type): Add "mastodon".
(notification-mastodon): New procedure.
(send-notifications): Add it.
2021-02-21 10:37:11 +01:00
Mathieu Othacehe
4495e08542
Add notifications support.
* src/cuirass/mail.scm: New file.
* src/cuirass/notification.scm: New file.
* src/sql/upgrade-5.sql: New file.
* Makefile.am (dist_pkgmodule_DATA, dist_sql_DATA): Add them.
* src/schema.sql (Specifications)[notifications]: New field.
* bin/cuirass.in: Wrap inside the "with-notification" macro.
* src/cuirass/remote-server.scm (remote-server): Ditto.
* src/cuirass/database.scm (db-add-specification): Add notifications field.
(db-get-specifications): Ditto.
(db-update-build-status!): Send notifications.
* tests/mail.sh: New file.
* tests/database.scm (mu-debug, tmp-mail): New variables.
(mailer): New procedure.
(example-spec): Add an email notification.
("mail-notification"): New test case.
2021-02-21 09:55:41 +01:00
Mathieu Othacehe
aa9099e4df
Move date->rfc822-str to utils.scm.
* src/cuirass/rss.scm (date->rfc822-str): Move it to ...
* src/cuirass/utils.scm: ... here.
2021-02-21 09:15:39 +01:00
Mathieu Othacehe
422de6c3e2
Remove favicon in SVG format.
* src/static/images/icon.svg: Remove it.
* src/cuirass/http.scm (%file-white-list): Remove "images/icon.svg".
* src/cuirass/templates.scm (html-page): Remove icon.svg link.
2021-02-19 19:25:11 +01:00
Mathieu Othacehe
2ab6c4604d
Add favicon support.
* src/cuirass/http.scm (%file-white-list): Rename "logo.png" into "guix.png".
Add "icon.png" and "icon.svg".
* src/cuirass/templates.scm (html-page): Adapt it.
* src/static/images/logo.png: Rename it ...
* src/static/images/guix.png: ... into this file.
* src/static/images/icon.png: New file.
* src/static/images/icon.svg: New file.
2021-02-19 09:53:16 +01:00
Mathieu Othacehe
b200ea8947
Add a lock icon for admin actions.
* src/cuirass/templates.scm (build-details, evaluation-info-table): Add lock
icons for admin actions.
2021-02-19 09:19:09 +01:00
Mathieu Othacehe
efb140d3d5
Remove the evaluation restart dropdown arrow.
* src/cuirass/templates.scm: Remove the evaluation restart dropdown arrow.
* src/static/css/cuirass.css (no-dropdown-arrow): New rule.
2021-02-18 15:37:10 +01:00
Mathieu Othacehe
64151eee28
Add an evaluation restart button.
* src/cuirass/http.scm (url-handler): New route
"/admin/evaluation/<id>/restart".
* src/cuirass/templates.scm (evaluation-info-table): Add an evaluation restart
button.
2021-02-18 15:22:59 +01:00
Mathieu Othacehe
4a0cea2245
database: Add "db-restart-evaluation!" support.
* src/cuirass/database.scm (db-restart-evaluation!): New procedure.
* tests/database.scm (db-restart-evaluation!): New test.
2021-02-18 15:12:54 +01:00
Mathieu Othacehe
04185edba6
Allow unconditionnal build restart.
* src/cuirass/templates.scm (build-details): Allow unconditionnal build
restart.
2021-02-18 14:57:42 +01:00
Mathieu Othacehe
4e0152f7a4
Add a build restart button.
* src/cuirass/http.scm (url-handler): New route "/admin/build/<id>/restart".
* src/cuirass/template.scm (build-details): Add a "restart" button.
2021-02-18 14:53:52 +01:00
Mathieu Othacehe
31342ff80f
database: Add db-restart-build! support.
* src/cuirass/database.scm (db-restart-build!): New procedure.
* tests/database.scm (db-restart-build!): New test.
2021-02-17 19:11:38 +01:00
Mathieu Othacehe
860fffa260
remote: Set the locale only in the publish thread.
* src/cuirass/remote-server.scm (remote-server): Move the locale setup to the
publish thread.
* src/cuirass/remote-worker.scm (remote-worker): Ditto.
* src/cuirass/remote.scm (publish-server): Set the locale.
2021-02-17 17:19:27 +01:00
Mathieu Othacehe
ea01201ccd
remote: Use a default locale.
* src/cuirass/remote-server.scm (remote-server): Use a default locale.
* src/cuirass/remote-worker.scm (remote-worker): Ditto.
2021-02-17 14:23:05 +01:00
Mathieu Othacehe
a5f0a5f04d
Remove outdated commentary.
* src/cuirass/database.scm (db-register-builds): Remove commentary.
2021-02-14 15:32:49 +01:00
Mathieu Othacehe
83f33cdbb4
remote: Remove address argument. 2021-02-12 14:39:12 +01:00
Mathieu Othacehe
b191a2a5f6
Pick the first worker build.
* src/cuirass/templates.scm (machine-status): Pick the first worker build if
multiple builds are started on the same worker.
2021-02-10 18:27:06 +01:00
Mathieu Othacehe
e77a0a94fe
database: Fix db-get-build-percentage query.
* src/cuirass/database.scm (db-get-build-percentage): Consider both successful
and failing builds.
2021-02-10 18:23:41 +01:00
Mathieu Othacehe
38701970eb
remote: Discover server log-port and publish-port without Avahi.
* src/cuirass/remote.scm (zmq-server-info, zmq-worker-request-info-message):
New procedures.
* src/cuirass/remote-server.scm (%log-port, %publish-port): New parameters.
(read-worker-exp): Handle 'worker-request-info message.
(remote-server): Set the new parameters.
* src/cuirass/remote-worker.scm (start-worker): Rename "server" argument. Send
a 'worker-request-info message to discover the server log port and publish
port.
(remote-worker): Adapt it.
2021-02-10 17:37:37 +01:00
Mathieu Othacehe
5e5850533e
Add Zabbix command line argument.
* bin/cuirass.in: Add "--zabbix-uri" argument.
* src/cuirass/zabbix.scm (%zabbix-uri): Export it.
2021-02-08 13:31:28 +01:00
Mathieu Othacehe
ac98f81671
Add Zabbix support. 2021-02-08 12:26:35 +01:00
Mathieu Othacehe
7aa1d9156a
Return worker last-seen field as integer.
* src/cuirass/database.scm (db-get-worker, db-get-workers): Return last-seen
field as integer.
2021-02-07 18:16:57 +01:00
Mathieu Othacehe
eea91d9a63
remote: Swallow zlib errors.
* src/cuirass/remote.scm (swallow-zlib-error): New macro.
(send-log): Use it.
2021-02-06 09:42:54 +01:00
Mathieu Othacehe
75c44bb579
remote: Stop polling once the workers are started.
* src/cuirass/remote-worker.scm (remote-worker): Stop the avahi poll loop once
the workers are started.
2021-02-06 09:41:11 +01:00
Mathieu Othacehe
485ed9182b
Fix weather query.
* src/cuirass/database.scm (db-get-builds): Add missing parens.
2021-02-02 14:48:36 +01:00
Mathieu Othacehe
8bdc7ee535
Fix weather value.
* src/cuirass/database.scm (db-get-builds): Fix weather value.
* tests/http.scm (build-query-result): Adapt it.
2021-02-02 14:29:16 +01:00
Mathieu Othacehe
6bd940fc24
Add RSS link to the home page.
* src/cuirass/templates.scm (specifications-table): Add RSS link.
2021-02-02 14:11:55 +01:00
Mathieu Othacehe
4e98cb02dd
Add RSS link to the evaluation page.
* src/cuirass/templates.scm (evaluation-info-table): Add RSS link.
2021-02-02 14:09:35 +01:00
Mathieu Othacehe
7cf304f754
Fix RSS specification handling.
* src/cuirass/http.scm (url-handler): Pass the specification to
"db-get-builds" procedure.
2021-02-02 13:57:28 +01:00
Mathieu Othacehe
2befdc6a0d
Use a XML header for the RSS feed.
* src/cuirass/http.scm (respond-xml): New procedure.
(url-handler): Use it for the RSS feed.
2021-02-02 13:06:38 +01:00
Mathieu Othacehe
f8ddf8ca09
Add basic RSS support.
* src/cuirass/rss.scm: New file.
* Makefile.am (dist_pkgmodule_DATA): Add it.
* src/cuirass/http.scm (url-handler): Add "/events/rss" route.
2021-02-02 11:58:29 +01:00
Mathieu Othacehe
4f4d7ff7db
Move weather field to database.
* src/sql/upgrade-4.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds)[weather]: New field.
(Builds_weather_evaluation): New index.
* src/cuirass/database.scm (db-get-last-status): New procedure.
(db-update-build-status!): Use it and update the new weather field.
(db-get-builds): Adapt it.
* tests/http.scm (build-query-result): Ditto.
2021-02-02 11:56:28 +01:00
Mathieu Othacehe
f6662298c9
Move weather icon next to build status icon.
* src/cuirass/templates.scm (build-details): Move the weather icon.
2021-02-01 19:02:27 +01:00
Mathieu Othacehe
79b77b4377
remote: Start workers only once.
* src/cuirass/remote-worker.scm (%workers-started?): New variable.
(remote-worker): Use it to start workers only once.
2021-02-01 18:16:23 +01:00
Mathieu Othacehe
a57b066e4f
Add build history support.
* src/cuirass/database.scm (db-get-builds): Add "oldevaluation" filter.
* src/cuirass/templates.scm (build-details): Add "history" argument.
* src/cuirass/http.scm (url-handler): Adapt it.
2021-02-01 17:49:00 +01:00
Mathieu Othacehe
f9a5cbe0dd
Add weather support in build details.
* src/cuirass/templates.scm (build-details): Display weather.
2021-02-01 15:15:13 +01:00
Mathieu Othacehe
d7282c05c0
Add build weather support.
* src/cuirass/database.scm (build-weather): New macro.
(build-status->weather): New procedure.
(db-get-builds): Return the build weather using the new procedure.
* src/cuirass/http.scm (build->hydra-build): Also return the weather.
* src/cuirass/templates.scm (weather-class, weather-title): New procedures.
(build-eval-table): Display the weather.
* tests/database.scm ("db-get-build weather"): New tests.
* tests/http.scm (build-query-result): Adapt it.
2021-02-01 14:27:24 +01:00
Mathieu Othacehe
54244e6e97
database: Fix "db-update-build-status!".
* src/cuirass/database.scm (db-update-build-status): Only consider evaluations
that happened before the current one. This is useful when updating the build
status of old evaluations.
2021-02-01 12:30:38 +01:00
Mathieu Othacehe
7697735fce
database: Fix "db-get-worker".
* src/cuirass/database.scm (db-get-worker): Handle the case where no worker
were found.
2021-02-01 12:22:56 +01:00
Mathieu Othacehe
da93cb96ff
Fix SQL syntax.
* src/sql/upgrade-3.sql: Fix syntax.
2021-02-01 12:06:05 +01:00
Mathieu Othacehe
74c1a94a4d
Introduce build "last_status" field.
* src/sql/upgrade-3.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds)[last_status]: New field.
* src/cuirass/database.scm (db-update-build-status!): Honor it.
(db-get-builds): Return it.
* tests/database.scm ("db-update-build-status!"): New test.
2021-02-01 11:45:10 +01:00
Mathieu Othacehe
158966dca0
Fix /api/latestbuilds ordering.
Evaluations are added sequentially to database but builds are not always
registered nor performed in order. This means that a build corresponding to an
older evaluation can be returned first if it was completed last. Order by
descending evaluation id to prevent it.

* src/cuirass/database.scm (db-get-builds): Add "evaluation" order.
* src/cuirass/http.scm (url-handler): Order latestbuilds by descending
evaluation number.
2021-01-31 21:09:17 +01:00
Mathieu Othacehe
e9e0943945
Remove workers hash table.
* src/cuirass/database.scm (db-add-worker): Rename ...
(db-add-or-update-worker): ... into this new procedure.
(db-get-worker, db-remove-unresponsive-workers): New procedures.
* src/cuirass/remote-server.scm (%workers): Remove it.
(pop-build): Adapt it.
(remove-unresponsive-workers!): Remove it.
(read-worker-exp): Adapt it.
(zmq-start-proxy): Ditto.
* tests/database.scm ("db-add-worker"): Rename ...
("db-add-or-update-worker"): ... into this new test.
("db-get-worker", "db-remove-unresponsive-workers"): New tests.
2021-01-31 10:31:01 +01:00
Mathieu Othacehe
b993f3d433
Truncate long lines.
* src/cuirass/templates (workers-status): Truncate long lines.
2021-01-30 20:50:51 +01:00
Mathieu Othacehe
4370acce19
Sort workers consistently.
* src/cuirass/templates.scm (workers-status): Sort workers consistently.
2021-01-30 18:10:31 +01:00
Mathieu Othacehe
6c0298e12c
Remove left-over procedure.
* src/cuirass/templates.scm (workers-status): Remove unused "build-row"
procedure.
2021-01-30 18:02:35 +01:00
Mathieu Othacehe
5f770638bb
Fix workers display.
* src/cuirass/templates.scm (workers-status): Handle the case where multiple
builds are started on a worker.
2021-01-30 16:55:22 +01:00
Mathieu Othacehe
6838ec2eac
database: Prevent division by zero.
* src/cuirass/database.scm (db-get-build-percentage): Prevent division by zero.
2021-01-30 16:14:04 +01:00
Mathieu Othacehe
158dd2bd42
Fix build duration display.
* src/cuirass/templates.scm (build-details): Fix build duration display.
2021-01-30 16:11:50 +01:00
Mathieu Othacehe
154653b4c8
database: Fix starttime update.
* src/cuirass/database.scm (db-update-build-status!): Set starttime when the
build status is "submitted".
2021-01-30 16:10:50 +01:00
Mathieu Othacehe
7a7c26c628
Sort machines consistently.
* src/cuirass/templates.scm (workers-status): Sort machines.
2021-01-30 15:54:29 +01:00
Mathieu Othacehe
1e8d075d70
Improve workers page.
* src/cuirass/templates.scm (workers-status): Improve display.
* src/cuirass/http.scm (url-handler): Adapt it.
2021-01-30 14:24:29 +01:00
Mathieu Othacehe
213683ad27
database: Add "db-get-build-percentage".
* src/cuirass/database.scm (db-get-build-percentage): New procedure.
* tests/database.scm ("db-get-build-percentage"): New test.
2021-01-30 14:23:29 +01:00
Mathieu Othacehe
1271b11725
Add machine field to Worker table.
* src/sql/upgrade-2.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Workers): Add "machine field".
* src/cuirass/database.scm (db-get-builds): Return "worker" field.
(db-add-worker): Honor new "machine" field.
(db-get-workers): Ditto.
* src/cuirass/remote-worker.scm (remote-worker): Adapt it.
* src/cuirass/remote.scm (<worker>)[machine]: New field.
(worker-machine): New procedure.
(worker->sexp, sexp->worker): Adapt accordingly.
(generate-worker-name): Ditto.
* tests/database.scm (%dummy-worker): Add "machine" field.
2021-01-30 14:18:59 +01:00
Mathieu Othacehe
68532aee90
Fix logging.
* src/cuirass/remote-server.scm (remote-server): Have stdout/stderr
line-buffered.
* src/cuirass/remote-worker.scm (remote-worker): Ditto.
* src/cuirass/remote.scm (publish-server): Discard publish logs.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2021-01-28 16:16:43 +01:00
Mathieu Othacehe
dea5707750
database: Fix search pagination.
* src/cuirass/database.scm (db-get-builds-by-search): Fix pagination.
2021-01-17 19:47:54 +01:00
Mathieu Othacehe
e61e7a5ca4
Fix tests.
* tests/database.scm (db-init): Force database creation.
* tests/http.scm (db-init): Ditto.
* tests/metrics (db-init): Ditto.
2021-01-17 12:05:31 +01:00
Mathieu Othacehe
53d8b66bf9
database: Fix regression.
Fix a regression introduced by cbc462679d.

* src/cuirass/database.scm (db-get-builds): Collect BuildProducts id field.
2021-01-17 11:53:47 +01:00
Mathieu Othacehe
508ed333a6
Fix concurrent database creation. 2021-01-15 15:07:15 +01:00
Mathieu Othacehe
cbc462679d
Switch to PostegreSQL. 2021-01-11 12:28:13 +01:00
Mathieu Othacehe
ca7a7ca989
Add remote build support.
* src/cuirass/remote.scm: New file.
* src/cuirass/remote-server.scm: New file.
* src/cuirass/remote-worker.scm: New file.
* bin/remote-server.in: New file.
* bin/remote-worker.in: New file.
* Makefile.am (bin_SCRIPTS): Add new binaries,
(dist_pkgmodule_DATA): add new files,
(EXTRA_DIST): add new binaries,
(bin/remote-server, bin/remote-worker): new targets.
* .gitignore: Add new binaries.
* bin/cuirass.in (%options): Add "--build-remote" option,
(show-help): document it,
(main): honor it.
* src/cuirass/base.scm (with-build-offload-thread): New macro,
(%build-remote?, %build-offload-channel): new parameters,
(make-build-offload-thread): new procedure,
(build-derivations/offload): new procedure,
(restart-builds): use it to offload builds when %build-remote? is set,
(build-packages): ditto.
2021-01-06 21:06:04 +01:00
Mathieu Othacehe
f65ef23ce6
Remove debug message.
src/cuirass/base.scm (build-packages): Remove debug message that can be
inaccurate if queue-size is superior to 1.
2020-12-09 12:37:16 +01:00
Mathieu Othacehe
3673fc310d
Save the build machine.
* src/sql/upgrade-17.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds): Add "machine" field.
* src/cuirass/database.scm (db-update-build-machine!): New procedure.
* src/cuirass/base.scm (handle-build-event): Use it to record the machine
performing the build.
2020-12-09 12:16:48 +01:00
Mathieu Othacehe
697fa14584
Add "queue size" argument.
* bin/cuirass.in (%options): Add "queue-size" argument.
(show-help): Document it.
(main): Honor it.
* src/cuirass/database.scm (%db-writer-queue-size): New parameter,
(with-queue-writer-worker): use it.
2020-12-08 11:46:07 +01:00
Mathieu Othacehe
ac2187ff6b
http: Add /api/evaluation route.
* src/cuirass/database.scm (db-get-evaluation): New procedure.
* src/cuirass/http.scm (url-handler): Add "/api/evaluation" route.
2020-12-07 15:34:29 +01:00
Mathieu Othacehe
ad44a9bb02
http: Add evaluation field to hydra-build.
* src/cuirass/http.scm (build->hydra-build): Add "evaluation" field.
2020-12-07 15:13:09 +01:00
Christopher Baines
b2c77dd626 database: Fix using sqlite-reset in a few queries.
Rather than calling sqlite-reset before reading the rows, call sqlite-reset
after. I think this is important to stop SQLite getting stuck because the
statement is still live even though it's not being read from after these
procedures return.

Assuming I've got the ordering right, I think using sqlite-fold-right directly
is simpler code as well.

* src/cuirass/database.scm (db-get-builds-by-search, format-build-products,
db-get-events): Rewrite fetching result rows.
2020-12-07 09:44:51 +00:00
Christopher Baines
23d75284bf database: Remove redundant reset calls.
sqlite-prepare will reset cached statements before returning them, so these
sqlite-reset calls are redundant.

* src/cuirass/database.scm (db-get-builds-query-min, db-get-builds-query-max):
Remove sqlite-reset calls.
2020-12-07 09:44:48 +00:00
Christopher Baines
068ad30a27 database: Don't finalise cached statements.
All these statements are cached, but that's pointless if they're finalized
after use, because they'll need recreating on next use.

* src/cuirass/database.scm (%sqlite-exec, db-get-builds-query-min,
db-get-builds-query-max): Replace sqlite-finalize with sqlite-reset.
2020-12-07 09:44:46 +00:00
Mathieu Othacehe
38f48c80da
database: Fix builds pagination.
* src/cuirass/database.scm (db-get-builds): Fix pagination.
2020-12-02 17:18:15 +01:00
Mathieu Othacehe
e35eee6a80
database: Rewrite db-get-builds-max and db-get-builds-min.
* src/cuirass/database.scm (db-get-builds-min, db-get-builds-max): Rewrite SQL
queries without nesting.
2020-12-02 17:18:15 +01:00
Mathieu Othacehe
fd432b8e8f
Use specification for periodic builds.
When the periodic argument is passed to a job, it will be registered only if
the time difference between the current time and the registration time of the
last build is greater than the specified period. Make sure that the last job
that is searched is part of the same specification.

* src/sql/upgrade-16.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds_job_name_timestamp): New index.
* src/cuirass/database.scm (db-get-time-since-previous-build): Add
"specification" argument,
(db-register-builds): pass it.
2020-11-25 16:49:22 +01:00
Mathieu Othacehe
e0f97e475f
Fix interactive checkout.
This is a work-around: https://issues.guix.gnu.org/44742.

* src/cuirass/base.scm (fetch-inputs): Set "current-error-port" parameter to a
void port to prevent the fetch progression bar to appear.
2020-11-25 10:46:03 +01:00
Mathieu Othacehe
053f92273a
Add periodical build support.
* src/cuirass/database.scm (db-get-time-since-previous-build): New procedure,
(db-register-builds): if the period argument is set, only register builds
which last registration is older than the specified period.
2020-11-25 10:43:18 +01:00
Mathieu Othacehe
3fd0eb154f
Revert "Use a non-blocking socket for store communication."
This reverts commit 387909454c that causes:

2020-11-02T11:05:08 fatal: uncaught exception 'wrong-type-arg' in 'build' fiber!
2020-11-02T11:05:08 exception arguments: ("struct-vtable" "Wrong type argument in position 1 (expecting struct): ~S" (#f) (#f))
In ice-9/boot-9.scm:
  1731:15 12 (with-exception-handler #<procedure 7fb1a93f9930 at ic…> …)
  1736:10 11 (with-exception-handler _ _ #:unwind? _ # _)
    718:2 10 (call-with-prompt ("break") #<procedure 7fb1ab76f440 a…> …)
    718:2  9 (call-with-prompt ("continue") #<procedure 7fb1ab77084…> …)
In ice-9/eval.scm:
    619:8  8 (_ #(#(#<directory (guile-user) 7fb1ac680f00> #<var…> …)))
In srfi/srfi-1.scm:
    634:9  7 (for-each #<procedure 7fb1a9525900 at cuirass/base.scm…> …)
In ice-9/boot-9.scm:
  1731:15  6 (with-exception-handler #<procedure 7fb1a95a94e0 at ic…> …)
  1669:16  5 (raise-exception _ #:continuable? _)
  1764:13  4 (_ #<&compound-exception components: (#<&assertion-fail…>)
In cuirass/utils.scm:
    319:8  3 (_ _ . _)
In ice-9/boot-9.scm:
  1731:15  2 (with-exception-handler #<procedure 7fb1ab2e3720 at ic…> …)
In cuirass/utils.scm:
   320:22  1 (_)
In unknown file:
           0 (make-stack #t)
ERROR: In procedure make-stack:
In procedure struct-vtable: Wrong type argument in position 1 (expecting struct): #f
2020-11-02 11:05:50 +01:00
Ludovic Courtès
387909454c
Use a non-blocking socket for store communication.
Set the store socket as non-blocking so that fibers communicating with the
store don't get blocked as described here: https://issues.guix.gnu.org/43565.

* src/cuirass/base.scm (with-store): Set the store socket as non-blocking.
(build-derivations&): Unset current-read-waiter and current-write-waiter.
2020-10-27 19:00:31 +01:00
Mathieu Othacehe
f141dd205a
Use with-db-writer-worker-thread/force macro.
* src/cuirass/database.scm (db-register-builds): Use
"with-db-writer-worker-thread/force" macro.
2020-10-15 10:45:13 +02:00
Mathieu Othacehe
df2d13621f
Use the writer worker for all write queries.
* .dir-locals.el: Add "with-queue-writer-worker".
* bin/cuirass.in: Modify "with-queue-writer-worker" scope to include the
web-server operations.
* src/cuirass/database.scm (with-db-writer-worker-thread): Export it.
(with-db-writer-worker-thread/force): New macro.
(db-add-input, db-add-checkout, db-add-specification, db-remove-specification,
db-add-evaluation, db-abort-pending-evaluations, db-set-evaluation-status,
db-set-evaluation-time, db-add-output, db-add-build-product, db-add-event,
db-delete-events-with-ids-<=-to): Use "with-db-writer-worker-thread" or
"with-db-writer-worker-thread/force" instead of "with-db-worker-thread".
* src/cuirass/metrics.scm (db-update-metrics): Ditto.
* tests/database.scm ("db-init"): Set "%db-writer-channel".
* tests/http.scm ("db-init"): Ditto.
* tests/metrics.scm ("db-init"): Ditto.
2020-10-15 09:53:53 +02:00
Mathieu Othacehe
a0e70b9d51
Remove unused procedure.
* src/cuirass/base.scm (cancel-old-builds): Remove it.
2020-10-14 18:53:31 +02:00
Mathieu Othacehe
38ee2c5b5b
Fix tests.
This is a follow-up of b67f38a7b9.

* src/cuirass/database.scm (catch-sqlite-error): New macro.
(SQLITE_CONSTRAINT_PRIMARYKEY, SQLITE_CONSTRAINT_UNIQUE, %db-writer-channel):
New variables.
* tests/database.scm (with-temporary-database): Set "%db-writer-channel".
(db-add-build-with-fixed-output): Catch sqlite error.
(db-get-pending-derivations): Do not add builds with duplicated outputs.
2020-10-14 16:28:59 +02:00
Mathieu Othacehe
65e3624bf8
Optimize SQLite database.
* src/cuirass/database.scm (set-db-options): Optimize database parameters.
2020-10-14 14:22:17 +02:00
Mathieu Othacehe
b67f38a7b9
Queue write operations.
SQLite only allows one concurrent write query operation. Having multiple
database workers calling "db-update-build-status!", will thus increase worker
starvation. Every write operation will also be done is a single transaction.

For those reasons, create a database worker dedicated to write queries. Have
this worker queue work and issue all the queued work queries in a single
transaction.

* .dir-locals.el: Add with-db-writer-worker-thread.
* src/cuirass/database.scm (with-queue-writer-worker): Rename
"with-registration-workers" macro.
(%db-writer-channel): Rename "%db-registration-channel" variable.
(with-queue-writer-worker): Rename "with-registration-workers".
(db-register-builds): Use "with-db-writer-worker-thread" instead of
"with-db-registration-worker-thread".
(db-update-build-status!): Ditto
* src/cuirass/utils.scm (make-worker-thread-channel): Add "queue-size" and
"queue-proc" arguments.
(call-with-worker-thread): Add "options" argument.
* bin/cuirass.in (main): Use "with-queue-writer-worker" instead of
"with-registration-workers". Modify the macro scope to include all the
possible write operations.
2020-10-14 14:15:09 +02:00