From ea804b2096ccb3231efe02f710bd0c56f682c6d5 Mon Sep 17 00:00:00 2001 From: Zachary Marois Date: Sun, 7 Jan 2018 17:18:02 -0500 Subject: [PATCH] Isolating instance metadata calls --- .../priam/defaultimpl/PriamConfiguration.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java b/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java index ca92c7b72..1773439d7 100644 --- a/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java +++ b/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java @@ -172,7 +172,6 @@ public class PriamConfiguration implements IConfiguration { private static final String CONFIG_SIBLING_ASG_NAMES = PRIAM_PRE + ".az.sibling.asgnames"; private static final String CONFIG_REGION_NAME = PRIAM_PRE + ".az.region"; private static final String CONFIG_ACL_GROUP_NAME = PRIAM_PRE + ".acl.groupname"; - private final String LOCAL_IP = SystemUtils.getDataFromUrl("http://169.254.169.254/latest/meta-data/local-ipv4").trim(); private static String ASG_NAME = System.getenv("ASG_NAME"); private static String REGION = System.getenv("EC2_REGION"); private static final String CONFIG_VPC_RING = PRIAM_PRE + ".vpc"; @@ -184,7 +183,6 @@ public class PriamConfiguration implements IConfiguration { //Running instance meta data private String RAC; - private String PUBLIC_IP; //== vpc specific private String NETWORK_VPC; //Fetch the vpc id of running instance @@ -255,14 +253,6 @@ public class PriamConfiguration implements IConfiguration { @Inject public PriamConfiguration(ICredential provider, IConfigSource config, InstanceEnvIdentity insEnvIdentity) { - // public interface meta-data does not exist when Priam runs in AWS VPC (priam.vpc=true) - String p_ip = ""; - try { - p_ip = SystemUtils.getDataFromUrl("http://169.254.169.254/latest/meta-data/public-ipv4").trim(); - } catch (RuntimeException ex) { - // swallow - } - this.PUBLIC_IP = p_ip; this.provider = provider; this.config = config; this.insEnvIdentity = insEnvIdentity; @@ -284,7 +274,6 @@ public void intialize() { } RAC = instanceDataRetriever.getRac(); - PUBLIC_IP = instanceDataRetriever.getPublicIP(); NETWORK_VPC = instanceDataRetriever.getVpcId(); @@ -532,7 +521,7 @@ public List getRacs() { @Override public String getHostname() { - if (this.isVpcRing()) return LOCAL_IP; + if (this.isVpcRing()) return getInstanceDataRetriever().getPrivateIP(); else return getInstanceDataRetriever().getPublicHostname(); } @@ -690,8 +679,8 @@ public boolean isIncrBackup() { @Override public String getHostIP() { - if (this.isVpcRing()) return LOCAL_IP; - else return PUBLIC_IP; + if (this.isVpcRing()) return getInstanceDataRetriever().getPrivateIP(); + else return getInstanceDataRetriever().getPublicIP(); } @Override