You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2019/03/27 15:50:35 UTC

[impala] 06/06: Use 'wget http://169.254.169.254/' to determine if we're running in aws

This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 7079fc99a91bc140fcb278d45c428ab90642f10c
Author: Hector Acosta <he...@cloudera.com>
AuthorDate: Mon Mar 11 18:18:53 2019 -0700

    Use 'wget http://169.254.169.254/' to determine if we're running in aws
    
    https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
    lists the above endpoint as the first choice.
    
    In my running instance 'dmidecode -s bios-version' prints out:
    1.0
    
    dmidecode --string system-uuid|grep ^ec2 seems like a valid alternative
    here.
    
    I removed the 'grep' assertions since it's possible that images may have
    already configured ntp here.
    
    Change-Id: Iddb2574dbcb3f97cf697095d1777e51ce463b205
    Reviewed-on: http://gerrit.cloudera.org:8080/12727
    Reviewed-by: Joe McDonnell <jo...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 bin/bootstrap_system.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/bootstrap_system.sh b/bin/bootstrap_system.sh
index cd7a891..98cba3f 100755
--- a/bin/bootstrap_system.sh
+++ b/bin/bootstrap_system.sh
@@ -237,11 +237,11 @@ redhat6 sudo service ntpd stop
 redhat7 notindocker sudo service ntpd stop
 sudo ntpdate us.pool.ntp.org
 # If on EC2, use Amazon's ntp servers
-if which dmidecode && { sudo dmidecode -s bios-version | grep amazon; }
+# EC2 nodes expose this IP address internally as a way to gather instance metadata.
+# The assumption is that only AWS nodes do this
+if wget -q -T 1 -t 1 -o /dev/null http://169.254.169.254/latest/dynamic/instance-identity
 then
   sudo sed -i 's/ubuntu\.pool/amazon\.pool/' /etc/ntp.conf
-  grep amazon /etc/ntp.conf
-  grep ubuntu /etc/ntp.conf
 fi
 # While it is nice to have ntpd running to keep the clock in sync, that does not work in a
 # --privileged docker container, and a non-privileged container cannot run ntpdate, which