Subject: [PATCH cuirass] remote-server: Disable url-fetch* fallback when triggering substitutes.
From: vicvbcun <[email-masked]>
To: [email-masked]
Cc: Ludovic Courtès <[email-masked]>
Date: Thu, 23 Jan 2025 12:36:10 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

If an output is larger than the configured cache bypass threshold and the
substitute hasn't already been baked, guix publish returns a 404 response and
schedules baking.  This error code causes `url-fetch*' to instead try fetching
the narinfo from the Internet Archive.  Suppress this fallback behaviour as
the sole purpose is triggering the baking of substitutes.

* src/cuirass/scripts/remote-server.scm (trigger-substitutes-baking): Bind
`%download-methods' to the empty list befor calling `url-fetch*'.
---
Hello Guix!

I've stumbled upon this as somehow (presumably due to the way my server is
connected to the IPv4 internet) the remote server would block indefinitely
reading a reply from web.archive.org, needing to be restarted.  This patch
fixes (or at least hides) this behaviour.  Anyway, since there is no point
to the fallback in the first place, I think this merits a patch regardless
of that.

 src/cuirass/scripts/remote-server.scm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/cuirass/scripts/remote-server.scm b/src/cuirass/scripts/remote-server.scm
index caeb8ed..fb99551 100644
--- a/src/cuirass/scripts/remote-server.scm
+++ b/src/cuirass/scripts/remote-server.scm
@@ -45,7 +45,8 @@
   #:use-module ((guix build utils) #:select (mkdir-p
                                              strip-store-file-name
                                              call-with-temporary-output-file))
-  #:autoload   (guix build download) (url-fetch)
+  #:autoload   (guix build download) (%download-methods
+                                      url-fetch)
   #:autoload   (gcrypt pk-crypto) (read-file-sexp)
   #:use-module (simple-zmq)
   #:use-module (srfi srfi-1)
@@ -255,7 +256,13 @@ Start a remote build server.\n") (%program-name))
     (log-debug "Bake: ~a" narinfo-url)
     (call-with-temporary-output-file
      (lambda (tmp-file port)
-       (url-fetch* narinfo-url tmp-file)))))
+       (parameterize
+           ;; XXX: guix publish returns a 404 response when the output is
+           ;; large and has not already been baked.  By default, this causes
+           ;; `url-fetch*' to fall back to the Internet Archive.  Disable
+           ;; this.
+           ((%download-methods '()))
+         (url-fetch* narinfo-url tmp-file))))))
 
 (define (add-to-store drv outputs url)
   "Add the OUTPUTS that are available from the substitute server at URL to the

base-commit: 6b499a74999fc05e19e349e2c8ca8e7f417147f5
-- 
2.47.1