[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Mathieu Othacehe |
Date: |
Wed, 13 Jan 2021 06:38:05 -0500 (EST) |
branch: master
commit 3673fc310d8eed6792af37c9449d2c0134169a71
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Wed Dec 9 12:13:20 2020 +0100
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.
---
Makefile.am | 3 ++-
src/cuirass/base.scm | 3 ++-
src/cuirass/database.scm | 7 +++++++
src/schema.sql | 1 +
src/sql/upgrade-17.sql | 5 +++++
5 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 17a73f0..72cb5a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -85,7 +85,8 @@ dist_sql_DATA = \
src/sql/upgrade-13.sql \
src/sql/upgrade-14.sql \
src/sql/upgrade-15.sql \
- src/sql/upgrade-16.sql
+ src/sql/upgrade-16.sql \
+ src/sql/upgrade-17.sql
dist_css_DATA = \
src/static/css/cuirass.css \
diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm
index c3ce900..a134440 100644
--- a/src/cuirass/base.scm
+++ b/src/cuirass/base.scm
@@ -583,7 +583,8 @@ updating the database accordingly."
(db-update-build-status! drv (build-status started)))
(log-message "bogus build-started event for '~a'" drv)))
(('build-remote drv host _ ...)
- (log-message "'~a' offloaded to '~a'" drv host))
+ (log-message "'~a' offloaded to '~a'" drv host)
+ (db-update-build-machine! drv host))
(('build-succeeded drv _ ...)
(if (valid? drv)
(begin
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 7d9427b..4ef5229 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -60,6 +60,7 @@
db-add-build-product
db-register-builds
db-update-build-status!
+ db-update-build-machine!
db-get-output
db-get-inputs
db-get-build
@@ -802,6 +803,12 @@ log file for DRV."
(#:event . ,(assq-ref status-names
status)))))))))
+(define* (db-update-build-machine! drv machine)
+ "Update the database so that DRV's machine is MACHINE."
+ (with-db-writer-worker-thread db
+ (sqlite-exec db "UPDATE Builds SET machine=" machine
+ "WHERE derivation=" drv ";")))
+
(define (db-get-output path)
"Retrieve the OUTPUT for PATH."
(with-db-worker-thread db
diff --git a/src/schema.sql b/src/schema.sql
index 6b08b7e..51d0c80 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -61,6 +61,7 @@ CREATE TABLE Builds (
evaluation INTEGER NOT NULL,
job_name TEXT NOT NULL,
system TEXT NOT NULL,
+ machine TEXT, --optional, machine performing the build.
nix_name TEXT NOT NULL,
log TEXT NOT NULL,
status INTEGER NOT NULL,
diff --git a/src/sql/upgrade-17.sql b/src/sql/upgrade-17.sql
new file mode 100644
index 0000000..f74bb92
--- /dev/null
+++ b/src/sql/upgrade-17.sql
@@ -0,0 +1,5 @@
+BEGIN TRANSACTION;
+
+ALTER TABLE Builds ADD machine TEXT DEFAULT NULL;
+
+COMMIT;