From 25ffc57864dbf34ca58741f89c1f790dbde6702f Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Wed, 28 Dec 2022 15:19:29 +0100 Subject: [PATCH 2/2] substitutes: Log the failing queries. * guix/substitutes.scm (%debug?): New variable. (handle-narinfo-response): Log the failing queries if the %debug? parameter is set. --- guix/substitutes.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/guix/substitutes.scm b/guix/substitutes.scm index 9014cf61ec..819eb2c73e 100644 --- a/guix/substitutes.scm +++ b/guix/substitutes.scm @@ -90,6 +90,12 @@ (define %narinfo-cache-directory (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 (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 +230,15 @@ (define (handle-narinfo-response request response port result) (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. + (when (%debug?) + (let ((baking? + (assoc-ref (response-headers response) 'x-baking))) + (display + (format #f "could not fetch ~a~a ~a~a~%" + url path code + (if baking? " (baking)" ""))))) (if len (get-bytevector-n port len) (read-to-eof port)) -- 2.38.1