diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-13 18:49:50 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-13 20:00:05 +0100 |
commit | b62fd6fb44979569253c0ec4dae332bd3e6802f2 (patch) | |
tree | dd33099d844efa9817ca94265b241e7a2d177bca /guix-build-coordinator | |
parent | 4cd595eca0f7e203b43aeac456e3baaaca93c5c2 (diff) | |
download | build-coordinator-b62fd6fb44979569253c0ec4dae332bd3e6802f2.tar build-coordinator-b62fd6fb44979569253c0ec4dae332bd3e6802f2.tar.gz |
Support reporting setup failures to the coordinator
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r-- | guix-build-coordinator/agent-messaging/http.scm | 37 | ||||
-rw-r--r-- | guix-build-coordinator/agent.scm | 9 | ||||
-rw-r--r-- | guix-build-coordinator/coordinator.scm | 18 |
3 files changed, 61 insertions, 3 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm index 97cffdf..78c3a7b 100644 --- a/guix-build-coordinator/agent-messaging/http.scm +++ b/guix-build-coordinator/agent-messaging/http.scm @@ -43,6 +43,7 @@ submit-status submit-build-result + report-setup-failure submit-output fetch-builds-for-agent)) @@ -178,6 +179,19 @@ port. Also, the port used can be changed by passing the --port option.\n" (render-json "access denied" #:code 403)))) + (('POST "build" uuid "report-setup-failure") + (let ((agent-id-for-build + (datastore-agent-for-build datastore uuid))) + (if (authenticated? agent-id-for-build request) + (begin + (handle-setup-failure-report + datastore agent-id-for-build uuid + (json-string->scm (utf8->string body))) + (render-json + "message received")) + (render-json + "access denied" + #:code 403)))) (('PUT "build" uuid "output" output-name) (let ((agent-id-for-build (datastore-agent-for-build datastore uuid))) @@ -322,6 +336,29 @@ port. Also, the port used can be changed by passing the --port option.\n" `((Authorization . ,auth-value))))) (json-string->scm (utf8->string body)))) +(define (report-setup-failure coordinator-uri agent-uuid password + build-id report) + (define auth-value + (string-append + "Basic " + (base64-encode + (string->utf8 + (string-append agent-uuid ":" password))))) + + (define uri + (coordinator-uri-for-path + coordinator-uri + (string-append "/build/" build-id "/report-setup-failure"))) + + (let-values (((response body) + (http-request + uri + #:method 'POST + #:body (scm->json-string report) + #:headers + `((Authorization . ,auth-value))))) + (json-string->scm (utf8->string body)))) + (define (fetch-builds-for-agent coordinator-uri agent-uuid password) (define auth-value (string-append diff --git a/guix-build-coordinator/agent.scm b/guix-build-coordinator/agent.scm index ee552f1..e514373 100644 --- a/guix-build-coordinator/agent.scm +++ b/guix-build-coordinator/agent.scm @@ -49,7 +49,11 @@ (post-build uuid coordinator-uri password (assoc-ref build "uuid") derivation-name)) - (simple-format #t "failure: ~A\n" pre-build-status))))) + (begin + (simple-format #t "failure: ~A\n" pre-build-status) + (report-setup-failure coordinator-uri uuid password + (assoc-ref build "uuid") + pre-build-status)))))) builds)) (sleep 5))) @@ -99,7 +103,8 @@ (if (null? missing-inputs) '((result . success)) `((result . failure) - (missing-inputs . ,missing-inputs))))))) + (failure_reason . missing_inputs) + (missing_inputs . ,(list->vector missing-inputs)))))))) (define (perform-build derivation-name) (with-store store diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm index ee7860d..b016744 100644 --- a/guix-build-coordinator/coordinator.scm +++ b/guix-build-coordinator/coordinator.scm @@ -33,7 +33,8 @@ agent-details build-output-file-location - handle-build-result)) + handle-build-result + handle-setup-failure-report)) (define* (submit-build datastore derivation-file #:key @@ -136,3 +137,18 @@ "success" "failure") #f))) ; TODO + +(define (handle-setup-failure-report datastore agent-id build-id report-json) + (let ((failure-reason (assoc-ref report-json "failure_reason"))) + (if (string=? failure-reason "missing_inputs") + ;; For missing inputs, we need to store the inputs that were missing, + ;; so that has a special function + (datastore-store-setup-failure/missing-inputs + datastore + build-id + agent-id + (vector->list (assoc-ref report-json "missing_inputs"))) + (datastore-store-setup-failure datastore + build-id + agent-id + failure-reason)))) |