[PATCH] Allow defining multiple substituters

  • Open
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Maxime Devos
  • Tony Olagbaiye
Owner
unassigned
Submitted by
Maxime Devos
Severity
normal
M
M
Maxime Devos wrote on 26 Feb 2021 18:41
(address . guix-patches@gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
c9f5535b93c0e0e832017e8f6f4ec3182fdad971.camel@telenet.be
Hi Guix,

This patch series is my suggestion for allowing
multiple "substitution methods" or "substituters"
as I call them. Currently, only a method for HTTP/S
is defined, though I hope it will be a good basis
for a common framework for substitutes over GNUnet
and IPFS.

Extending "guix-service-type" to allow configuration
of substitution method is left for later.

Any questions, remarks?

Greetings,
Maxime
Attachment: file
-----BEGIN PGP SIGNATURE-----

iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYDky4BccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7g6wAQCNF3Ghq8OzJ8cZEwYsXAkCl6pC
jHL5zHBsvbyMFvmprwEA3N/M6vVhe9E9O5Y8XqBPIdWO4AuoImfH2uq9tvlcNA0=
=EgwA
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 2 Mar 2021 21:37
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 46800@debbugs.gnu.org)
87o8g1thpr.fsf@gnu.org
Hi Maxime,

Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (7 lines)
> This patch series is my suggestion for allowing
> multiple "substitution methods" or "substituters"
> as I call them. Currently, only a method for HTTP/S
> is defined, though I hope it will be a good basis
> for a common framework for substitutes over GNUnet
> and IPFS.

Thanks for working on this!

As discussed on IRC, the daemon used to have support for multiple
substituters, but as a built-in C++ interface, which I removed in
f6919ebdc6b0ce0286814cc6ab0564b1a4c67f5f.

The Scheme interface you propose is of course nicer :-), but I’m still
not sure it’s necessary. For example, in the IPFS prototype at
https://issues.guix.gnu.org/33899, IPFS support goes hand in hand with
HTTP support: narinfos are retrieved over HTTP and nars can be retrieved
over IPFS, or HTTP. Likewise with “digests”:

Another issue is that it may be that, instead of letting users choose
one method and stick to it, we’d rather let them choose a policy that
can automatically pick the “best” method, dynamically adjusting choices.

All in all, I would prefer to wait until there’s a clear need for this
abstraction.

WDYT?

Thanks,
Ludo’.
M
M
Maxime Devos wrote on 4 Mar 2021 08:48
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 46800@debbugs.gnu.org)
865935bc92c080a9ab79044856b01654fcc4410b.camel@telenet.be
On Tue, 2021-03-02 at 21:37 +0100, Ludovic Courtès wrote:
Toggle quote (17 lines)
> Hi Maxime,
>
> Maxime Devos <maximedevos@telenet.be> skribis:
>
> > This patch series is my suggestion for allowing
> > multiple "substitution methods" or "substituters"
> > as I call them. Currently, only a method for HTTP/S
> > is defined, though I hope it will be a good basis
> > for a common framework for substitutes over GNUnet
> > and IPFS.
>
> Thanks for working on this!
>
> As discussed on IRC, the daemon used to have support for multiple
> substituters, but as a built-in C++ interface, which I removed in
> f6919ebdc6b0ce0286814cc6ab0564b1a4c67f5f.

Was there any particular reason this support was removed, beyond
moving from C++ to Scheme and the absence of any alternative substituters?

Toggle quote (6 lines)
> The Scheme interface you propose is of course nicer :-), but I’m still
> not sure it’s necessary. For example, in the IPFS prototype at
> <https://issues.guix.gnu.org/33899>;, IPFS support goes hand in hand with
> HTTP support: narinfos are retrieved over HTTP and nars can be retrieved
> over IPFS, or HTTP.

About X going hand-in-hand with Y:

Note that fetching narinfos, or fetching the nar itself are separated
A method can support both procedures, or just one of them (or none,
but that's rather useless.)

Users (well, the system administrator) can choose multiple methods, which
will be each fetch narinfos after each other & combine the
results into
one large list (or maybe some other data structure, I don't recall the
details), and each substituter will be asked to produce
a nar until a substituter
succeeds or all have said "sorry, I don't have that nar".

(That's different from C++ interface for multiple substituters I think, where
the methods are only tried sequentialy, they aren't combined.)

In case of IPFS, the idea is that *both* the IPFS and HTTP substituter are
enabled, in that order: "--substitute-methods=ipfs http". The IPFS substituter
won't be able to produce any narinfos by itself, but that's no problem as
the HTTP substituter can find some. Then, the IPFS substituter will be asked
first to download a substitute, as it's first in the "--substitute-methods" list.

And what if the narinfo doesn't have a IPFS URI, as the substitute server doesn't
support that? Then "guix substitute" automatically fall-backs to HTTP.

Summary: some substitution methods can't do everything on their own, but that's ok,
as "guix substitute" will just ask them to try what they can and will see if some
combination of methods works.

About ‘not sure it's necessary’: there presumably will be a GNUnet substituter
at some point. I suppose it would be possible to define all substitute methods
in (guix scripts substitute), but then you would still end up with a procedure
that tries all methods (e.g. in wip-ipfs-substitutes, process-substitution has
an "if" structures that tries downloading via IPFS with fall-back to HTTP; this
would become a (cond (ipfs? ipfs-code) (gnunet? gnunet-code) (#t http-code?))

Note that there's (guix scripts import X) and (guix build-system X).

Toggle quote (2 lines)
I haven't taken a close look at this yet before (I haven't been around guix
development for long). To me, this seems compatible with this patch actually.
The HTTP substituter's procedure for downloading the substitute itself
(process-substitution/http in my patch) could be split in two, and look
at the narinfo to see whether the 'digest' or the usual mechanism should be used.

Alternatively, one could define *two* substituters: the ‘standard’ http substituter
‘http’, and the ‘http-digest’ substituter that can't fetch narinfo's, but rather
is an alternative method for downloading the substitute. The daemon can be started
with "--substitute-methods http-digest http" to prefer downloading via the ‘http-digest’
method when possible, but uses ‘http’ for the narinfos and as a fallback for when the
narinfo does not have a digest.

But what if a non-HTTP substituter wants to use digests? Well, I don't know any such
substituters (-:. But for the (hypothetical) GNUnet substituter & the wip IPFS
substituter, I don't think they will use the digests code.

Toggle quote (3 lines)
> Another issue is that it may be that, instead of letting users choose
> one method and stick to it,

They (at least the system administrator) can choose a list of substituters,
see above.

Toggle quote (3 lines)
> we’d rather let them choose a policy that
> can automatically pick the “best” method, dynamically adjusting choices.

Who's the user here?
(a) the system administrator, who configuring the daemon to use a certain
list of substituters and defines a default list of substitute uris.
(b) the ‘user’, that doesn't directly have the capability to modify
the system's guix daemon (or possibly an administrator that wants to
to test some things out without the possibility of accidentally messing
up the ‘real’ system).

If (b), I think it would be ideal to give the (unprivileged) user the
possibility of using their own substituter(s) (under their own capabilities,
not root), albeit at the cost of the guix daemon having to verify the narhash
& narinfo signature.

That could be implemented as a separate patch (though this patch would need
to be rebased then). WDYT? Would be useful for developing new substituters
and testing them, I think.

About *automatically* dynamically adjusting choices: would be nice, but how is
this supposed to work? Any ideas? The only thing I could think of is a
allowing the user to choose which narinfo to use (e.g. from the list of found
narinfos try to choose a narinfo that has an IPFS URI).

Also, for (a) the shepherd service could use a "set-substitute-methods" option,
and perhaps the user (b) could be allowed to select a subset of these substitute
methods to use when running "guix build PACKAGE" and the like (but only a subset,
as "guix substitute" when invoked by the daemon runs as root and therefore the
potential attack surface shouldn't be increased beyond what the administrator
allows).

Toggle quote (3 lines)
> All in all, I would prefer to wait until there’s a clear need for this
> abstraction.

See above responses.

WDYT?

Thanks,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYECQ3RccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7ltBAP9iYlOav2/YVN2Zt3CBeW0DASO2
PGooVzqFmZwePUzMqAD+PEzziVN7j7ToALv6bJWH74o61yFFk2WziDK1P/wx3w4=
=poFh
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 5 Mar 2021 21:05
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 46800@debbugs.gnu.org)
9585e4728cfa5cae4e4a16f3434220ac4dd0bd7d.camel@telenet.be
On Tue, 2021-03-02 at 21:37 +0100, Ludovic Courtès wrote:
Toggle quote (13 lines)
> Hi Maxime,
>
> Maxime Devos <maximedevos@telenet.be> skribis:
>
> > This patch series is my suggestion for allowing
> > multiple "substitution methods" or "substituters"
> > as I call them. Currently, only a method for HTTP/S
> > is defined, though I hope it will be a good basis
> > for a common framework for substitutes over GNUnet
> > and IPFS.
>
> [Ludovic's reply]

(See previous mail for my responses)

FYI: I've implemented a GNUnet substituter using this patch series
and the "publish hooks" patch (+ an unsubmitted patch that passes
some extra information to the publish hook) here:


(Warning: it does some questionable things with add-to-load-path.
Will hopefully be fixed eventually. Also requires

Also, there's a bug in fetch-narinfos that causes an error if
the "fetch-narinfos" field of a subtituter is #f. Also,
recognised-uri-scheme should be removed or reworked, as otherwise
the IPFS and GNUnet substituter won't be used for downloading a
substitute if http and https are not in the list.

I've worked around that for now by setting the latter '(http https file),
and setting the former to (const '()).

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYEKPIRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7ggNAP9kAKdmueFuktbJwweo4z6igHkb
Kn07Uc1HuE7mT3IJnQEAtkL8N9OTD+IC6+PEyo7qIoUogyflcM43nW/fUD94oAI=
=QISs
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 12 Mar 2021 18:37
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 46800@debbugs.gnu.org)
878s6sqnm6.fsf_-_@gnu.org
Hi Maxime,

Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (2 lines)
> On Tue, 2021-03-02 at 21:37 +0100, Ludovic Courtès wrote:

[...]

Toggle quote (7 lines)
>> As discussed on IRC, the daemon used to have support for multiple
>> substituters, but as a built-in C++ interface, which I removed in
>> f6919ebdc6b0ce0286814cc6ab0564b1a4c67f5f.
>
> Was there any particular reason this support was removed, beyond
> moving from C++ to Scheme and the absence of any alternative substituters?

These were the main reasons, yes.

Toggle quote (20 lines)
>> The Scheme interface you propose is of course nicer :-), but I’m still
>> not sure it’s necessary. For example, in the IPFS prototype at
>> <https://issues.guix.gnu.org/33899>;, IPFS support goes hand in hand with
>> HTTP support: narinfos are retrieved over HTTP and nars can be retrieved
>> over IPFS, or HTTP.
>
> About X going hand-in-hand with Y:
>
> Note that fetching narinfos, or fetching the nar itself are separated
> A method can support both procedures, or just one of them (or none,
> but that's rather useless.)
>
> Users (well, the system administrator) can choose multiple methods, which
> will be each fetch narinfos after each other & combine the
> results into
> one large list (or maybe some other data structure, I don't recall the
> details), and each substituter will be asked to produce
> a nar until a substituter
> succeeds or all have said "sorry, I don't have that nar".

OK.

Toggle quote (16 lines)
> (That's different from C++ interface for multiple substituters I think, where
> the methods are only tried sequentialy, they aren't combined.)
>
> In case of IPFS, the idea is that *both* the IPFS and HTTP substituter are
> enabled, in that order: "--substitute-methods=ipfs http". The IPFS substituter
> won't be able to produce any narinfos by itself, but that's no problem as
> the HTTP substituter can find some. Then, the IPFS substituter will be asked
> first to download a substitute, as it's first in the "--substitute-methods" list.
>
> And what if the narinfo doesn't have a IPFS URI, as the substitute server doesn't
> support that? Then "guix substitute" automatically fall-backs to HTTP.
>
> Summary: some substitution methods can't do everything on their own, but that's ok,
> as "guix substitute" will just ask them to try what they can and will see if some
> combination of methods works.

Alright.

Toggle quote (7 lines)
> About ‘not sure it's necessary’: there presumably will be a GNUnet substituter
> at some point. I suppose it would be possible to define all substitute methods
> in (guix scripts substitute), but then you would still end up with a procedure
> that tries all methods (e.g. in wip-ipfs-substitutes, process-substitution has
> an "if" structures that tries downloading via IPFS with fall-back to HTTP; this
> would become a (cond (ipfs? ipfs-code) (gnunet? gnunet-code) (#t http-code?))

I guess considerations that are more important to me (and to users, I
suppose) now than a few years back are maintainability and robustness.

Concretely, I wouldn’t want Guix to offer out of the box 4 methods, 3 of
which perform poorly or are downright buggy. I think it would be more
fruitful if, as a project, we would focus on one or two methods or
method combinations that we have battle-tested, perform well, and a nice
long-term maintenance story, and so on.

[...]

Toggle quote (11 lines)
>> we’d rather let them choose a policy that
>> can automatically pick the “best” method, dynamically adjusting choices.
>
> Who's the user here?
> (a) the system administrator, who configuring the daemon to use a certain
> list of substituters and defines a default list of substitute uris.
> (b) the ‘user’, that doesn't directly have the capability to modify
> the system's guix daemon (or possibly an administrator that wants to
> to test some things out without the possibility of accidentally messing
> up the ‘real’ system).

I think (b) should be possible, just like users can pass
‘--substitute-urls’.

[...]

Toggle quote (5 lines)
> About *automatically* dynamically adjusting choices: would be nice, but how is
> this supposed to work? Any ideas? The only thing I could think of is a
> allowing the user to choose which narinfo to use (e.g. from the list of found
> narinfos try to choose a narinfo that has an IPFS URI).

I think it’ll have to be fine-tuned once we have several stable
substitute methods. After all, we have yet to figure out how to choose
between zstd and lzip for the current substitution mechanism; the
tradeoffs when very different methods are in use may be more complex!

Toggle quote (5 lines)
>> All in all, I would prefer to wait until there’s a clear need for this
>> abstraction.
>
> See above responses.

I don’t think my concerns are really addressed :-), but at the same time
I think we need a playground for these things so we can actually grow
new substitute methods like those you’ve been looking at. Hmmm tricky!

Ludo’.
T
T
Tony Olagbaiye wrote on 6 Jun 2021 19:52
RE: [PATCH] Allow defining multiple substituters
(name . 46800@debbugs.gnu.org)(address . 46800@debbugs.gnu.org)
nlcoNpb6oKz6tKJ_O5FQ-6gc4dtSAtY6fFLPe15gZGVoFEhvHQwt9YNsHPqjRI4J51p06XsyyQl-9Ak6eBaAeQ==@fron.io
Hi, any news on this patch?

Thanks,
ix
Attachment: file
Attachment: signature.asc
?