aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-03-24 09:45:10 +0000
committerChristopher Baines <mail@cbaines.net>2023-03-24 09:51:28 +0000
commitd6ae42f19691267d915cd66174436f33debabec0 (patch)
treebdcac7bd56cb06a2a62631e72564c7a51716cbf3
parent024761d432ff84e197b49846c71ac34f5703df38 (diff)
downloadbuild-coordinator-d6ae42f19691267d915cd66174436f33debabec0.tar
build-coordinator-d6ae42f19691267d915cd66174436f33debabec0.tar.gz
Add processor count to the agent status
This is useful when interpreting the load information.
-rw-r--r--guix-build-coordinator/agent-messaging/http.scm3
-rw-r--r--guix-build-coordinator/agent-messaging/http/server.scm6
-rw-r--r--guix-build-coordinator/coordinator.scm6
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm18
-rw-r--r--sqitch/pg/deploy/agent_status_add_processor_count.sql7
-rw-r--r--sqitch/pg/revert/agent_status_add_processor_count.sql7
-rw-r--r--sqitch/pg/verify/agent_status_add_processor_count.sql7
-rw-r--r--sqitch/sqitch.plan1
-rw-r--r--sqitch/sqlite/deploy/agent_status_add_processor_count.sql15
-rw-r--r--sqitch/sqlite/revert/agent_status_add_processor_count.sql7
-rw-r--r--sqitch/sqlite/verify/agent_status_add_processor_count.sql7
11 files changed, 72 insertions, 12 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index 992768f..adc8102 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -264,7 +264,8 @@
interface
(string-append "/agent/" (slot-ref interface 'agent-uuid))
#:method 'PUT ; TODO Should be PATCH
- #:body `((status . ,status)
+ #:body `((status . ,status)
+ (processor_count . ,(current-processor-count))
,@(if 1min-load-average
`((load_average
. (("1" . ,1min-load-average))))
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm
index 016cecf..2928513 100644
--- a/guix-build-coordinator/agent-messaging/http/server.scm
+++ b/guix-build-coordinator/agent-messaging/http/server.scm
@@ -253,10 +253,12 @@ port. Also, the port used can be changed by passing the --port option.\n"
(status (assoc-ref json-body "status"))
(1min-load-average (and=> (assoc-ref json-body "load_average")
(lambda (load-average)
- (assoc-ref load-average "1")))))
+ (assoc-ref load-average "1"))))
+ (processor-count (assoc-ref json-body "processor_count")))
(update-agent-status build-coordinator uuid
- status 1min-load-average))
+ status 1min-load-average
+ processor-count))
(render-json
(agent-details datastore uuid)))
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm
index 22d97f8..5960031 100644
--- a/guix-build-coordinator/coordinator.scm
+++ b/guix-build-coordinator/coordinator.scm
@@ -805,12 +805,14 @@
(trigger-build-allocation coordinator))
(define (update-agent-status coordinator agent-uuid
- status 1min-load-average)
+ status 1min-load-average
+ processor-count)
(datastore-update-agent-status
(build-coordinator-datastore coordinator)
agent-uuid
status
- 1min-load-average))
+ 1min-load-average
+ processor-count))
(define (trigger-build-allocation build-coordinator)
((build-coordinator-allocator-thread build-coordinator)))
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index c2dc3de..36a9e5c 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -687,7 +687,7 @@ UPDATE agents SET active = :active WHERE id = :uuid"
(sqlite-prepare
db
"
-SELECT status, load_average_1min, timestamp
+SELECT status, load_average_1min, timestamp, processor_count
FROM agent_status
WHERE agent_id = :agent_id"
#:cache? #t)))
@@ -697,19 +697,22 @@ WHERE agent_id = :agent_id"
#:agent_id agent-id)
(match (sqlite-step statement)
- (#(status 1min_load_average timestamp)
+ (#(status 1min_load_average timestamp
+ processor_count)
(sqlite-reset statement)
`((status . ,status)
(1min_load_average . ,1min_load_average)
- (timestamp . ,timestamp)))
+ (timestamp . ,timestamp)
+ (processor_count . ,processor_count)))
(_ #f))))))
(define-method (datastore-update-agent-status
(datastore <sqlite-datastore>)
agent-uuid
status
- 1min-load-average)
+ 1min-load-average
+ processor-count)
(call-with-worker-thread
(slot-ref datastore 'worker-writer-thread-channel)
(lambda (db)
@@ -729,14 +732,15 @@ DELETE FROM agent_status WHERE agent_id = :uuid"
(sqlite-prepare
db
"
-INSERT INTO agent_status (agent_id, status, load_average_1min)
- VALUES (:uuid, :status, :load)"
+INSERT INTO agent_status (agent_id, status, load_average_1min, processor_count)
+ VALUES (:uuid, :status, :load, :processor_count)"
#:cache? #t)))
(sqlite-bind-arguments statement
#:uuid agent-uuid
#:status status
- #:load 1min-load-average)
+ #:load 1min-load-average
+ #:processor_count processor-count)
(sqlite-step statement)
(sqlite-reset statement))))
diff --git a/sqitch/pg/deploy/agent_status_add_processor_count.sql b/sqitch/pg/deploy/agent_status_add_processor_count.sql
new file mode 100644
index 0000000..558dd89
--- /dev/null
+++ b/sqitch/pg/deploy/agent_status_add_processor_count.sql
@@ -0,0 +1,7 @@
+-- Deploy guix-build-coordinator:agent_status_add_processor_count to pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/pg/revert/agent_status_add_processor_count.sql b/sqitch/pg/revert/agent_status_add_processor_count.sql
new file mode 100644
index 0000000..da6e669
--- /dev/null
+++ b/sqitch/pg/revert/agent_status_add_processor_count.sql
@@ -0,0 +1,7 @@
+-- Revert guix-build-coordinator:agent_status_add_processor_count from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/pg/verify/agent_status_add_processor_count.sql b/sqitch/pg/verify/agent_status_add_processor_count.sql
new file mode 100644
index 0000000..bdd3f8e
--- /dev/null
+++ b/sqitch/pg/verify/agent_status_add_processor_count.sql
@@ -0,0 +1,7 @@
+-- Verify guix-build-coordinator:agent_status_add_processor_count on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;
diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan
index 6ed7af9..1591710 100644
--- a/sqitch/sqitch.plan
+++ b/sqitch/sqitch.plan
@@ -42,3 +42,4 @@ derivation_output_details 2022-07-07T18:12:27Z Chris <chris@felis> # Add derivat
build_counts 2022-10-28T09:36:25Z Chris <chris@felis> # Add builds_counts
build_results_counts 2022-10-28T09:36:35Z Chris <chris@felis> # Add build_results_counts
replace_agent_status 2023-03-22T14:17:35Z Chris <chris@felis> # Replace agent_status
+agent_status_add_processor_count 2023-03-24T09:28:47Z Chris <chris@felis> # Add agent_status.processor_count
diff --git a/sqitch/sqlite/deploy/agent_status_add_processor_count.sql b/sqitch/sqlite/deploy/agent_status_add_processor_count.sql
new file mode 100644
index 0000000..5618809
--- /dev/null
+++ b/sqitch/sqlite/deploy/agent_status_add_processor_count.sql
@@ -0,0 +1,15 @@
+-- Deploy guix-build-coordinator:agent_status_add_processor_count to sqlite
+
+BEGIN;
+
+DROP TABLE agent_status;
+
+CREATE TABLE agent_status (
+ agent_id TEXT PRIMARY KEY ASC REFERENCES agents (id),
+ timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ status TEXT NOT NULL,
+ load_average_1min INTEGER,
+ processor_count INTEGER
+);
+
+COMMIT;
diff --git a/sqitch/sqlite/revert/agent_status_add_processor_count.sql b/sqitch/sqlite/revert/agent_status_add_processor_count.sql
new file mode 100644
index 0000000..5f94a64
--- /dev/null
+++ b/sqitch/sqlite/revert/agent_status_add_processor_count.sql
@@ -0,0 +1,7 @@
+-- Revert guix-build-coordinator:agent_status_add_processor_count from sqlite
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/sqlite/verify/agent_status_add_processor_count.sql b/sqitch/sqlite/verify/agent_status_add_processor_count.sql
new file mode 100644
index 0000000..f478a17
--- /dev/null
+++ b/sqitch/sqlite/verify/agent_status_add_processor_count.sql
@@ -0,0 +1,7 @@
+-- Verify guix-build-coordinator:agent_status_add_processor_count on sqlite
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;