From de4a303beedc3414d7ca9a8ad948d0fc676e7e77 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 9 Apr 2022 22:36:16 +0100 Subject: Add a timeout for submitting outputs --- guix-build-coordinator/agent-messaging/http.scm | 45 +++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm index 21b64d1..2c07336 100644 --- a/guix-build-coordinator/agent-messaging/http.scm +++ b/guix-build-coordinator/agent-messaging/http.scm @@ -339,27 +339,30 @@ (seek file-port bytes SEEK_SET) (log 'INFO "resuming upload from byte " bytes)) - (let-values (((response body) - (call-with-streaming-http-request - (uri #:resume? (integer? bytes)) - (lambda (port) - (with-time-logging - (simple-format #f "sending ~A" file) - (dump-port file-port port - #:buffer-size 65536))) - #:headers `((Authorization . ,auth-value)) - #:method (if bytes 'POST 'PUT) - #:report-bytes-sent report-bytes-sent))) - (when (>= (response-code response) 400) - (raise-exception - (make-exception-with-message - (coordinator-handle-failed-request - log - 'PUT - (uri-path - (uri #:resume? (integer? bytes))) - response - body)))))))))) + (with-timeout (* 20 60) ; 20 minutes + (raise-exception + (make-exception-with-message "timeout submitting output")) + (let-values (((response body) + (call-with-streaming-http-request + (uri #:resume? (integer? bytes)) + (lambda (port) + (with-time-logging + (simple-format #f "sending ~A" file) + (dump-port file-port port + #:buffer-size 65536))) + #:headers `((Authorization . ,auth-value)) + #:method (if bytes 'POST 'PUT) + #:report-bytes-sent report-bytes-sent))) + (when (>= (response-code response) 400) + (raise-exception + (make-exception-with-message + (coordinator-handle-failed-request + log + 'PUT + (uri-path + (uri #:resume? (integer? bytes))) + response + body))))))))))) #:times 100 #:delay (random 15))) -- cgit v1.2.3