jtgans / tsumufs

An NFS caching layer for Linux
GNU General Public License v2.0
0 stars 0 forks source link

Ping NFS server #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, I've found a solution to ping nfs server by using a shell command :

rpcinfo -t @host nfs version

"version" is a number like 2, 3 or 4

if server is unreachable, it will respond :
rpcinfo: RPC: Timed out
program 100003 version 3 is not available

if nfs server is accessible, it will respond:
program 100003 version 3 ready and waiting

So create a .sh script:
#!/bin/sh
rpcinfo -t @host nfs 3

then, include this code into the PingServerOk function:

import subprocess
import os
retval=subprocess.call('your absolute script path')

it seems to work well when I use tsumufs

Original issue reported on code.google.com by megab...@gmail.com on 19 May 2009 at 4:08

GoogleCodeExporter commented 9 years ago
Hm. I would agree, but the problem is that it calls out to yet another shell 
command.
Since we're running multithreaded python, using popen(2) in this way is very
dangerous for the life of the program -- especially when we call it multiple 
times.
Further, rpcinfo is VERY NFS specific, so I'm pretty reluctant to integrate it 
into
the codebase. Really, we should setup an abstraction class to move the NFS 
specifics
outside of the syncthread entirely and allow for using alternate classes for
differing FSes.

As a result, I would like to see the RPC protocol implemented in python as an
extension instead, or at least a simple RPC implementation in pure python. TBH, 
the
/only/ reason why we shell out to the mount command to setup NFS in the first 
place
is because the mount syscall isn't portable and isn't even really available to
userspace without crazy pretzel-like contortions.

I'm going to mark this as Accepted until one of the two above problems can be
integrated somehow.

Original comment by june.t...@gmail.com on 4 Jun 2009 at 5:19

GoogleCodeExporter commented 9 years ago
On Jun 15th, megabast wrote:
> Hi,
> I've found a new solution for checking nfs server availability.
> I've used pynfs (http://freshmeat.net/projects/pynfs/) which works
> with nfs v4.
> It's an extern module and it's very simple to use it. So it's a new
> dependence for tsumufs with the RPC protocol implementation in pure
> python.

This looks VERY promising for what the bug needs. My only concern is
that it seems to be NFSv4 only, while the primary NFS implementations
out there are v3 (from past experience, most v4 clients and servers
are horribly bug ridden and still haven't been deployed very heavily).
Perhaps we should extract or use the RPC implementation and just use
that to verify some checks in the ping method.

Great find! I can't look into it much more right now, but I'll
definitely be having a closer look sometime tonight or tomorrow.
Thanks!

Original comment by june.t...@gmail.com on 17 Jun 2009 at 8:16