-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-2960][Deploy] Support executing Spark from symlinks (reopen) #8669
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
bin/beeline
Outdated
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, is there no way to refactor these and source the function once? would be a good excuse to create such a common script here if it doesn't exist already.
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 think if we move this function to a new script, there still has a problem of how to find the real path of this new script.
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 will continue to think a way to remove these annoying duplication, also do more corner tests about this function.
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, I would imagine it could be next to the symlink and symlinked as well... but is the point that even sourcing isn't going to follow the symlink? I thought the point was not that the symlinks don't work as links to files, but that they don't help you find where Spark is installed.
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.
Hi @srowen , yes the actual problem is to find to out where Spark is installed through symlink.
Yes, sourcing can follow the symlink, but the problem is how to find the path of sourcing file/symlink.
Say if we make spark-shell as a symlink and add to /usr/bin, when we execute this spark-shell in any directory, how to identify the path of sourcing file? If sourcing file is not linked to /usr/bin/xx, we still need to find out where Spark is installed.
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 mean the file would be in /usr/bin too, yes. I understand it's a little ugly, yeah.
Hm, I wonder if this is really the right approach to finding where Spark is installed. Shouldn't this be covered by SPARK_HOME? that's how other software works. The title of the JIRA is actually misleading since symlinks works fine, themselves.
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.
If we assume SPARK_HOME must be set, then this problem can be simply solved. But the problem is that we don't have such assumptions, so we still need some scripts to find out where Spark is installed and still the problem is back again.
BTW, project like Hadoop also has this issue to find out hadoop-config.sh.
|
Other than that if it doesn't change existing behavior and lets symlinks stand a chance of working, seems good. |
|
Test build #42204 has finished for PR 8669 at commit
|
|
Applying the same fix to sbin executables would be great. In fact, the whole fix would be incomplete without it. |
|
Hi @patrungel , I've also fixed this issue for sbin executables, mind taking a look at it? |
|
Test build #42245 has finished for PR 8669 at commit
|
|
Hi, @jerryshao |
|
Can the following be fixed as well? |
|
Woah, this PR is really big! @jerryshao, do you think that you could move this function into a common "helper library" file then source / include that file into the other scripts? That would help to reduce duplication here. |
|
@JoshRosen yes agree. See the discussion above out the small chicken-and-egg problem there about the location of the helper script. Still may be a better solution than this much duplication, or else, declare that |
bin/load-spark-env.sh
Outdated
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.
Can this function be replaced by:
DIR="$(dirname "$(readlink -f "$0")")"
I see you're recursively resolving the symlink and putting a limit in the depth of recursion, but it sounds like readlink -f does just that.
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.
Nevermind, I just saw the comment about Macs not supporting that. There's no alternative on Macs? (If no, that sucks.)
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.
Hi @vanzin , the behavior of readlink -f is different under Mac, here is the discussion in stackoverflow. Another solution is to install greadlink through brew.
|
I think this is a whole lot of change, and the purpose really is just to avoid setting |
|
The change aims to make spark binaries launch properly when symlinked, not just to avoid setting which is generically wrong and does not work for a symlinked set-up. This behaviour prohibits proper ( = with alternatives) installations/packaging. So, if 'resolve this as wont-fix' refers to the issue, I beg to differ (this discussion should rather be moved to the ticket then). |
|
Gotcha, is the way forward really to not over-write |
|
Hi @srowen , I admitted currently solution is quite ugly, but like what you mentioned, it is a chicken-and-egg problem, hard to remove the duplication. Another solution is by setting So if setting What's your opinion? |
|
If |
The current scripts (e.g. pyspark) fail to run when they are executed via symlinks. A common Linux scenario would be to have Spark installed somewhere (e.g. /opt) and have a symlink to it in /usr/bin. Fixed the scripts to traverse symlinks until reaching the actual binary.
|
Hi @srowen @patrungel @JoshRosen and @vazin, I changed this patch to honor |
|
Jenkins, retest this please. |
|
Test build #44400 has finished for PR 8669 at commit
|
bin/beeline
Outdated
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, I very much like how this has standardized everything to use SPARK_HOME instead of FWDIR, and doesn't overwrite the value if already set. (Nit: all of the occurrences of this line have a 4-space indent instead of 2)
LGTM; does anyone see a reason this isn't a good idea? I suppose now SPARK_HOME, if set, has an effect everywhere, but it looks like the desired effect. Docs also make reference to SPARK_HOME as if it has this effect.
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.
Thanks @srowen for your comments, I will change to the 2-space indent.
|
Test build #44408 has finished for PR 8669 at commit
|
|
Test build #44423 has finished for PR 8669 at commit
|
|
Test build #44988 has finished for PR 8669 at commit
|
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 have trouble parsing what this script was doing before, but the desired outcome seems clear. The only change here is that SPARK_PREFIX is no longer set and exported, but I believe you've correctly removed usages of it in favor of SPARK_HOME. Good cleanup and standardization IMHO.
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.
This bunch of code is try to solve symlink, relative path of this file, since we now honor the SPARK_HOME to solve this issue, from my understanding the original code is not necessary.
|
LGTM. There's a lot going on here but it's all really standardizing on one approach to defining the Spark base directory. I scanned all the lines and it looks correct and carefully applied, so I feel good about merging this to master. |
|
It has been pointed out that this commit might be the cause of a regression that is possibly holding up the 1.6 release (https://issues.apache.org/jira/browse/SPARK-12345). It would be great if those involved could take a look. |
|
Thanks @marmbrus for your notice, I will take a look at the issues. |
|
It's a good lead; I'm looking too. The effect of this change should be to respect |
|
The MesosDispatchScheduler ships a number of environment variables. |
|
@dragos Did you specify |
|
@jerryshao though the scripts will now set If this is right, one of these two things could be a way forward: don't export |
|
Ohh, I see. That possibly will be the problem. One fix is to remove |
|
@dragos , if |
|
I'll check that. I don't have Spark installed on every slave node in my test setup. |
|
One more question @dragos , did you specify |
|
I believe I tried both.. |
|
@jerryshao I observed the same failure using EDIT: That's probably because |
|
I see, can you please confirm Spark is installed in this path |
|
@jerryshao Yes, it is. |
|
It is a little weird. I assume if |
|
Anyway I think we should not export |
|
I admit it is very surprising. Here's what I see Driver page on the Mesos dispatcher (note that And here is the log. Note that the executor is fetched correctly, but the |
|
If you set executorUri.isDefined then it wont reach (this is what we have as well): val executorSparkHome = conf.getOption("spark.mesos.executor.home") |
|
Yes, agree with @skonto. Why still honor SPARK_HOME, a little strange. |
|
Its because Mesos Dispatcher passed that env variable to the driver at line: In 1.6 the spark-submit script has changed... |
|
Ahhh, I see. The problem is that we expose |
|
I'm not sure it's that. It's that |

This PR is based on the work of @roji to support running Spark scripts from symlinks. Thanks for the great work @roji . Would you mind taking a look at this PR, thanks a lot.
For releases like HDP and others, normally it will expose the Spark executables as symlinks and put in
PATH, but current Spark's scripts do not support finding real path from symlink recursively, this will make spark fail to execute from symlink. This PR try to solve this issue by finding the absolute path from symlink.Instead of using
readlink -flike what this PR (#2386) implemented is that-fis not support for Mac, so here manually seeking the path through loop.I've tested with Mac and Linux (Cent OS), looks fine.
This PR did not fix the scripts under
sbinfolder, not sure if it needs to be fixed also?Please help to review, any comment is greatly appreciated.