{"action":"created","comment":{"url":"https://api.github.com/repos/mesos/spark-ec2/pulls/comments/23131271","id":23131271,"diff_hunk":"@@ -0,0 +1,32 @@\n+#!/bin/bash\n+\n+# Starting new instance in VPC often results that `hostname` returns something like 'ip-10-1-1-24', which is\n+# not resolvable. Which leads to problems like SparkUI failing to bind itself on start up to that hostname as\n+# described in https://issues.apache.org/jira/browse/SPARK-5246.\n+# This script maps private ip to such hostname via '/etc/hosts'.\n+#\n+\n+# Are we in VPC?\n+MAC=`wget -q -O - http://169.254.169.254/latest/meta-data/mac`\n+VCP_ID=`wget -q -O - http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC}/vpc-id`\n+if [ -n \"${VCP_ID}\" ]; then\n+    # echo \"nothing to do - instance is not in VPC\"\n+    exit 0\n+fi\n+\n+SHORT_HOSTNAME=`hostname`\n+\n+PRIVATE_IP=`wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4`\n+\n+# do changes only if short hostname does not resolve\n+if ( ! ping -c 1 -q \"${SHORT_HOSTNAME}\" > /dev/null 2>&1 ); then","path":"resolve-hostname.sh","position":null,"original_position":22,"commit_id":"cb2c0346f14b7f6842003b7dc71abb6a2650e9df","original_commit_id":"994a1bf64a2803ec02530bd06540315160e9508a","user":{"login":"voukka","id":207265,"avatar_url":"https://avatars.githubusercontent.com/u/207265?v=3","gravatar_id":"","url":"https://api.github.com/users/voukka","html_url":"https://github.com/voukka","followers_url":"https://api.github.com/users/voukka/followers","following_url":"https://api.github.com/users/voukka/following{/other_user}","gists_url":"https://api.github.com/users/voukka/gists{/gist_id}","starred_url":"https://api.github.com/users/voukka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voukka/subscriptions","organizations_url":"https://api.github.com/users/voukka/orgs","repos_url":"https://api.github.com/users/voukka/repos","events_url":"https://api.github.com/users/voukka/events{/privacy}","received_events_url":"https://api.github.com/users/voukka/received_events","type":"User","site_admin":false},"body":"fixed\r\n\r\n> On 18 Jan 2015, at 07:35, Shivaram Venkataraman <notifications@github.com> wrote:\r\n> \r\n> In resolve-hostname.sh:\r\n> \r\n> > +#\r\n> > +\r\n> > +# Are we in VPC?\r\n> > +MAC=`wget -q -O - http://169.254.169.254/latest/meta-data/mac`\r\n> > +VCP_ID=`wget -q -O - http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC}/vpc-id`\r\n> > +if [ -n \"${VCP_ID}\" ]; then\r\n> > +    # echo \"nothing to do - instance is not in VPC\"\r\n> > +    exit 0\r\n> > +fi\r\n> > +\r\n> > +SHORT_HOSTNAME=`hostname`\r\n> > +\r\n> > +PRIVATE_IP=`wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4`\r\n> > +\r\n> > +# do changes only if short hostname does not resolve\r\n> > +if ( ! ping -c 1 -q \"${SHORT_HOSTNAME}\" > /dev/null 2>&1 ); then\r\n> Minor style comment: We use [[ or [ with if statements in all our scripts. Could you change this and line 26 to match that ?\r\n> \r\n> —\r\n> Reply to this email directly or view it on GitHub.\r\n> ","created_at":"2015-01-18T06:28:28Z","updated_at":"2015-01-18T06:28:28Z","html_url":"https://github.com/mesos/spark-ec2/pull/91#discussion_r23131271","pull_request_url":"https://api.github.com/repos/mesos/spark-ec2/pulls/91","_links":{"self":{"href":"https://api.github.com/repos/mesos/spark-ec2/pulls/comments/23131271"},"html":{"href":"https://github.com/mesos/spark-ec2/pull/91#discussion_r23131271"},"pull_request":{"href":"https://api.github.com/repos/mesos/spark-ec2/pulls/91"}}},"pull_request":{"url":"https://api.github.com/repos/mesos/spark-ec2/pulls/91","id":27435019,"html_url":"https://github.com/mesos/spark-ec2/pull/91","diff_url":"https://github.com/mesos/spark-ec2/pull/91.diff","patch_url":"https://github.com/mesos/spark-ec2/pull/91.patch","issue_url":"https://api.github.com/repos/mesos/spark-ec2/issues/91","number":91,"state":"open","locked":false,"title":"Spark-5246 resolving hostname","user":{"login":"voukka","id":207265,"avatar_url":"https://avatars.githubusercontent.com/u/207265?v=3","gravatar_id":"","url":"https://api.github.com/users/voukka","html_url":"https://github.com/voukka","followers_url":"https://api.github.com/users/voukka/followers","following_url":"https://api.github.com/users/voukka/following{/other_user}","gists_url":"https://api.github.com/users/voukka/gists{/gist_id}","starred_url":"https://api.github.com/users/voukka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voukka/subscriptions","organizations_url":"https://api.github.com/users/voukka/orgs","repos_url":"https://api.github.com/users/voukka/repos","events_url":"https://api.github.com/users/voukka/events{/privacy}","received_events_url":"https://api.github.com/users/voukka/received_events","type":"User","site_admin":false},"body":"Please see https://issues.apache.org/jira/browse/SPARK-5246\r\n\r\nFix for local hostname problem in VPC","created_at":"2015-01-15T15:13:17Z","updated_at":"2015-01-18T06:28:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fcaee2e4024916f784df25610cdf201bbef0495","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mesos/spark-ec2/pulls/91/commits","review_comments_url":"https://api.github.com/repos/mesos/spark-ec2/pulls/91/comments","review_comment_url":"https://api.github.com/repos/mesos/spark-ec2/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mesos/spark-ec2/issues/91/comments","statuses_url":"https://api.github.com/repos/mesos/spark-ec2/statuses/cb2c0346f14b7f6842003b7dc71abb6a2650e9df","head":{"label":"voukka:SPARK-5246_voukka_resolving_hostname","ref":"SPARK-5246_voukka_resolving_hostname","sha":"cb2c0346f14b7f6842003b7dc71abb6a2650e9df","user":{"login":"voukka","id":207265,"avatar_url":"https://avatars.githubusercontent.com/u/207265?v=3","gravatar_id":"","url":"https://api.github.com/users/voukka","html_url":"https://github.com/voukka","followers_url":"https://api.github.com/users/voukka/followers","following_url":"https://api.github.com/users/voukka/following{/other_user}","gists_url":"https://api.github.com/users/voukka/gists{/gist_id}","starred_url":"https://api.github.com/users/voukka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voukka/subscriptions","organizations_url":"https://api.github.com/users/voukka/orgs","repos_url":"https://api.github.com/users/voukka/repos","events_url":"https://api.github.com/users/voukka/events{/privacy}","received_events_url":"https://api.github.com/users/voukka/received_events","type":"User","site_admin":false},"repo":{"id":29236685,"name":"spark-ec2","full_name":"voukka/spark-ec2","owner":{"login":"voukka","id":207265,"avatar_url":"https://avatars.githubusercontent.com/u/207265?v=3","gravatar_id":"","url":"https://api.github.com/users/voukka","html_url":"https://github.com/voukka","followers_url":"https://api.github.com/users/voukka/followers","following_url":"https://api.github.com/users/voukka/following{/other_user}","gists_url":"https://api.github.com/users/voukka/gists{/gist_id}","starred_url":"https://api.github.com/users/voukka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voukka/subscriptions","organizations_url":"https://api.github.com/users/voukka/orgs","repos_url":"https://api.github.com/users/voukka/repos","events_url":"https://api.github.com/users/voukka/events{/privacy}","received_events_url":"https://api.github.com/users/voukka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/voukka/spark-ec2","description":"Scripts used to setup a Spark cluster on EC2","fork":true,"url":"https://api.github.com/repos/voukka/spark-ec2","forks_url":"https://api.github.com/repos/voukka/spark-ec2/forks","keys_url":"https://api.github.com/repos/voukka/spark-ec2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/voukka/spark-ec2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/voukka/spark-ec2/teams","hooks_url":"https://api.github.com/repos/voukka/spark-ec2/hooks","issue_events_url":"https://api.github.com/repos/voukka/spark-ec2/issues/events{/number}","events_url":"https://api.github.com/repos/voukka/spark-ec2/events","assignees_url":"https://api.github.com/repos/voukka/spark-ec2/assignees{/user}","branches_url":"https://api.github.com/repos/voukka/spark-ec2/branches{/branch}","tags_url":"https://api.github.com/repos/voukka/spark-ec2/tags","blobs_url":"https://api.github.com/repos/voukka/spark-ec2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/voukka/spark-ec2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/voukka/spark-ec2/git/refs{/sha}","trees_url":"https://api.github.com/repos/voukka/spark-ec2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/voukka/spark-ec2/statuses/{sha}","languages_url":"https://api.github.com/repos/voukka/spark-ec2/languages","stargazers_url":"https://api.github.com/repos/voukka/spark-ec2/stargazers","contributors_url":"https://api.github.com/repos/voukka/spark-ec2/contributors","subscribers_url":"https://api.github.com/repos/voukka/spark-ec2/subscribers","subscription_url":"https://api.github.com/repos/voukka/spark-ec2/subscription","commits_url":"https://api.github.com/repos/voukka/spark-ec2/commits{/sha}","git_commits_url":"https://api.github.com/repos/voukka/spark-ec2/git/commits{/sha}","comments_url":"https://api.github.com/repos/voukka/spark-ec2/comments{/number}","issue_comment_url":"https://api.github.com/repos/voukka/spark-ec2/issues/comments/{number}","contents_url":"https://api.github.com/repos/voukka/spark-ec2/contents/{+path}","compare_url":"https://api.github.com/repos/voukka/spark-ec2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/voukka/spark-ec2/merges","archive_url":"https://api.github.com/repos/voukka/spark-ec2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/voukka/spark-ec2/downloads","issues_url":"https://api.github.com/repos/voukka/spark-ec2/issues{/number}","pulls_url":"https://api.github.com/repos/voukka/spark-ec2/pulls{/number}","milestones_url":"https://api.github.com/repos/voukka/spark-ec2/milestones{/number}","notifications_url":"https://api.github.com/repos/voukka/spark-ec2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/voukka/spark-ec2/labels{/name}","releases_url":"https://api.github.com/repos/voukka/spark-ec2/releases{/id}","created_at":"2015-01-14T09:22:20Z","updated_at":"2015-01-14T09:22:21Z","pushed_at":"2015-01-18T06:27:18Z","git_url":"git://github.com/voukka/spark-ec2.git","ssh_url":"git@github.com:voukka/spark-ec2.git","clone_url":"https://github.com/voukka/spark-ec2.git","svn_url":"https://github.com/voukka/spark-ec2","homepage":null,"size":985,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"v4"}},"base":{"label":"mesos:branch-1.3","ref":"branch-1.3","sha":"3a95101c70e6892a8a48cc54094adaed1458487a","user":{"login":"mesos","id":229272,"avatar_url":"https://avatars.githubusercontent.com/u/229272?v=3","gravatar_id":"","url":"https://api.github.com/users/mesos","html_url":"https://github.com/mesos","followers_url":"https://api.github.com/users/mesos/followers","following_url":"https://api.github.com/users/mesos/following{/other_user}","gists_url":"https://api.github.com/users/mesos/gists{/gist_id}","starred_url":"https://api.github.com/users/mesos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesos/subscriptions","organizations_url":"https://api.github.com/users/mesos/orgs","repos_url":"https://api.github.com/users/mesos/repos","events_url":"https://api.github.com/users/mesos/events{/privacy}","received_events_url":"https://api.github.com/users/mesos/received_events","type":"Organization","site_admin":false},"repo":{"id":8257251,"name":"spark-ec2","full_name":"mesos/spark-ec2","owner":{"login":"mesos","id":229272,"avatar_url":"https://avatars.githubusercontent.com/u/229272?v=3","gravatar_id":"","url":"https://api.github.com/users/mesos","html_url":"https://github.com/mesos","followers_url":"https://api.github.com/users/mesos/followers","following_url":"https://api.github.com/users/mesos/following{/other_user}","gists_url":"https://api.github.com/users/mesos/gists{/gist_id}","starred_url":"https://api.github.com/users/mesos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesos/subscriptions","organizations_url":"https://api.github.com/users/mesos/orgs","repos_url":"https://api.github.com/users/mesos/repos","events_url":"https://api.github.com/users/mesos/events{/privacy}","received_events_url":"https://api.github.com/users/mesos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesos/spark-ec2","description":"Scripts used to setup a Spark cluster on EC2","fork":true,"url":"https://api.github.com/repos/mesos/spark-ec2","forks_url":"https://api.github.com/repos/mesos/spark-ec2/forks","keys_url":"https://api.github.com/repos/mesos/spark-ec2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesos/spark-ec2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesos/spark-ec2/teams","hooks_url":"https://api.github.com/repos/mesos/spark-ec2/hooks","issue_events_url":"https://api.github.com/repos/mesos/spark-ec2/issues/events{/number}","events_url":"https://api.github.com/repos/mesos/spark-ec2/events","assignees_url":"https://api.github.com/repos/mesos/spark-ec2/assignees{/user}","branches_url":"https://api.github.com/repos/mesos/spark-ec2/branches{/branch}","tags_url":"https://api.github.com/repos/mesos/spark-ec2/tags","blobs_url":"https://api.github.com/repos/mesos/spark-ec2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesos/spark-ec2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesos/spark-ec2/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesos/spark-ec2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesos/spark-ec2/statuses/{sha}","languages_url":"https://api.github.com/repos/mesos/spark-ec2/languages","stargazers_url":"https://api.github.com/repos/mesos/spark-ec2/stargazers","contributors_url":"https://api.github.com/repos/mesos/spark-ec2/contributors","subscribers_url":"https://api.github.com/repos/mesos/spark-ec2/subscribers","subscription_url":"https://api.github.com/repos/mesos/spark-ec2/subscription","commits_url":"https://api.github.com/repos/mesos/spark-ec2/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesos/spark-ec2/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesos/spark-ec2/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesos/spark-ec2/issues/comments/{number}","contents_url":"https://api.github.com/repos/mesos/spark-ec2/contents/{+path}","compare_url":"https://api.github.com/repos/mesos/spark-ec2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesos/spark-ec2/merges","archive_url":"https://api.github.com/repos/mesos/spark-ec2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesos/spark-ec2/downloads","issues_url":"https://api.github.com/repos/mesos/spark-ec2/issues{/number}","pulls_url":"https://api.github.com/repos/mesos/spark-ec2/pulls{/number}","milestones_url":"https://api.github.com/repos/mesos/spark-ec2/milestones{/number}","notifications_url":"https://api.github.com/repos/mesos/spark-ec2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesos/spark-ec2/labels{/name}","releases_url":"https://api.github.com/repos/mesos/spark-ec2/releases{/id}","created_at":"2013-02-17T21:51:50Z","updated_at":"2015-01-15T04:39:41Z","pushed_at":"2015-01-09T03:10:22Z","git_url":"git://github.com/mesos/spark-ec2.git","ssh_url":"git@github.com:mesos/spark-ec2.git","clone_url":"https://github.com/mesos/spark-ec2.git","svn_url":"https://github.com/mesos/spark-ec2","homepage":null,"size":985,"stargazers_count":40,"watchers_count":40,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":4,"forks":76,"open_issues":4,"watchers":40,"default_branch":"branch-1.3"}},"_links":{"self":{"href":"https://api.github.com/repos/mesos/spark-ec2/pulls/91"},"html":{"href":"https://github.com/mesos/spark-ec2/pull/91"},"issue":{"href":"https://api.github.com/repos/mesos/spark-ec2/issues/91"},"comments":{"href":"https://api.github.com/repos/mesos/spark-ec2/issues/91/comments"},"review_comments":{"href":"https://api.github.com/repos/mesos/spark-ec2/pulls/91/comments"},"review_comment":{"href":"https://api.github.com/repos/mesos/spark-ec2/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mesos/spark-ec2/pulls/91/commits"},"statuses":{"href":"https://api.github.com/repos/mesos/spark-ec2/statuses/cb2c0346f14b7f6842003b7dc71abb6a2650e9df"}}}}