Skip to content

Commit 70f6f36

Browse files
nchammasshivaram
authored andcommitted
[SPARK-4137] [EC2] Don't change working dir on user
This issue was uncovered after [this discussion](https://issues.apache.org/jira/browse/SPARK-3398?focusedCommentId=14187471&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14187471). Don't change the working directory on the user. This breaks relative paths the user may pass in, e.g., for the SSH identity file. ``` ./ec2/spark-ec2 -i ../my.pem ``` This patch will preserve the user's current working directory and allow calls like the one above to work. Author: Nicholas Chammas <[email protected]> Closes #2988 from nchammas/spark-ec2-cwd and squashes the following commits: f3850b5 [Nicholas Chammas] pep8 fix fbc20c7 [Nicholas Chammas] revert to old commenting style 752f958 [Nicholas Chammas] specify deploy.generic path absolutely bcdf6a5 [Nicholas Chammas] fix typo 77871a2 [Nicholas Chammas] add clarifying comment ce071fc [Nicholas Chammas] don't change working dir (cherry picked from commit db45f5a) Signed-off-by: Shivaram Venkataraman <[email protected]>
1 parent 7e0da9f commit 70f6f36

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

ec2/spark-ec2

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
# limitations under the License.
1919
#
2020

21-
cd "`dirname $0`"
22-
PYTHONPATH="./third_party/boto-2.4.1.zip/boto-2.4.1:$PYTHONPATH" python ./spark_ec2.py "$@"
21+
# Preserve the user's CWD so that relative paths are passed correctly to
22+
#+ the underlying Python script.
23+
SPARK_EC2_DIR="$(dirname $0)"
24+
25+
PYTHONPATH="${SPARK_EC2_DIR}/third_party/boto-2.4.1.zip/boto-2.4.1:$PYTHONPATH" \
26+
python "${SPARK_EC2_DIR}/spark_ec2.py" "$@"

ec2/spark_ec2.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from boto import ec2
4141

4242
DEFAULT_SPARK_VERSION = "1.1.0"
43+
SPARK_EC2_DIR = os.path.dirname(os.path.realpath(__file__))
4344

4445
MESOS_SPARK_EC2_BRANCH = "v4"
4546
# A URL prefix from which to fetch AMI information
@@ -593,7 +594,14 @@ def setup_cluster(conn, master_nodes, slave_nodes, opts, deploy_ssh_key):
593594
)
594595

595596
print "Deploying files to master..."
596-
deploy_files(conn, "deploy.generic", opts, master_nodes, slave_nodes, modules)
597+
deploy_files(
598+
conn=conn,
599+
root_dir=SPARK_EC2_DIR + "/" + "deploy.generic",
600+
opts=opts,
601+
master_nodes=master_nodes,
602+
slave_nodes=slave_nodes,
603+
modules=modules
604+
)
597605

598606
print "Running setup on master..."
599607
setup_spark_cluster(master, opts)
@@ -730,6 +738,8 @@ def get_num_disks(instance_type):
730738
# cluster (e.g. lists of masters and slaves). Files are only deployed to
731739
# the first master instance in the cluster, and we expect the setup
732740
# script to be run on that instance to copy them to other nodes.
741+
#
742+
# root_dir should be an absolute path to the directory with the files we want to deploy.
733743
def deploy_files(conn, root_dir, opts, master_nodes, slave_nodes, modules):
734744
active_master = master_nodes[0].public_dns_name
735745

0 commit comments

Comments
 (0)