[node-devel] Maybe the reason for install failed sometimes

Fabian Deutsch fabiand at redhat.com
Mon Aug 26 07:27:52 UTC 2013


Am Montag, den 26.08.2013, 02:19 +0000 schrieb Bohai (ricky):
> > > I failed to install the ovirt-node. About detail info, please see
> the summary of
> > ovirt.log
> > > at the end of the mail.
> > >
> > > I read the code, and found the call for subprocess_closefds like
> below:
> > > 1426 def findfs(label):
> > > 1427     system("partprobe /dev/mapper/*")
> > > 1428     system("udevadm settle")
> > > 1429     blkid_cmd = "/sbin/blkid -c /dev/null -l -o device -t
> LABEL=\"" +
> > label + "\""
> > > 1430     blkid = subprocess_closefds(blkid_cmd, shell=True,
> stdout=PIPE,
> > stderr=STDOUT)
> > > 1431     blkid_output = blkid.stdout.read().strip()
> > > 1432     return blkid_output
> > >
> > > I think when we read the stdout the command has not finished, so
> the real
> > blkid can't be read.
> > >
> > > After call of function subprocess_closefds, whether or not we need
> to wait for
> > process to terminate?
> > 
> > Hey Ricky,
> > 
> > subprocess_closefds is just wrapping subprocess.Popen and adding
> > close_fds=True. subprocess.Popen by default is waiting for the cmd
> to
> > exit. At least it behaved like this in a small test.
> > 
> 
> Hey Fabian,
> Maybe I can't agree with you.
> 
> When I read the Popen's source code in
> Python-2.7.5/Lib/subprocess.py, 
> I didn't find the default wait code.
> 
> In [1], the document only say the subprocess.call by default wait the
> command's complete.
> The below is the source code of subprocess.call, actually it depends
> on the wait() function.

You are right. It's only the subprocess.call() method which is waiting
for the cmd to complete.
subprocess.Popen() (which is used by subprocess_closefds) is only
spawning the new process.

So yes, this could really be a reason for the occasionally failing
installations.

In the 3.0 branch we can't just fix subprocess_closefds, we'll need to
look at each call to that function to add - if necessary - a wait()
call.

For 3.1 we can probably get rid of subprocess_closefds at all and use
the ovirt.node.utils.process module.

Greetings
- fabian




More information about the node-devel mailing list