-
Notifications
You must be signed in to change notification settings - Fork 114
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
Spark-5246 resolving hostname #91
Changes from 2 commits
0a3c43a
25240e5
f7ef50d
367a4ed
994a1bf
58605f6
cb2c034
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# Starting new instance in VPC often results that `hostname` returns something like 'ip-10-1-1-24', which is | ||
# not resolvable. Which leads to problems like SparkUI failing to bind itself on start up to that hostname as | ||
# described in https://issues.apache.org/jira/browse/SPARK-5246. | ||
# This script maps private ip to such hostname via '/etc/hosts'. | ||
# | ||
|
||
#Are we in VPC? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor nits: Space after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed and pushed |
||
MAC=`wget -q -O - http://169.254.169.254/latest/meta-data/mac` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is used on line 11 |
||
VCP_ID=`wget -q -O - http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC}/vpc-id` | ||
if [ -n "${VCP_ID}" ]; then | ||
#echo "nothing to do - instance is not in VPC" | ||
exit 0 | ||
fi | ||
|
||
SHORT_HOSTNAME=`hostname` | ||
|
||
PRIVATE_IP=`wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4` | ||
|
||
# do changes only if short hostname does not resolve | ||
if ( ! ping -c 1 -q "${SHORT_HOSTNAME}" > /dev/null 2>&1 ); then | ||
echo -e "\n ${PRIVATE_IP} ${SHORT_HOSTNAME}\n" >> /etc/hosts | ||
|
||
#let's make sure that it got fixed | ||
if ( ! ping -c 1 -q "${SHORT_HOSTNAME}" > /dev/null 2>&1 ); then | ||
#return some non-zero code to indicate problem | ||
echo "Possible bug: unable to fix resolution of local hostname" | ||
return 62 | ||
fi | ||
|
||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ source ec2-variables.sh | |
|
||
# Set hostname based on EC2 private DNS name, so that it is set correctly | ||
# even if the instance is restarted with a different private DNS name | ||
PRIVATE_DNS=`wget -q -O - http://instance-data.ec2.internal/latest/meta-data/local-hostname` | ||
PRIVATE_DNS=`wget -q -O - http://169.254.169.254/latest/meta-data/local-hostname` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to invoke the new setup-hostname script here -- You can assume that the spark-ec2 directory exists, so just adding a line like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about creation of "module" and putting it in the list of modules in spark-ec2.py before "spark" module. It might be better to do it your way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - modules are more appropriate for new packages or something like that. For things like fixing hostnames we can just put it in the top level directory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it to setup-slave.sh as you suggested. Should it also be invoked from setup.sh? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - setup-slave.sh is invoked on all machines (including the master node). So this should be enough |
||
hostname $PRIVATE_DNS | ||
echo $PRIVATE_DNS > /etc/hostname | ||
HOSTNAME=$PRIVATE_DNS # Fix the bash built-in hostname variable too | ||
|
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.
Lets rename this to something like
resolve-hostname.sh
orsetup-hostname.sh
in the top-level directory