[PATCH] doc: Document the (possible) need for network-online for NFS.

  • Done
  • quality assurance status badge
Details
2 participants
  • Maxim Cournoyer
  • Tomas Volf
Owner
unassigned
Submitted by
Tomas Volf
Severity
normal

Debbugs page

Tomas Volf wrote 4 months ago
(address . guix-patches@gnu.org)(name . Tomas Volf)(address . ~@wolfsden.cz)
2e43b85dce9d86ded76acc7acee234847c49a616.1732470232.git.~@wolfsden.cz
Depending on networking is not enough in some setups, so a language clarifying
that and an example of network-online service.

* doc/guix.texi (File Systems): Document the possible need for network-online.

Change-Id: I8abe07cc9d6dc61f28eeea7ffa785eb8c9e8fd09
---
doc/guix.texi | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

Toggle diff (41 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 26488b41c8..861e78e6d2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18018,7 +18018,33 @@ File Systems
met before mounting the file system.
As an example, an NFS file system would typically have a requirement for
-@code{networking}.
+@code{networking}. However be aware that depending on @code{networking}
+might not be sufficient in some setups and a variant of custom
+@code{network-online} service might be necessary. Example:
+
+@lisp
+(simple-service 'network-online shepherd-root-service-type
+ (list
+ (shepherd-service
+ (requirement '(networking))
+ (provision '(network-online))
+ (documentation "Wait for the network to come up.")
+ (start #~(lambda _
+ (let* ((cmd
+ "set -eux
+c=0
+while ! /run/setuid-programs/ping -qc1 -W1 example.org; do
+ sleep 1
+ [ \"$((c += 1))\" -lt 30 ] || exit 1 # Limit the wait time
+done
+")
+ (status (system cmd)))
+ (= 0 (status:exit-val status)))))
+ ;; Ordering for one-shot? services does not currently work.
+ ;; https://issues.guix.gnu.org/74284
+ ;; (one-shot? #t)
+ )))
+@end lisp
Typically, file systems are mounted before most other Shepherd services
are started. However, file systems with a non-empty
--
2.46.0
Maxim Cournoyer wrote 4 months ago
(name . Tomas Volf)(address . ~@wolfsden.cz)
87o724nmr9.fsf@gmail.com
Hi Tomas,

Tomas Volf <~@wolfsden.cz> writes:

Toggle quote (23 lines)
> Depending on networking is not enough in some setups, so a language clarifying
> that and an example of network-online service.
>
> * doc/guix.texi (File Systems): Document the possible need for network-online.
>
> Change-Id: I8abe07cc9d6dc61f28eeea7ffa785eb8c9e8fd09
> ---
> doc/guix.texi | 28 +++++++++++++++++++++++++++-
> 1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 26488b41c8..861e78e6d2 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -18018,7 +18018,33 @@ File Systems
> met before mounting the file system.
>
> As an example, an NFS file system would typically have a requirement for
> -@code{networking}.
> +@code{networking}. However be aware that depending on @code{networking}
> +might not be sufficient in some setups and a variant of custom
> +@code{network-online} service might be necessary.

Could we be more precise and detail a simple case or example of when
requiring 'network-online is needed over just 'network for NFS?

Toggle quote (21 lines)
> Example:
> +
> +@lisp
> +(simple-service 'network-online shepherd-root-service-type
> + (list
> + (shepherd-service
> + (requirement '(networking))
> + (provision '(network-online))
> + (documentation "Wait for the network to come up.")
> + (start #~(lambda _
> + (let* ((cmd
> + "set -eux
> +c=0
> +while ! /run/setuid-programs/ping -qc1 -W1 example.org; do
> + sleep 1
> + [ \"$((c += 1))\" -lt 30 ] || exit 1 # Limit the wait time
> +done
> +")
> + (status (system cmd)))
> + (= 0 (status:exit-val status)))))

I'm pretty sure we have connectivity tests already in the Guix test
suite that must make use of Guile; that would be nicer, I think; for
example, the (guix tests) module has:

Toggle snippet (5 lines)
(define (network-reachable?)
"Return true if we can reach the Internet."
(false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))

Toggle quote (6 lines)
> + ;; Ordering for one-shot? services does not currently work.
> + ;; https://issues.guix.gnu.org/74284
> + ;; (one-shot? #t)
> + )))
> +@end lisp

Otherwise, it looks like a useful addition.

--
Thanks,
Maxim
Tomas Volf wrote 4 months ago
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87zflneeah.fsf@wolfsden.cz
Hello Maxim,

thank you for the review. :) Responses below.

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (30 lines)
> Hi Tomas,
>
> Tomas Volf <~@wolfsden.cz> writes:
>
>> Depending on networking is not enough in some setups, so a language clarifying
>> that and an example of network-online service.
>>
>> * doc/guix.texi (File Systems): Document the possible need for network-online.
>>
>> Change-Id: I8abe07cc9d6dc61f28eeea7ffa785eb8c9e8fd09
>> ---
>> doc/guix.texi | 28 +++++++++++++++++++++++++++-
>> 1 file changed, 27 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index 26488b41c8..861e78e6d2 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -18018,7 +18018,33 @@ File Systems
>> met before mounting the file system.
>>
>> As an example, an NFS file system would typically have a requirement for
>> -@code{networking}.
>> +@code{networking}. However be aware that depending on @code{networking}
>> +might not be sufficient in some setups and a variant of custom
>> +@code{network-online} service might be necessary.
>
> Could we be more precise and detail a simple case or example of when
> requiring 'network-online is needed over just 'network for NFS?

It would be the case for any setup where 'networking being marked as
started does not mean the network is fully configured. I personally
encountered the issue with dhcp-client-service-type.

I will send a v2 that will go into more details than "in some setups".

Toggle quote (31 lines)
>
>> Example:
>> +
>> +@lisp
>> +(simple-service 'network-online shepherd-root-service-type
>> + (list
>> + (shepherd-service
>> + (requirement '(networking))
>> + (provision '(network-online))
>> + (documentation "Wait for the network to come up.")
>> + (start #~(lambda _
>> + (let* ((cmd
>> + "set -eux
>> +c=0
>> +while ! /run/setuid-programs/ping -qc1 -W1 example.org; do
>> + sleep 1
>> + [ \"$((c += 1))\" -lt 30 ] || exit 1 # Limit the wait time
>> +done
>> +")
>> + (status (system cmd)))
>> + (= 0 (status:exit-val status)))))
>
> I'm pretty sure we have connectivity tests already in the Guix test
> suite that must make use of Guile; that would be nicer, I think; for
> example, the (guix tests) module has:
>
> (define (network-reachable?)
> "Return true if we can reach the Internet."
> (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
>

This procedure however (despite the name) does not test whether network
is reachable, it tests whether single specific host name is resolvable.
That is not an equivalent of the example 'network-online service.

1. The procedure succeeds on completely offline machine, assuming there
is a record for the host in /etc/hosts. This is not an hypothetical
problem, in my configuration the actual host name I ping (instead of
example.org above) *is* in /etc/hosts.

2. Even if the DNS server works, that does not mean that the route to
the host being checked is configured (yet). That could happen when
the route is (for example) created by VPN, so it needs some extra
time to come up.

I do not see a way to do a "ping" using Guile's standard library, and
while I *could* implement it using raw sockets (the service is running
as a root after all), that seems like an overkill for just an example
snippet of code.

I mean, I am not happy about shelling to the /run/setuid-programs/ping.
But I did not figure out a Guile-only way to test what I want to test
(specific host is reachable) that would fit in similar amount of code.

What I could do is to replace the example with something like
"Implementing the 'network-online service is left as an exercise to the
reader.". Would that work for you?

Toggle quote (8 lines)
>> + ;; Ordering for one-shot? services does not currently work.
>> + ;; https://issues.guix.gnu.org/74284
>> + ;; (one-shot? #t)
>> + )))
>> +@end lisp
>
> Otherwise, it looks like a useful addition.

Will send a v2 once we clarify what to do about the ping.

Thanks,
Tomas

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmdEYSYOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wan3ohAAjP4Hhw1r9MQ+fiAqEyIq7NCG5GHXdNmXuOU/
L8f+8EpYnGtR/+qPWL9eI62JTbnec5NOqdnwfQ7C5rAYpVRH7UFfrzx66qyg0jAW
fpwmwQmUQZsPpDiBscDAVhsIddCLYTpJ9Y9SM/DTw6q8b8QR8qplk6bnXTbaf8u8
sw7a+jTC4qQOS8M5s3QxE+1EFMeThlm1A2Tkig+OsaDVNX8z+0hj6OVakqhflyQO
SeozxaPbL5gA9dB7rwhdMYEz5tFOFbRQoc73gJOx/Erjz3CjVeJNYz+bBIkkis/j
wvmrRaXaOclmKgtE4eb3+iR+kxywsB9ZdlY1vdkeVOV2RAe4GSz3eehfqGR5op2x
u21n2wZrOAHPFpZjz0rk1doavJHVv47nMs1YC3Bm8juZC/W7uZo4trA5EBny4f2F
4MrGEllwQUFfOh2XeZGFwhh2bHa9O1jV/n79goqfhVgE76ICwjjZU5Tcoa/w3QMY
mcPUmHMcTnlD3p4ShZpiqIvC4GqFOjX2AVXYOwzOSlqlYTs4iEtDio1jysF4XKNN
WeKjhE3gYBIggWyHEVCsxv+LMc9hB/5YR5Y+cwxhUiDE2MR3BXrptV3znjZI8e97
oYQuqlI4EaUYsXVhUlIBTgQy2ytkNpK8iQfmAd1kkErTlBzAAs9dvPqoxwUfeugn
IBAm/iM=
=Kg8W
-----END PGP SIGNATURE-----

Maxim Cournoyer wrote 1 weeks ago
Re: bug#74510: [PATCH] doc: Document the (possible) need for network-online for NFS.
(name . Tomas Volf)(address . ~@wolfsden.cz)
87r03fg8wp.fsf_-_@gmail.com
Hi Tomas,

Tomas Volf <~@wolfsden.cz> writes:


[...]

Toggle quote (9 lines)
>> Could we be more precise and detail a simple case or example of when
>> requiring 'network-online is needed over just 'network for NFS?
>
> It would be the case for any setup where 'networking being marked as
> started does not mean the network is fully configured. I personally
> encountered the issue with dhcp-client-service-type.
>
> I will send a v2 that will go into more details than "in some setups".

OK, thank you.

Toggle quote (40 lines)
>>
>>> Example:
>>> +
>>> +@lisp
>>> +(simple-service 'network-online shepherd-root-service-type
>>> + (list
>>> + (shepherd-service
>>> + (requirement '(networking))
>>> + (provision '(network-online))
>>> + (documentation "Wait for the network to come up.")
>>> + (start #~(lambda _
>>> + (let* ((cmd
>>> + "set -eux
>>> +c=0
>>> +while ! /run/setuid-programs/ping -qc1 -W1 example.org; do
>>> + sleep 1
>>> + [ \"$((c += 1))\" -lt 30 ] || exit 1 # Limit the wait time
>>> +done
>>> +")
>>> + (status (system cmd)))
>>> + (= 0 (status:exit-val status)))))
>>
>> I'm pretty sure we have connectivity tests already in the Guix test
>> suite that must make use of Guile; that would be nicer, I think; for
>> example, the (guix tests) module has:
>>
>> (define (network-reachable?)
>> "Return true if we can reach the Internet."
>> (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
>>
>
> This procedure however (despite the name) does not test whether network
> is reachable, it tests whether single specific host name is resolvable.
> That is not an equivalent of the example 'network-online service.
>
> 1. The procedure succeeds on completely offline machine, assuming there
> is a record for the host in /etc/hosts. This is not an hypothetical
> problem, in my configuration the actual host name I ping (instead of
> example.org above) *is* in /etc/hosts.

To be clear, I wasn't suggesting to change the host name checked;
example.org seems a fine target as it appears intended for such use case
(and maintained by the IANA).

Toggle quote (5 lines)
> 2. Even if the DNS server works, that does not mean that the route to
> the host being checked is configured (yet). That could happen when
> the route is (for example) created by VPN, so it needs some extra
> time to come up.

Good point.

Toggle quote (13 lines)
> I do not see a way to do a "ping" using Guile's standard library, and
> while I *could* implement it using raw sockets (the service is running
> as a root after all), that seems like an overkill for just an example
> snippet of code.
>
> I mean, I am not happy about shelling to the /run/setuid-programs/ping.
> But I did not figure out a Guile-only way to test what I want to test
> (specific host is reachable) that would fit in similar amount of code.
>
> What I could do is to replace the example with something like
> "Implementing the 'network-online service is left as an exercise to the
> reader.". Would that work for you?

I think your ready to use example is fine as is; thanks for the
explanations.

--
Thanks,
Maxim
Tomas Volf wrote 1 weeks ago
[PATCH v2] doc: Document the (possible) need for network-online for NFS.
(address . 74510@debbugs.gnu.org)(name . Tomas Volf)(address . ~@wolfsden.cz)
87367d0bff9571182aed65b296c8f630d9b8ae0e.1740925749.git.~@wolfsden.cz
Depending on networking is not enough in some setups, so a language clarifying
that and an example of network-online service.

* doc/guix.texi (File Systems): Document the possible need for network-online.

Change-Id: I8abe07cc9d6dc61f28eeea7ffa785eb8c9e8fd09
---
doc/guix.texi | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

Toggle diff (40 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index a036c85c31..daebf046d7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18153,7 +18153,32 @@ File Systems
met before mounting the file system.
As an example, an NFS file system would typically have a requirement for
-@code{networking}.
+@code{networking}. However be aware that depending on @code{networking}
+might not be sufficient in setups where @code{networking} being marked
+as started does not imply the network is configured and working
+(e.g. when using @code{dhcp-client-service-type}). In those cases, a
+custom @code{network-online} service might be necessary. Example:
+
+@lisp
+(simple-service 'network-online shepherd-root-service-type
+ (list
+ (shepherd-service
+ (requirement '(networking))
+ (provision '(network-online))
+ (documentation "Wait for the network to come up.")
+ (start #~(lambda _
+ (let* ((cmd
+ "set -eux
+c=0
+while ! /run/setuid-programs/ping -qc1 -W1 example.org; do
+ sleep 1
+ [ \"$((c += 1))\" -lt 30 ] || exit 1 # Limit the wait time
+done
+")
+ (status (system cmd)))
+ (= 0 (status:exit-val status)))))
+ (one-shot? #t))))
+@end lisp
Typically, file systems are mounted before most other Shepherd services
are started. However, file systems with a non-empty
--
2.48.1
Tomas Volf wrote 1 weeks ago
Re: bug#74510: [PATCH] doc: Document the (possible) need for network-online for NFS.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
877c57o69b.fsf@wolfsden.cz
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (18 lines)
> Hi Tomas,
>
> Tomas Volf <~@wolfsden.cz> writes:
>
>
> [...]
>
>>> Could we be more precise and detail a simple case or example of when
>>> requiring 'network-online is needed over just 'network for NFS?
>>
>> It would be the case for any setup where 'networking being marked as
>> started does not mean the network is fully configured. I personally
>> encountered the issue with dhcp-client-service-type.
>>
>> I will send a v2 that will go into more details than "in some setups".
>
> OK, thank you.

v2 sent.

Toggle quote (45 lines)
>
>>>
>>>> Example:
>>>> +
>>>> +@lisp
>>>> +(simple-service 'network-online shepherd-root-service-type
>>>> + (list
>>>> + (shepherd-service
>>>> + (requirement '(networking))
>>>> + (provision '(network-online))
>>>> + (documentation "Wait for the network to come up.")
>>>> + (start #~(lambda _
>>>> + (let* ((cmd
>>>> + "set -eux
>>>> +c=0
>>>> +while ! /run/setuid-programs/ping -qc1 -W1 example.org; do
>>>> + sleep 1
>>>> + [ \"$((c += 1))\" -lt 30 ] || exit 1 # Limit the wait time
>>>> +done
>>>> +")
>>>> + (status (system cmd)))
>>>> + (= 0 (status:exit-val status)))))
>>>
>>> I'm pretty sure we have connectivity tests already in the Guix test
>>> suite that must make use of Guile; that would be nicer, I think; for
>>> example, the (guix tests) module has:
>>>
>>> (define (network-reachable?)
>>> "Return true if we can reach the Internet."
>>> (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
>>>
>>
>> This procedure however (despite the name) does not test whether network
>> is reachable, it tests whether single specific host name is resolvable.
>> That is not an equivalent of the example 'network-online service.
>>
>> 1. The procedure succeeds on completely offline machine, assuming there
>> is a record for the host in /etc/hosts. This is not an hypothetical
>> problem, in my configuration the actual host name I ping (instead of
>> example.org above) *is* in /etc/hosts.
>
> To be clear, I wasn't suggesting to change the host name checked;
> example.org seems a fine target as it appears intended for such use case
> (and maintained by the IANA).

I get that. The point I was trying to make was that if you have
`example.org' in /etc/hosts, the `network-reachable?' against
`example.org' will always succeed, regardless of state of the network.

That is unlikely for example.org (or www.gnu.org), but it is the case
for the hostname I am actually checking in my configuration. Hence the
`network-reachable?', as written above, would always return true.

Have a nice day,
Tomas
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmfEa1AOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wakPrg//fCKDMDPGKyJ0jcuy22jAQskxcgOEOAxBkKcv
idmRGL9371bSH+b5+MnuhH+1K/8vmhNBpp+ComvxZaEMh98Gx15m0W/YkIlV9opM
q0R0Geoq+w59jU/aRZbSEWiktjGfe2d7tCbu8vRIfyE0KVq6x5KedVDB7R43cXiH
jtxs3GEeV+MD96sgqW7eZLtP7My55zP2peC4NUmVTS9FB0XGacJ4NJ62weeUg82v
2oEm+dyRyKVUGIkTxaXVy7UhxbUrb7c8YOdGTUq9/hV5hWgaA2uJ/PRbfP5JBYWo
TBdCb8uuIBnFJVPO5i7mMch1S0mBmPlF5gPcwxmOJ8YM4QZw64QZ5E5Ph/jaHdPh
2Vfhxn7Ly5QnkGx1C5bouDcr28+w2PL+o2zm+tKF+YAJxbGONfKhLo42Q3lKKFPr
9xvpzad+N4aigNWI/V5ObfwTY40+PFCwiorluo1/CGYj+Pj6MVEi8d1U1kdku4dg
vTOrVoKj+7YT1eNAkz3Yc1Hy/ntI4HLPkITgurrtErPR0NYS7cHWamO5cdUq8jhI
vRvJ4k8zPcGTiD+LfUWpVsYoDcrUYnF0RSIEOqLXlDQ4LFs7gP1do34CYF2etJfL
yWl3jU5GFEHM6kPff/vSOFoxzSu0r2BPvlq6ZT1fTkncwCKq+UHvf1c+Z/QfGk7P
o6iOa8E=
=FD9W
-----END PGP SIGNATURE-----

Maxim Cournoyer wrote 3 days ago
Re: [bug#74510] [PATCH v2] doc: Document the (possible) need for network-online for NFS.
(name . Tomas Volf)(address . ~@wolfsden.cz)
87frjmu15d.fsf@gmail.com
Hi,

Tomas Volf <~@wolfsden.cz> writes:

Toggle quote (5 lines)
> Depending on networking is not enough in some setups, so a language clarifying
> that and an example of network-online service.
>
> * doc/guix.texi (File Systems): Document the possible need for network-online.

I've modified your wording slightly, like so:

Toggle snippet (21 lines)
@@ -18170,11 +18170,14 @@ File Systems
met before mounting the file system.
As an example, an NOW'S file system would typically have a requirement for
-@code{networking}. However be aware that depending on @code{networking}
-might not be sufficient in setups where @code{networking} being marked
-as started does not imply the network is configured and working
-(e.g. when using @code{dhcp-client-service-type}). In those cases, a
-custom @code{network-online} service might be necessary. Example:
+@code{networking}. In some situations, requiring @code{networking}
+might not be sufficient as @code{networking} being marked as started
+does @emph{not} imply the network has already been configured and in
+working order (for example, when using
+@code{dhcpcd-client-service-type}). For such cases, a custom
+@code{network-online} service might be necessary. A sample
+@code{network-online} one-shot Shepherd service implementation is
+provided below:
@lisp

and pushed!

--
Thanks,
Maxim
Closed
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 74510@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74510
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help