[Ocfs2-test-devel] [PATCH 2/2] Ocfs2-test: Fix a o2tf bug when trying to capture the RC of openmpi_run

Tristan Ye tristan.ye at oracle.com
Tue Feb 17 01:17:29 PST 2009


When we running the openmpi_run() to spawn multi-nodes binary among nodes, we
used os.waitpid() to run mpirun, sadly, we did not capture the return code of
process waited by waitpid() and upcast to higher layer, this patch fix the problem
and let the remote_mount and remote_umount have its mpirun's return code examined.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 programs/python_common/command.py       |    3 +++
 programs/python_common/o2tf.py          |    5 ++++-
 programs/python_common/remote_mount.py  |    6 +++++-
 programs/python_common/remote_umount.py |    7 +++++--
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/programs/python_common/command.py b/programs/python_common/command.py
index 3efe95a..04c99e8 100755
--- a/programs/python_common/command.py
+++ b/programs/python_common/command.py
@@ -83,6 +83,8 @@ if __name__=='__main__':
 		else:
 			o2tf.printlog('Partition already mounted.',
 				logfile, 0, '')
+			sys.exit(1)
+
 	if options.doumount:
 		if not options.mountpoint:
 			parser.error('Please specify mountpoint.')
@@ -92,4 +94,5 @@ if __name__=='__main__':
 		else:
 			o2tf.printlog('Partition not mounted.',
 				logfile, 0, '')
+			sys.exit(1)
 #
diff --git a/programs/python_common/o2tf.py b/programs/python_common/o2tf.py
index 7ecca74..84342e6 100644
--- a/programs/python_common/o2tf.py
+++ b/programs/python_common/o2tf.py
@@ -310,6 +310,8 @@ def openmpi_run(DEBUGON, nproc, cmd, nodes, remote_sh, logfile, w_flag):
 	Execute commands in parallel using OpenMPI.'
 	"""
 	from os import access,F_OK
+	pid = 0
+        status = 0
 	found = 0
 	uname = os.uname()
 	nodelen = len(string.split(nodes,','))
@@ -341,7 +343,8 @@ def openmpi_run(DEBUGON, nproc, cmd, nodes, remote_sh, logfile, w_flag):
 		if w_flag == 'NOWAIT':
 			return pid
 		else:
-			os.waitpid(pid, 0)
+			(pid, status) = os.waitpid(pid, 0)
+			return status
 
 	except os.error:
 		pass
diff --git a/programs/python_common/remote_mount.py b/programs/python_common/remote_mount.py
index 9df45a4..ae2a6c5 100755
--- a/programs/python_common/remote_mount.py
+++ b/programs/python_common/remote_mount.py
@@ -95,7 +95,7 @@ command = str('%s -l %s -m %s' % (buildcmd,
 o2tf.OpenMPIInit(DEBUGON, options.nodelist, logfile, 'ssh')
 #
 #
-o2tf.openmpi_run(DEBUGON,
+ret = o2tf.openmpi_run(DEBUGON,
 		 nproc,
 		 str('%s' % command),
 		 options.nodelist,
@@ -103,3 +103,7 @@ o2tf.openmpi_run(DEBUGON,
 		 logfile,
 		 'WAIT')
 
+if ret:
+	sys.exit(1)
+else:
+	sys.exit(0)
diff --git a/programs/python_common/remote_umount.py b/programs/python_common/remote_umount.py
index d4124cc..7b8f24d 100755
--- a/programs/python_common/remote_umount.py
+++ b/programs/python_common/remote_umount.py
@@ -85,11 +85,14 @@ command = str('%s -m %s' % (buildcmd,
 o2tf.OpenMPIInit(DEBUGON, options.nodelist, logfile, 'ssh')
 #
 #
-o2tf.openmpi_run(DEBUGON,
+ret = o2tf.openmpi_run(DEBUGON,
 		 nproc,
 		 str('%s' % command),
 		 options.nodelist,
 		 'ssh', logfile,
 		 'WAIT')
 
-
+if ret:
+	sys.exit(1)
+else:
+	sys.exit(0)
-- 
1.5.5




More information about the Ocfs2-test-devel mailing list