summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2022-12-28 15:19:29 +0100
committerMathieu Othacehe <othacehe@gnu.org>2023-01-07 14:27:17 +0100
commit8b665a4ff3aa01d689fdbdd8e6757c13e2180507 (patch)
tree994ccc30ec24eca3daeca713b54387dead5d67d2
parent62f9f345250d5e037634e7762f6404d5e868c179 (diff)
substitutes: Log the failing queries.
* guix/substitutes.scm (%debug?): New variable. (handle-narinfo-response): Log the failing queries if the %debug? parameter is set.
-rw-r--r--guix/substitutes.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/guix/substitutes.scm b/guix/substitutes.scm
index 9014cf61ec..edff84aac3 100644
--- a/guix/substitutes.scm
+++ b/guix/substitutes.scm
@@ -90,6 +90,16 @@
(string-append %state-directory "/substitute/cache"))
(string-append (cache-directory #:ensure? #f) "/substitute")))
+(define %debug?
+ ;; Enable debug mode by setting the GUIX_SUBSTITUTE_DEBUG environmnent
+ ;; variable.
+ (make-parameter
+ (getenv "GUIX_SUBSTITUTE_DEBUG")))
+
+(define-syntax-rule (debug fmt args ...)
+ (when (%debug?)
+ (format #t fmt args ...)))
+
(define (narinfo-cache-file cache-url path)
"Return the name of the local file that contains an entry for PATH. The
entry is stored in a sub-directory specific to CACHE-URL."
@@ -224,6 +234,13 @@ if file doesn't exist, and the narinfo otherwise."
(let* ((path (uri-path (request-uri request)))
(hash-part (basename
(string-drop-right path 8)))) ;drop ".narinfo"
+ ;; Log the failing queries and indicate if it failed because the
+ ;; narinfo is being baked.
+ (let ((baking?
+ (assoc-ref (response-headers response) 'x-baking)))
+ (debug "could not fetch ~a~a ~a~a~%"
+ url path code
+ (if baking? " (baking)" "")))
(if len
(get-bytevector-n port len)
(read-to-eof port))