diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-13 12:29:51 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-13 12:29:51 +0100 |
commit | 3a050050a561850e116e5389d138abdb57052e19 (patch) | |
tree | 96a9297aa5d6281476ab2e53526e44a339d7e241 /guix-build-coordinator | |
parent | 95e7246ade7a106651466bcc10a377fe7ea4af33 (diff) | |
download | build-coordinator-3a050050a561850e116e5389d138abdb57052e19.tar build-coordinator-3a050050a561850e116e5389d138abdb57052e19.tar.gz |
Add datastore-agent-for-build
So that the coordinator can find out what agent is assigned a build.
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r-- | guix-build-coordinator/datastore.scm | 1 | ||||
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore.scm b/guix-build-coordinator/datastore.scm index 7503110..fc21674 100644 --- a/guix-build-coordinator/datastore.scm +++ b/guix-build-coordinator/datastore.scm @@ -13,6 +13,7 @@ datastore-agent-password-exists? datastore-list-unprocessed-builds datastore-list-agent-builds + datastore-agent-for-build datastore-replace-build-allocation-plan datastore-allocate-builds-to-agent datastore-list-allocation-plan-builds) diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index befa560..67e9dde 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -19,6 +19,7 @@ datastore-agent-password-exists? datastore-list-unprocessed-builds datastore-list-agent-builds + datastore-agent-for-build datastore-replace-build-allocation-plan datastore-allocate-builds-to-agent datastore-list-allocation-plan-builds)) @@ -342,6 +343,32 @@ WHERE allocated_builds.agent_id = :agent_id"))) builds))))) +(define-method (datastore-agent-for-build + (datastore <sqlite-datastore>) + build-id) + (call-with-worker-thread + (slot-ref datastore 'worker-thread-channel) + (lambda (db) + (let ((statement + (sqlite-prepare + db + " +SELECT agent_id +FROM allocated_builds +WHERE build_id = :build_id"))) + + (sqlite-bind-arguments + statement + #:build_id build-id) + + (let ((result + (match (sqlite-step statement) + (#(agent-id) agent-id) + (#f #f)))) + (sqlite-reset statement) + + result))))) + (define (db-open database) (define flags (list SQLITE_OPEN_READWRITE |