fix(emr): use the cluster's regional private DNS domain for instances and the master (#5169)

* fix(emr): use the cluster's regional private DNS domain for instances and the master

ListInstances built every synthetic instance's PrivateDnsName as
ip-10-0-0-N.ec2.internal, the us-east-1 domain, in every region, while
RunJobFlow set MasterPublicDnsName to <region>.compute.internal, which is
wrong in us-east-1. Both now use the shared EC2 helper, so names end in
ec2.internal in us-east-1 and <region>.compute.internal elsewhere, as EC2
itself does since #5033.

* fix(emr): report the regional master DNS name for a cluster stored before the fix

DescribeCluster returned the stored MasterPublicDnsName, so a us-east-1
cluster persisted before the previous commit kept reporting
<region>.compute.internal after an upgrade. The name is now derived from the
cluster's region when the response is built.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-06 06:51:41 -04:00
1 parent 17c99047b9
commit 4115becdf2
4 files changed
+64 -6

No files matched your search

@@ -8,6 +8,7 @@ import io.github.hectorvent.floci.core.common.AwsEndpoints;
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.AwsJson11Controller;
import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.services.emr.model.EmrBlockPublicAccess;
import io.github.hectorvent.floci.services.emr.model.EmrCluster;
import io.github.hectorvent.floci.services.emr.model.EmrInstanceFleet;
@@ -492,7 +493,7 @@ public class EmrHandler {
}
node.put("NormalizedInstanceHours", c.getNormalizedInstanceHours());
if (c.getMasterPublicDnsName() != null) {
node.put("MasterPublicDnsName", c.getMasterPublicDnsName());
node.put("MasterPublicDnsName", EmrService.masterDnsName(c.getRegion()));
}
if (c.getAutoScalingRole() != null) {
node.put("AutoScalingRole", c.getAutoScalingRole());
@@ -628,8 +629,9 @@ public class EmrHandler {
node.put("Id", "ci-" + index + cluster.getId());
node.put("Ec2InstanceId", "i-" + String.format("%017d", index));
node.put("PublicDnsName", AwsEndpoints.ec2PublicDns("203.0.113." + index, cluster.getRegion()));
node.put("PrivateDnsName", "ip-10-0-0-" + index + ".ec2.internal");
node.put("PrivateIpAddress", "10.0.0." + index);
String privateIp = "10.0.0." + index;
node.put("PrivateDnsName", AwsRegions.ec2PrivateIpDnsName(privateIp, cluster.getRegion()));
node.put("PrivateIpAddress", privateIp);
node.put("InstanceGroupId", group.getId());
if (group.getMarket() != null) {
node.put("Market", group.getMarket());
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
@@ -86,7 +87,7 @@ public class EmrService {
cluster.setInstanceCollectionType(cluster.getInstanceFleets().isEmpty()
? "INSTANCE_GROUP" : "INSTANCE_FLEET");
cluster.setAutoTerminate(!cluster.isKeepJobFlowAliveWhenNoSteps());
cluster.setMasterPublicDnsName("ip-10-0-0-1." + region + ".compute.internal");
cluster.setMasterPublicDnsName(masterDnsName(region));
cluster.setCreationDateTime(Instant.now());
for (EmrInstanceGroup g : cluster.getInstanceGroups()) {
g.setId("ig-" + randomId(13));
@@ -108,6 +109,11 @@ public class EmrService {
return cluster;
}
/** The master node's private DNS name, derived from the region so a stored name never goes stale. */
static String masterDnsName(String region) {
return AwsRegions.ec2PrivateIpDnsName("10.0.0.1", region);
}
public EmrCluster describeCluster(String id) {
return requireCluster(id);
}