Skip to main content
11 events
when toggle format what by license comment
Dec 31, 2014 at 14:55 comment added Sean Allred I'm very familiar with the XY problem; we get them all the time over at TeX.SX. It may not look like it from my rep on this particular site, but I've been on SE for quite a while :). I do not have control over the NFS servers -- this is an extremely large and complicated system with multiple contracts for it -- I don't like it, but there is defensive code everywhere. And actually -- yes that kind of granulated status is part of the design. More accurately, it can (and should) return exit codes based on the mount status.
Dec 31, 2014 at 14:37 comment added doktor5000 @SeanAllred: This seems more of a case of the XY problem. Maybe you should take a look at meta.stackoverflow.com/questions/66377/what-is-the-xy-problem. Before investing any further time into that script, you better fix the NFS servers. Putting that much efforts into a script to check beforehand that much stuff for a basic task like this seems a clear indication for obvious underlying issues. What is your goal? If a mount is exported, mount it - and in case not, your script does what exactly? Only output the error messages for your 4 checks?
Dec 31, 2014 at 12:06 comment added Mark Plotnick @SeanAllred Luckily, you don't need to create a subshell or a pipeline to look at the output of a process. Use output=subprocess.check_output(["showmount","-e",server]) and look through the output string for a line that starts with the directory or parent of a directory you want to know about.
Dec 30, 2014 at 22:10 comment added Sean Allred It truly is a separate issue – one that I've asked separately before (somewhere) to no great success or revelation. This script is part of a vast and (over-)complicated statusing network; I could create the mount and handle failure, but it would end up being an expensive step (since it would need to mount, unmount, and usually mount again). It's why I have so many levels of statusing – to ensure as little work as possible is done twice.
Dec 30, 2014 at 22:05 comment added BowlOfRed I think this is really a separate question from the NFS issue, it's about aspects of what you want to achieve from a python script. Perhaps you should ask that separately. But what is the purpose of getting this info? Is it just for troubleshooting? You could simply attempt the mount and handle failure. Is it a big advantage to detect that it's not exported before issuing the mount? For a down host, that could take some time. But if it's just unexported, I'd expect immediate failure.
Dec 30, 2014 at 21:58 comment added Sean Allred I can promise you it's not as easy as you'd immediately think – when it's locked up so, rpcinfo does not respond to anything but SIGKILL (which is a misattribution – the OS obviously just kills the process). At any rate, that would still start a shell to start rpcinfo – the underlying problem remains.
Dec 30, 2014 at 21:34 comment added BowlOfRed Write a separate script that does what you need (like calls showmount, but takes an argument for directory and returns success/failure, and includes a timeout that is reasonable for your purposes), then call that script from your python.
Dec 30, 2014 at 21:28 comment added Sean Allred I'm writing my script in Python 2.6 and using the subprocess module. I can set up a pipeline with it, but I'd rather not complicate the design that much. I need to avoid starting a subshell to allow the script to be killed gracefully -- if it is killed, its child processes will be killed, but not the children of the child processes. Thus, the subshell would be killed, but not the processes the subshell spawns. I've also noted rpcinfo can take up to three minutes to return, which is the original basis for the no-subshell thing. It's far too late to change that now, though.
Dec 30, 2014 at 21:20 comment added BowlOfRed That depends on the facilities at your disposal. What is your script written in? Why is starting a separate executable (showmount) less of a problem than starting another shell?
Dec 30, 2014 at 21:17 comment added Sean Allred showmount -r remote will tell me if remote is exporting anything, but is there any way for me to determine if remote:/mnt/dir is being exported without starting a subshell (i.e. a pipeline)?
Dec 30, 2014 at 21:07 history answered BowlOfRed CC BY-SA 3.0