aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-03-22 15:52:17 +0000
committerChristopher Baines <mail@cbaines.net>2023-03-22 15:56:13 +0000
commit725548d302b42f7850d6574d311435f57dcd246c (patch)
treea17bb19bf61fea3d41eb39b5035bdf19602f846f
parentbaa9cd85812ffe0fc44cb5a25f04fed6a962f2dd (diff)
downloadbuild-coordinator-725548d302b42f7850d6574d311435f57dcd246c.tar
build-coordinator-725548d302b42f7850d6574d311435f57dcd246c.tar.gz
Include the allocation plan size in the coordinator state
-rw-r--r--guix-build-coordinator/client-communication.scm61
1 files changed, 34 insertions, 27 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm
index 7e84199..e5ab41c 100644
--- a/guix-build-coordinator/client-communication.scm
+++ b/guix-build-coordinator/client-communication.scm
@@ -500,33 +500,40 @@
(datastore-call-with-transaction
datastore
(lambda (_)
- `((state_id . ,(build-coordinator-get-state-id build-coordinator))
- (agents . ,(list->vector
- (map
- (lambda (agent-details)
- (let ((agent-id
- (assq-ref agent-details 'uuid)))
- `(,@agent-details
- (last_status_update
- . ,(datastore-find-agent-status datastore
- agent-id))
- (requested_systems
- . ,(list->vector
- (datastore-agent-requested-systems
- datastore
- agent-id)))
- (builds
- . ,(list->vector
- (map
- (lambda (build)
- `(,@build
- (tags . ,(datastore-fetch-build-tags
- datastore
- (assq-ref build 'uuid)))))
- (datastore-list-agent-builds
- datastore
- (assq-ref agent-details 'uuid))))))))
- (datastore-list-agents datastore)))))))))
+ (let ((allocation-plan-counts
+ (datastore-count-build-allocation-plan-entries
+ datastore)))
+ `((state_id . ,(build-coordinator-get-state-id build-coordinator))
+ (agents . ,(list->vector
+ (map
+ (lambda (agent-details)
+ (let ((agent-id
+ (assq-ref agent-details 'uuid)))
+ `(,@agent-details
+ (last_status_update
+ . ,(datastore-find-agent-status datastore
+ agent-id))
+ (requested_systems
+ . ,(list->vector
+ (datastore-agent-requested-systems
+ datastore
+ agent-id)))
+ (allocation_plan
+ . ((count . ,(or (assoc-ref allocation-plan-counts
+ agent-id)
+ 0))))
+ (builds
+ . ,(list->vector
+ (map
+ (lambda (build)
+ `(,@build
+ (tags . ,(datastore-fetch-build-tags
+ datastore
+ (assq-ref build 'uuid)))))
+ (datastore-list-agent-builds
+ datastore
+ (assq-ref agent-details 'uuid))))))))
+ (datastore-list-agents datastore))))))))))
(('GET "events")
(list (build-response
#:code 200