aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-12-16 06:43:33 +0000
committerChristopher Baines <mail@cbaines.net>2020-12-16 06:43:33 +0000
commit9c6746610a21d30aae183373dc73477074718f33 (patch)
tree0946a0b5cbab4d028b7ec149a6655fc788d03cd5 /scripts
parent7bd76b74e0e57045b3af23683d3ca72803bfd7be (diff)
downloadbuild-coordinator-9c6746610a21d30aae183373dc73477074718f33.tar
build-coordinator-9c6746610a21d30aae183373dc73477074718f33.tar.gz
Guard against starting the coordinator for unknown commands
Diffstat (limited to 'scripts')
-rw-r--r--scripts/guix-build-coordinator.in73
1 files changed, 42 insertions, 31 deletions
diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in
index 39c6dad..a5e97bd 100644
--- a/scripts/guix-build-coordinator.in
+++ b/scripts/guix-build-coordinator.in
@@ -417,36 +417,47 @@ canceled?: ~A
(append %service-option-defaults
%base-option-defaults)
arguments))
- (metrics-registry (make-metrics-registry
- #:namespace
- "guixbuildcoordinator"))
- (datastore (database-uri->datastore
- (assq-ref opts 'database)
- #:metrics-registry metrics-registry))
- (hooks
- `((build-submitted . ,(assq-ref opts 'build-submitted-hook))
- (build-started . ,(assq-ref opts 'build-started-hook))
- (build-success . ,(assq-ref opts 'build-success-hook))
- (build-failure . ,(assq-ref opts 'build-failure-hook))
- (build-missing-inputs . ,(assq-ref opts 'build-missing-inputs-hook))))
- (hooks-with-defaults
- `(,@(filter cdr hooks)
- ,@(remove (match-lambda
- ((name . _) (assq-ref hooks name)))
- %default-hooks)))
- (build-coordinator (make-build-coordinator
- #:datastore datastore
- #:hooks hooks-with-defaults
- #:metrics-registry metrics-registry
- #:allocation-strategy
- (assq-ref opts 'allocation-strategy))))
+ (unknown-arguments
+ (or (assq-ref opts 'arguments)
+ '())))
- (parameterize ((%show-error-details
- (assoc-ref opts 'show-error-details)))
+ (unless (null? unknown-arguments)
+ (simple-format (current-error-port)
+ "unknown arguments: ~A\n"
+ unknown-arguments)
- (run-coordinator-service
- build-coordinator
- #:update-datastore? (assoc-ref opts 'update-database)
- #:pid-file (assq-ref opts 'pid-file)
- #:agent-communication-uri (assq-ref opts 'agent-communication)
- #:client-communication-uri (assq-ref opts 'client-communication))))))
+ (exit 1))
+
+ (let* ((metrics-registry (make-metrics-registry
+ #:namespace
+ "guixbuildcoordinator"))
+ (datastore (database-uri->datastore
+ (assq-ref opts 'database)
+ #:metrics-registry metrics-registry))
+ (hooks
+ `((build-submitted . ,(assq-ref opts 'build-submitted-hook))
+ (build-started . ,(assq-ref opts 'build-started-hook))
+ (build-success . ,(assq-ref opts 'build-success-hook))
+ (build-failure . ,(assq-ref opts 'build-failure-hook))
+ (build-missing-inputs . ,(assq-ref opts 'build-missing-inputs-hook))))
+ (hooks-with-defaults
+ `(,@(filter cdr hooks)
+ ,@(remove (match-lambda
+ ((name . _) (assq-ref hooks name)))
+ %default-hooks)))
+ (build-coordinator (make-build-coordinator
+ #:datastore datastore
+ #:hooks hooks-with-defaults
+ #:metrics-registry metrics-registry
+ #:allocation-strategy
+ (assq-ref opts 'allocation-strategy))))
+
+ (parameterize ((%show-error-details
+ (assoc-ref opts 'show-error-details)))
+
+ (run-coordinator-service
+ build-coordinator
+ #:update-datastore? (assoc-ref opts 'update-database)
+ #:pid-file (assq-ref opts 'pid-file)
+ #:agent-communication-uri (assq-ref opts 'agent-communication)
+ #:client-communication-uri (assq-ref opts 'client-communication)))))))