diff options
author | Christopher Baines <mail@cbaines.net> | 2021-11-12 14:57:56 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-11-13 10:52:02 +0000 |
commit | a6c94ad7481b55403f9dbc034929144a737e9b7d (patch) | |
tree | 06e616ea1b9c67297ac61d1e324232f03ac5178a /guix-build-coordinator/client-communication.scm | |
parent | 6e4fb6d7cd7454874d16840cb766ecfdc012e441 (diff) | |
download | build-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/client-communication.scm')
-rw-r--r-- | guix-build-coordinator/client-communication.scm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm index bf27f93..fec53e3 100644 --- a/guix-build-coordinator/client-communication.scm +++ b/guix-build-coordinator/client-communication.scm @@ -52,6 +52,7 @@ request-agents-list request-failed-builds-with-blocking-count-list send-create-agent-request + send-agent-set-active-request send-create-agent-password-request send-create-dynamic-auth-token-request send-replace-agent-tags-request)) @@ -272,6 +273,24 @@ (render-json `((error . 404)) #:code 404)))) + (('POST "agent" agent-id "active") + (let ((agent-details (datastore-find-agent datastore agent-id))) + (if agent-details + (let ((active? (match (assoc "active" body) + (("active" . active?) active?)))) + (if (boolean? active?) + (begin + (set-agent-active build-coordinator + agent-id + active?) + (render-json + `((result . success)))) + (render-json + `((error . "active must be a boolean")) + #:code 400))) + (render-json + `((error . 404)) + #:code 404)))) (('GET "builds") (let ((query-parameters (request-query-parameters request))) (render-json @@ -649,6 +668,12 @@ `((description . ,description)) '())))) +(define* (send-agent-set-active-request coordinator-uri agent-uuid active?) + (send-request coordinator-uri + 'POST + (simple-format #f "/agent/~A/active" agent-uuid) + `((active . ,active?)))) + (define (send-create-agent-password-request coordinator-uri agent-id) (send-request coordinator-uri |