Commit Graph

9 Commits

Author SHA1 Message Date
Ludovic Courtès
af91c2d540
substitute: Gracefully handle TLS termination while fetching narinfos.
Fixes <https://issues.guix.gnu.org/62476>.

* guix/substitutes.scm (call-with-connection-error-handling): Add
'gnutls-error case.
2023-03-27 18:48:51 +02:00
Ludovic Courtès
ae587c2ef0
guix: Strip #:use-module lists.
This was obtained by setting up this environment:

  guix shell -D guix --with-input=guile@3.0.9=guile-next \
    --with-commit=guile-next=e2ed33ef0445c867fe56c247054aa67e834861f2
    -- make -j5

then adding 'unused-module' to (@@ (guix build compiler) %warnings),
building, and checking all the "unused module" warnings and removing
those that were definitely unused.
2023-03-13 15:08:33 +01:00
Mathieu Othacehe
8b665a4ff3
substitutes: Log the failing queries.
* guix/substitutes.scm (%debug?): New variable.
(handle-narinfo-response): Log the failing queries if the %debug? parameter is
set.
2023-01-07 14:27:17 +01:00
Ludovic Courtès
e68466de12
substitutes: Build correct narinfo URLs for cache URLs without trailing slash.
Fixes <https://issues.guix.gnu.org/51441>.
Reported by Z572 <873216071@qq.com> and Peng Mei Yu <pengmeiyu@riseup.net>.

Previously, passing '--substitute-urls=https://mirror.sjtu.edu.cn/guix',
without a trailing slash, would fail due to incorrectly constructed
narinfo URLs.  Users would have to explicitly add a trailing slash.

* guix/substitutes.scm (narinfo-request): Ensure BASE has a trailing
slash.
2021-12-12 00:27:53 +01:00
Hartmut Goebel
ccdf7b8006
substitutes: Properly construct URLs.
Use relative URIs and "resolve-uri-reference" (which implements the algorithm
specified in RFC 3986 section 5.2.2) for building the URL, instead of just
appending strings. This avoids issued if the cache-url ends with a slash.

* guix/substitutes.scm (narinfo-request): Use resolve-uri-reference for
  constructing the url.
2021-07-16 19:36:11 +02:00
Ludovic Courtès
dc3504913d
substitutes: Reduce negative TTLs.
* guix/substitutes.scm (%narinfo-negative-ttl): Change to 15mn.
(%narinfo-transient-error-ttl): Halve.
2021-05-16 23:28:11 +02:00
Christopher Baines
c5ab78f90b
substitutes: lookup-narinfos: Return the number of requests made.
As an additional value, in addition to the narinfos.  This value is useful in
the weather script for reporting how many requests to the substitute server
were made.

* guix/substitutes.scm (lookup-narinfos): Additionally return the number of
requests made.
2021-03-17 20:46:20 +00:00
Christopher Baines
fd5b77503e
guix: substitutes: Make progress reporting configurable.
Rather than always outputting to (current-error-port) in
lookup-narinfos (which is called from within lookup-narinfos/diverse), take a
procedure which should return a progress reporter, and defer any output to
that.

As this is now general purpose code, make the default behaviour to output
nothing. Maintain the current behaviour of the substitute script by moving the
progress reporter implementation there, and passing it in when calling
lookup-narinfos/diverse.

These changes should be generally useful, but I'm particularly looking at
getting guix weather to do progress reporting differently, with this new
flexibility.

* guix/substitutes.scm (fetch-narinfos): Take a procedure to make a
progress-reporter, and use that rather than the hardcoded behaviour.
(lookup-narinfos): Add #:make-progress-reporter keyword argument, and pass
this through to fetch-narinfos.
(lookup-narinfos/diverse): Add a #:make-progress-reporter keyword argument,
and pass this through to lookup-narinfos.
* guix/scripts/substitute.scm (process-query): Pass a progress-reporter to
lookup-narinfos/diverse.
2021-03-09 20:19:33 +00:00
Christopher Baines
112692c0d5
guix: Split (guix substitutes) from (guix scripts substitute).
This means there's a module for working with substitutes, rather than all the
code sitting in the script. The need for this can be seen with the weather and
challenge scripts, that now don't have to use code from the substitute script,
but can instead use the substitute module.

The separation here between the actual functionality of the substitute script
and the underlying functionality used both there and elsewhere should make
maintenance easier moving forward.

This commit just moves code, none of the code should have been changed
significantly.

* guix/scripts/substitute.scm (%narinfo-cache-directory, %narinfo-ttl,
%narinfo-negative-ttl, %narinfo-transient-error-ttl, %unreachable-hosts): Move
variables to guix/substitutes.scm.
(narinfo-cache-file, cached-narinfo, cache-narinfo!, narinfo-request,
read-to-eof, call-with-connection-error-handling, fetch-narinfos,
lookup-narinfos, lookup-narinfos/diverse): Move procedures to
guix/substitutes.scm.
* guix/substitutes.scm: New file.
* Makefile.am: Add it.
* guix/narinfo.scm: Remove redundant module.
* guix/scripts/challenge.scm: Change (guix scripts substitute) to (guix
substitutes).
* guix/scripts/weather.scm: Change (guix scripts substitute) to (guix
substitutes).
2021-03-05 21:06:03 +00:00