-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-22813][BUILD] Use lsof or /usr/sbin/lsof in run-tests.py #19998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@srowen @HyukjinKwon could you please review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
dev/run-tests.py
Outdated
cmd = ("lsof -P |grep %s | grep LISTEN " | ||
"| awk '{ print $2; }' | xargs kill") % zinc_port | ||
subprocess.check_call(cmd, shell=True) | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we catch the explicit exception?
Also, I think we could this like:
cmd = "%s -P |grep %s | grep LISTEN | awk '{ print $2; }' | xargs kill"
...
lsof = "lsof"
subprocess.check_call(cmd % (lsof zinc_port), shell=True)
...
lsof = "/usr/sbin/lsof"
subprocess.check_call(cmd % (lsof zinc_port), shell=True)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if the command does not exist, we can catch it as an exception. Thus, we can execute one of the two cases.
Yea, to use such a cmd
is fine.
dev/run-tests.py
Outdated
try: | ||
subprocess.check_call(cmd % ("lsof", zinc_port), shell=True) | ||
except: | ||
subprocess.call(cmd % ("/usr/sbin/lsof", zinc_port), shell=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, subprocess.call
-> subprocess.check_call
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intentionally use subprocess.call
to continue the execution even if lsof
and /usr/sbin/lsof
do not exist. This is because it is ok for other steps if we fail to kill zinc
.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, but it changes what originally kill_zinc_on_port
does though because now it is not guaranteed to kill it. I see the point but let's stick to the original behaviour, for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Since this change is not strong preference, I will revert this change to keep the original behavior.
cmd = ("/usr/sbin/lsof -P |grep %s | grep LISTEN " | ||
"| awk '{ print $2; }' | xargs kill") % zinc_port | ||
subprocess.check_call(cmd, shell=True) | ||
cmd = "%s -P |grep %s | grep LISTEN | awk '{ print $2; }' | xargs kill" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, @kiszk, I think we can actually use sparktestsupport.shellutils.which("...")
too like what we do for java:
Line 153 in 964e5ff
return java_exe if java_exe else which("java") |
So, like ..
cmd = "%s -P |grep %s | grep LISTEN | awk '{ print $2; }' | xargs kill"
lsof_exe = which("lsof")
subprocess.check_call(cmd % (lsof_exe if lsof_exe else "/usr/sbin/lsof", zinc_port), shell=True)
I just double checked:
>>> lsof_exe = which("lsof")
>>> cmd % (lsof_exe if lsof_exe else "/usr/sbin/lsof", zinc_port)
"/usr/sbin/lsof -P |grep 1234 | grep LISTEN | awk '{ print $2; }' | xargs kill"
>>> lsof_exe = which("lsof")
>>> cmd % (lsof_exe if lsof_exe else "/usr/bin/lsof", zinc_port)
"/usr/sbin/lsof -P |grep 1234 | grep LISTEN | awk '{ print $2; }' | xargs kill"
>>> lsof_exe = which("foo")
>>> cmd % (lsof_exe if lsof_exe else "/usr/sbin/lsof", zinc_port)
"/usr/sbin/lsof -P |grep 1234 | grep LISTEN | awk '{ print $2; }' | xargs kill"
>>> lsof_exe = which("bar")
>>> cmd % (lsof_exe if lsof_exe else "/usr/bin/lsof", zinc_port)
"/usr/bin/lsof -P |grep 1234 | grep LISTEN | awk '{ print $2; }' | xargs kill"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, I also checked it.
>>> print(which("lsof"))
/usr/bin/lsof
>>>
% ls /usr/bin/lsof /usr/sbin/lsof
ls: cannot access '/usr/sbin/lsof': No such file or directory
/usr/bin/lsof
Test build #84990 has finished for PR 19998 at commit
|
Test build #84992 has finished for PR 19998 at commit
|
Test build #84993 has finished for PR 19998 at commit
|
Test build #84997 has finished for PR 19998 at commit
|
retest this please |
Test build #84999 has finished for PR 19998 at commit
|
Should we retest this again? |
Let's wait for a bit. Let me restart this once we started to get passed. Seems globally failed in R's CRAN check. |
I see, thank you very much. |
retest this please |
Test build #85026 has finished for PR 19998 at commit
|
retest this please |
Test build #85050 has finished for PR 19998 at commit
|
Merged to master. |
What changes were proposed in this pull request?
In the environment where
/usr/sbin/lsof
does not exist,./dev/run-tests.py
formaven
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.How was this patch tested?
manually tested