aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix-build-coordinator/agent.scm19
-rw-r--r--guix-build-coordinator/coordinator.scm5
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm27
-rw-r--r--sqitch/pg/deploy/add_builds_end_time.sql7
-rw-r--r--sqitch/pg/revert/add_builds_end_time.sql7
-rw-r--r--sqitch/pg/verify/add_builds_end_time.sql7
-rw-r--r--sqitch/sqitch.plan1
-rw-r--r--sqitch/sqlite/deploy/add_builds_end_time.sql7
-rw-r--r--sqitch/sqlite/revert/add_builds_end_time.sql7
-rw-r--r--sqitch/sqlite/verify/add_builds_end_time.sql7
10 files changed, 78 insertions, 16 deletions
diff --git a/guix-build-coordinator/agent.scm b/guix-build-coordinator/agent.scm
index 0f9eaff..bbca1e3 100644
--- a/guix-build-coordinator/agent.scm
+++ b/guix-build-coordinator/agent.scm
@@ -64,7 +64,9 @@
build-id derivation-name)
(report-build-start coordinator-uri uuid password
build-id)
- (let ((result (perform-build derivation-name)))
+ (let* ((result (perform-build derivation-name))
+ ;; TODO Check this handles timezones right
+ (end-time (localtime (current-time) "UTC")))
(retry-on-error
(lambda ()
(let ((log-file (derivation-log-file derivation-name)))
@@ -87,7 +89,8 @@
post-build-failure)
uuid coordinator-uri password
build-id
- derivation-name)))
+ derivation-name
+ end-time)))
(begin
(simple-format #t "~A: failure: ~A\n" build-id pre-build-status)
(report-setup-failure coordinator-uri uuid password
@@ -246,15 +249,16 @@
#f)))))
(define (post-build-failure uuid coordinator-uri password
- build-id derivation)
+ build-id derivation end-time)
(simple-format #t "build ~A failed, reporting to coordinator\n"
build-id)
(submit-build-result coordinator-uri uuid password
build-id
- '((result . failure))))
+ `((result . failure)
+ (end_time . ,(strftime "%F %T" end-time)))))
(define (post-build-success uuid coordinator-uri password
- build-id derivation)
+ build-id derivation end-time)
(simple-format #t "build ~A successful, reporting to coordinator\n"
build-id)
(let ((output-details
@@ -284,5 +288,6 @@
(simple-format #t "finished submitting outputs, reporting result\n")
(submit-build-result
coordinator-uri uuid password build-id
- `((result . success)
- (outputs . ,(list->vector output-details))))))
+ `((result . success)
+ (end_time . ,(strftime "%F %T" end-time))
+ (outputs . ,(list->vector output-details))))))
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm
index f5be80d..2ceac56 100644
--- a/guix-build-coordinator/coordinator.scm
+++ b/guix-build-coordinator/coordinator.scm
@@ -420,7 +420,10 @@
(if success?
(vector->list
(assoc-ref result-json "outputs"))
- #f))
+ #f)
+ ;; TODO Check what the value of this is
+ (assoc-ref result-json "end_time"))
+
#t))))
(define (handle-build-start-report datastore
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index db9f807..a5c50e4 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -490,7 +490,8 @@ SELECT agent_id, result, COUNT(*) FROM build_results GROUP BY agent_id, result")
agent-id
result
failure-reason
- output-metadata)
+ output-metadata
+ end-time)
(define (insert-build-result db build-id agent-id result failure-reason)
(sqlite-exec
db
@@ -518,12 +519,17 @@ DELETE FROM allocated_builds WHERE build_id = '"
agent-id
"'")))
- (define (mark-build-as-processed db build-id)
+ (define (mark-build-as-processed db build-id end-time)
(sqlite-exec
db
(string-append
"
-UPDATE builds SET processed = 1 WHERE uuid = '" build-id "'")))
+UPDATE builds
+SET processed = 1 "
+ (if end-time
+ (string-append ", end_time = '" end-time "'")
+ "") "
+WHERE uuid = '" build-id "'")))
(define (store-output-metadata
db
@@ -586,7 +592,7 @@ VALUES "
(lambda (db)
(insert-build-result db build-id agent-id result failure-reason)
(remove-build-allocation db build-id agent-id)
- (mark-build-as-processed db build-id)
+ (mark-build-as-processed db build-id end-time)
;; This logic should be part of the coordinator, but it's here to be
;; inside the transaction
(handle-inserting-unprocessed-hook-event db build-id result)
@@ -789,7 +795,7 @@ GROUP BY derivations.system")))
(sqlite-prepare
db
"
-SELECT uuid, derivation_name, priority, processed, created_at
+SELECT uuid, derivation_name, priority, processed, created_at, end_time
FROM builds
WHERE uuid = :uuid")))
@@ -799,7 +805,7 @@ WHERE uuid = :uuid")))
(let ((result
(match (sqlite-step statement)
- (#(uuid derivation_name priority processed created_at)
+ (#(uuid derivation_name priority processed created_at end_time)
`((uuid . ,uuid)
(derivation-name . ,derivation_name)
(priority . ,priority)
@@ -810,7 +816,11 @@ WHERE uuid = :uuid")))
(error "unknown processed value"))))
(created-at . ,(if (string? created_at)
(match (strptime "%F %T" created_at)
- ((parts _) parts))
+ ((parts . _) parts))
+ #f))
+ (end-time . ,(if (string? end_time)
+ (match (strptime "%F %T" end_time)
+ ((parts . _) parts))
#f)))))))
(sqlite-reset statement)
@@ -839,7 +849,8 @@ WHERE build_id = :build_id")))
(#(agent_id result failure_reason)
`((agent_id . ,agent_id)
(result . ,result)
- (failure_reason . ,failure_reason))))))
+ (failure_reason . ,failure_reason)))
+ (#f #f))))
(sqlite-reset statement)
result)))))
diff --git a/sqitch/pg/deploy/add_builds_end_time.sql b/sqitch/pg/deploy/add_builds_end_time.sql
new file mode 100644
index 0000000..4fe125a
--- /dev/null
+++ b/sqitch/pg/deploy/add_builds_end_time.sql
@@ -0,0 +1,7 @@
+-- Deploy guix-build-coordinator:add_builds_end_time to pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/pg/revert/add_builds_end_time.sql b/sqitch/pg/revert/add_builds_end_time.sql
new file mode 100644
index 0000000..78fdb86
--- /dev/null
+++ b/sqitch/pg/revert/add_builds_end_time.sql
@@ -0,0 +1,7 @@
+-- Revert guix-build-coordinator:add_builds_end_time from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/pg/verify/add_builds_end_time.sql b/sqitch/pg/verify/add_builds_end_time.sql
new file mode 100644
index 0000000..68b2224
--- /dev/null
+++ b/sqitch/pg/verify/add_builds_end_time.sql
@@ -0,0 +1,7 @@
+-- Verify guix-build-coordinator:add_builds_end_time on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;
diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan
index e0712ce..213f01c 100644
--- a/sqitch/sqitch.plan
+++ b/sqitch/sqitch.plan
@@ -18,3 +18,4 @@ more_indexes_on_builds_and_derivation_inputs 2020-05-11T08:38:28Z Christopher Ba
build_tags 2020-05-31T13:54:41Z Christopher Baines <mail@cbaines.net> # Support tagging builds
builds_created_at 2020-06-27T18:30:32Z Christopher Baines <mail@cbaines.net> # Add builds.created_at
build_starts 2020-06-27T20:23:38Z Christopher Baines <mail@cbaines.net> # Add build_starts table
+add_builds_end_time 2020-06-27T20:58:01Z Christopher Baines <mail@cbaines.net> # Add builds.end_time field
diff --git a/sqitch/sqlite/deploy/add_builds_end_time.sql b/sqitch/sqlite/deploy/add_builds_end_time.sql
new file mode 100644
index 0000000..c7e4619
--- /dev/null
+++ b/sqitch/sqlite/deploy/add_builds_end_time.sql
@@ -0,0 +1,7 @@
+-- Deploy guix-build-coordinator:add_builds_end_time to sqlite
+
+BEGIN;
+
+ALTER TABLE builds ADD COLUMN end_time TEXT;
+
+COMMIT;
diff --git a/sqitch/sqlite/revert/add_builds_end_time.sql b/sqitch/sqlite/revert/add_builds_end_time.sql
new file mode 100644
index 0000000..216ac9a
--- /dev/null
+++ b/sqitch/sqlite/revert/add_builds_end_time.sql
@@ -0,0 +1,7 @@
+-- Revert guix-build-coordinator:add_builds_end_time from sqlite
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/sqlite/verify/add_builds_end_time.sql b/sqitch/sqlite/verify/add_builds_end_time.sql
new file mode 100644
index 0000000..4cc73db
--- /dev/null
+++ b/sqitch/sqlite/verify/add_builds_end_time.sql
@@ -0,0 +1,7 @@
+-- Verify guix-build-coordinator:add_builds_end_time on sqlite
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;