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