1 year ago
#188564
Gary Tessman
PCF Tasks on Active/Passive
Can someone help me understand how PCF Tasks in Active/Passive environment would work? It's my understanding that when deployed in Active, and mirrored in a Passive environment that the PCF Tasks would still run on the defined Job Schedules regardless if it's running on active or passive.
If this is true, is there a way for my PCF Task (a Java application) to programmatically check if it's running on Passive (then do nothing), or Active (do my operations)? I don't want to perform tasks on Passive until failover happens (where passive becomes Active, and active becomes Passive) and I only have one Task running from Active at any given time.
I tried getting the A Record from the FQDN (my apps route hostname) and then comparing it to localhost IP to determine if my running current IP matches the resolved hostname IP and therefore I'm running on Active... but I believe I am only getting an IP of a private Diego Cell or something (not sure yet).
private boolean isActive() {
try {
InetAddress inetHost = InetAddress.getByName(properties.getFqdn());
InetAddress inetSelf = InetAddress.getLocalHost();
logger.info("host FQDN IP: {}, self localhost IP: {}", inetHost.getHostAddress(), inetSelf.getHostAddress());
if (null != inetHost && null != inetSelf) { return (inetHost.getHostAddress().equals(inetSelf.getHostAddress())); }
} catch (UnknownHostException e) {
logger.error(e.getMessage());
}
return false;
}
What am I missing here? Doesn't seem like it should be that complicated given that Tasks are part of PCF and Active/Passive is a normal and preferred setup.
I'd really just like Tasks during failover or failback to just start/stop working without any additional interactions.
Thank you for any suggestions!
cloud-foundry
pcf
pcfdev
0 Answers
Your Answer