aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/datastore
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2021-11-12 14:57:56 +0000
committerChristopher Baines <mail@cbaines.net>2021-11-13 10:52:02 +0000
commita6c94ad7481b55403f9dbc034929144a737e9b7d (patch)
tree06e616ea1b9c67297ac61d1e324232f03ac5178a /guix-build-coordinator/datastore
parent6e4fb6d7cd7454874d16840cb766ecfdc012e441 (diff)
downloadbuild-coordinator-a6c94ad7481b55403f9dbc034929144a737e9b7d.tar
build-coordinator-a6c94ad7481b55403f9dbc034929144a737e9b7d.tar.gz
Support activating and deactivating agents
Not sure these are the best terms to use, but I want a way to pause agents, effectively removing them from the build allocation plan. This is mostly motivated by the lack of disk space on bayfront, as deactivating agents provides a way to stop the system from filling up with builds, but I think there's more general uses as well.
Diffstat (limited to 'guix-build-coordinator/datastore')
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm26
1 files changed, 26 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index 89fea58..94a3154 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -47,6 +47,7 @@
datastore-list-build-outputs
datastore-new-agent
datastore-list-agents
+ datastore-set-agent-active
datastore-find-agent
datastore-find-agent-by-name
datastore-insert-dynamic-auth-token
@@ -593,6 +594,31 @@ SELECT id, name, description, active FROM agents ORDER BY id"
agents)))))
+(define-method (datastore-set-agent-active
+ (datastore <sqlite-datastore>)
+ agent-uuid
+ active?)
+ (unless (boolean? active?)
+ (error "datastore-set-agent-active called with non-boolean"))
+
+ (call-with-worker-thread
+ (slot-ref datastore 'worker-writer-thread-channel)
+ (lambda (db)
+ (let ((statement
+ (sqlite-prepare
+ db
+ "
+UPDATE agents SET active = :active WHERE id = :uuid"
+ #:cache? #f)))
+
+ (sqlite-bind-arguments statement
+ #:uuid agent-uuid
+ #:active (if active? 1 0))
+
+ (sqlite-step statement)
+ (sqlite-finalize statement))))
+ active?)
+
(define-method (datastore-new-agent-password
(datastore <sqlite-datastore>)
agent-uuid