go-nfs icon indicating copy to clipboard operation
go-nfs copied to clipboard

add handler call on unmounts

Open willscott opened this issue 3 years ago • 5 comments

Allow handlers to correlate Mount and Unmount events to free resources like file handles when a client disconnects.

willscott avatar Mar 20 '21 16:03 willscott

upon testing, it looks like the unmount RPC call is only made when the nfs session has authentication. In the null authentication that's mostly being used, the unmounting of the device may (at least for linux clients) only be signaled through the closing of the TCP connection.

willscott avatar Mar 20 '21 19:03 willscott

Hey @willscott - thanks for this great library! How can I help in pushing this one past the finish line?

ozkatz avatar Apr 07 '24 07:04 ozkatz

PR welcome :) - i think it's probably not as drafted here, but rather on seeing the network connection terminate

willscott avatar Apr 07 '24 12:04 willscott

@willscott that's a good idea, but from my experience with TCP in Go, I don't know that there's a safe cross-platform way (looking at you, Windows!) to check TCP connection "liveness".

The only reliable way to tell if a connection is truly open, is to try to read from it (>0 bytes), which introduces its own set of complexities.

See recap of the problem on go-sql-driver/mysql 's attempt at the same.


Additionally, naive question regarding NFS implementations in the wild:

Will closing a TCP connection to a server necessarily mean explicit unmounting?

I can imagine an NFS client driver closing idle connections after a while of inactivity and reconnecting on demand when accessed by the user. Perhaps the connection tracks state that forbids this?

ozkatz avatar Apr 07 '24 17:04 ozkatz

I think your concern is probably why there isn't a clear Unmount event that makes sense. The decision to unmount in a stateless protocol like NFS ends up being a hybrid between the server's policy on when to clean up state and clients signalling explicit disconnects.

I think there may be a useful event to raise to handlers on these explicit disconnects when they are signaled by clients, and that's probably what this should be, with the understanding that it won't be "complete"

willscott avatar Apr 09 '24 06:04 willscott