public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] fix: check connection for nfs v4 only server
@ 2020-12-16 11:59 Alwin Antreich
  2020-12-16 14:00 ` Alwin Antreich
  2021-01-26 18:15 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Alwin Antreich @ 2020-12-16 11:59 UTC (permalink / raw)
  To: pve-devel

the check_connection is done by querying the exports of the nfs server
in question. With nfs v4 those exports aren't listed anymore since nfs
v4 employs a pseudo-filesystem starting from root (/).

rpcinfo allows to query the existence of an nfs v4 service.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
---
Note: scan_nfs will not work with nfs v4 only, since it also employs
      showmount. The path has to be provided manually.

 PVE/Storage/NFSPlugin.pm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/PVE/Storage/NFSPlugin.pm b/PVE/Storage/NFSPlugin.pm
index e8e27c0..72e06c2 100644
--- a/PVE/Storage/NFSPlugin.pm
+++ b/PVE/Storage/NFSPlugin.pm
@@ -160,8 +160,16 @@ sub check_connection {
     my ($class, $storeid, $scfg) = @_;
 
     my $server = $scfg->{server};
-
-    my $cmd = ['/sbin/showmount', '--no-headers', '--exports', $server];
+    my $opts = $scfg->{options};
+
+    my $cmd;
+    if (defined($opts) && $opts =~ /vers=4.*/) {
+	# nfsv4 uses a pseudo-filesystem always beginning with /
+	# no exports are listed
+	$cmd = ['/usr/sbin/rpcinfo', '-t', $server, 'nfs', '4'];
+    } else {
+	$cmd = ['/sbin/showmount', '--no-headers', '--exports', $server];
+    }
 
     eval { run_command($cmd, timeout => 10, outfunc => sub {}, errfunc => sub {}) };
     if (my $err = $@) {
-- 
2.27.0





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH storage] fix: check connection for nfs v4 only server
  2020-12-16 11:59 [pve-devel] [PATCH storage] fix: check connection for nfs v4 only server Alwin Antreich
@ 2020-12-16 14:00 ` Alwin Antreich
  2021-01-26 18:15 ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Alwin Antreich @ 2020-12-16 14:00 UTC (permalink / raw)
  To: pve-devel

On Wed, Dec 16, 2020 at 12:59:04PM +0100, Alwin Antreich wrote:
> the check_connection is done by querying the exports of the nfs server
> in question. With nfs v4 those exports aren't listed anymore since nfs
> v4 employs a pseudo-filesystem starting from root (/).
> 
> rpcinfo allows to query the existence of an nfs v4 service.
> 
> Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
> ---
> Note: scan_nfs will not work with nfs v4 only, since it also employs
>       showmount. The path has to be provided manually.
> 
>  PVE/Storage/NFSPlugin.pm | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/Storage/NFSPlugin.pm b/PVE/Storage/NFSPlugin.pm
> index e8e27c0..72e06c2 100644
> --- a/PVE/Storage/NFSPlugin.pm
> +++ b/PVE/Storage/NFSPlugin.pm
> @@ -160,8 +160,16 @@ sub check_connection {
>      my ($class, $storeid, $scfg) = @_;
>  
>      my $server = $scfg->{server};
> -
> -    my $cmd = ['/sbin/showmount', '--no-headers', '--exports', $server];
> +    my $opts = $scfg->{options};
> +
> +    my $cmd;
> +    if (defined($opts) && $opts =~ /vers=4.*/) {
> +	# nfsv4 uses a pseudo-filesystem always beginning with /
> +	# no exports are listed
> +	$cmd = ['/usr/sbin/rpcinfo', '-t', $server, 'nfs', '4'];
> +    } else {
> +	$cmd = ['/sbin/showmount', '--no-headers', '--exports', $server];
> +    }
>  
>      eval { run_command($cmd, timeout => 10, outfunc => sub {}, errfunc => sub {}) };
>      if (my $err = $@) {
> -- 
> 2.27.0
> 
In addition, the rpcbind service needs to run. Otherwise there is no
easy way to do the connection check.

See the troubleshooting on the forum.
https://forum.proxmox.com/threads/unable-to-mount-nfs-storage.80694/#post-357062

--
Cheers,
Alwin




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH storage] fix: check connection for nfs v4 only server
  2020-12-16 11:59 [pve-devel] [PATCH storage] fix: check connection for nfs v4 only server Alwin Antreich
  2020-12-16 14:00 ` Alwin Antreich
@ 2021-01-26 18:15 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2021-01-26 18:15 UTC (permalink / raw)
  To: Proxmox VE development discussion, Alwin Antreich

On 16.12.20 12:59, Alwin Antreich wrote:
> the check_connection is done by querying the exports of the nfs server
> in question. With nfs v4 those exports aren't listed anymore since nfs
> v4 employs a pseudo-filesystem starting from root (/).
> 
> rpcinfo allows to query the existence of an nfs v4 service.
> 
> Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
> ---
> Note: scan_nfs will not work with nfs v4 only, since it also employs
>       showmount. The path has to be provided manually.
> 
>  PVE/Storage/NFSPlugin.pm | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-26 18:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 11:59 [pve-devel] [PATCH storage] fix: check connection for nfs v4 only server Alwin Antreich
2020-12-16 14:00 ` Alwin Antreich
2021-01-26 18:15 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal