Fixing backblaze connection test in prod setups.

This commit is contained in:
2026-07-15 12:19:18 -07:00
parent 7236c8854d
commit 321578a74a

View File

@@ -742,10 +742,10 @@ h1, h2, h3, h4, h5, h6 {
"--password-file" "/restic-password"
"--json")))
(else
(process* "timeout"
`("--preserve-status" "8s" "restic" "cat" "config"
(process* "/bin/timeout"
`("--preserve-status" "8s" "/bin/restic" "cat" "config"
"--repo" ,(conc "s3:" bucket-url)
"--password-file" password-path
"--password-file" ,(conc (current-directory) "/" password-path)
"--json")
`(("AWS_ACCESS_KEY_ID" . ,key-id)
("AWS_SECRET_ACCESS_KEY" . ,application-key)))))
@@ -760,11 +760,14 @@ h1, h2, h3, h4, h5, h6 {
(if (= wait-pid 0) ;; wait-pid is 0 until the process has finished
(if (< i 12) ;; 12s timeout
(loop (+ i 1))
(error "timeout trying to connect to to backblaze"))
`((success . #f)
(errors ((message . "timeout trying to connect to backblaze")))))
(if exit-normal
(let ((res (with-input-from-port in-port read-json))
(err (with-input-from-port err-port read-json)))
(if res
;; status 10 is what is returned if we can connect but the repo
;; is not initialized yet
(if (or res (and err (= status 10)))
`((success . #t)
(result . ,res))
`((success . #f)
@@ -774,7 +777,8 @@ h1, h2, h3, h4, h5, h6 {
))))))))
(thread-join! thread))))
(lambda ()
(delete-file password-path)))))
(handle-exceptions exn 'ignore
(delete-file password-path))))))
(define (deployment-directory user-id instance-id)
(string-append "deploy-" (number->string user-id) "-" (->string instance-id)))