Skip to content

Commit 3a07eff

Browse files
kiszkHyukjinKwon
authored andcommitted
[SPARK-22813][BUILD] Use lsof or /usr/sbin/lsof in run-tests.py
## What changes were proposed in this pull request? In [the environment where `/usr/sbin/lsof` does not exist](#19695 (comment)), `./dev/run-tests.py` for `maven` causes the following error. This is because the current `./dev/run-tests.py` checks existence of only `/usr/sbin/lsof` and aborts immediately if it does not exist. This PR changes to check whether `lsof` or `/usr/sbin/lsof` exists. ``` /bin/sh: 1: /usr/sbin/lsof: not found Usage: kill [options] <pid> [...] Options: <pid> [...] send signal to every <pid> listed -<signal>, -s, --signal <signal> specify the <signal> to be sent -l, --list=[<signal>] list all signal names, or convert one to a name -L, --table list all signal names in a nice table -h, --help display this help and exit -V, --version output version information and exit For more details see kill(1). Traceback (most recent call last): File "./dev/run-tests.py", line 626, in <module> main() File "./dev/run-tests.py", line 597, in main build_apache_spark(build_tool, hadoop_version) File "./dev/run-tests.py", line 389, in build_apache_spark build_spark_maven(hadoop_version) File "./dev/run-tests.py", line 329, in build_spark_maven exec_maven(profiles_and_goals) File "./dev/run-tests.py", line 270, in exec_maven kill_zinc_on_port(zinc_port) File "./dev/run-tests.py", line 258, in kill_zinc_on_port subprocess.check_call(cmd, shell=True) File "/usr/lib/python2.7/subprocess.py", line 541, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '/usr/sbin/lsof -P |grep 3156 | grep LISTEN | awk '{ print $2; }' | xargs kill' returned non-zero exit status 123 ``` ## How was this patch tested? manually tested Author: Kazuaki Ishizaki <[email protected]> Closes #19998 from kiszk/SPARK-22813.
1 parent fbfa9be commit 3a07eff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

dev/run-tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ def kill_zinc_on_port(zinc_port):
253253
"""
254254
Kill the Zinc process running on the given port, if one exists.
255255
"""
256-
cmd = ("/usr/sbin/lsof -P |grep %s | grep LISTEN "
257-
"| awk '{ print $2; }' | xargs kill") % zinc_port
258-
subprocess.check_call(cmd, shell=True)
256+
cmd = "%s -P |grep %s | grep LISTEN | awk '{ print $2; }' | xargs kill"
257+
lsof_exe = which("lsof")
258+
subprocess.check_call(cmd % (lsof_exe if lsof_exe else "/usr/sbin/lsof", zinc_port), shell=True)
259259

260260

261261
def exec_maven(mvn_args=()):

0 commit comments

Comments
 (0)