mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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:
1 parent
17c99047b9
commit
4115becdf2
4 files changed
+64
-6
No files matched your search
+23
@@ -70,4 +70,27 @@ class EmrClusterRegionIntegrationTest {
|
||||
call(HOME, "TerminateJobFlows", "{\"JobFlowIds\":[\"" + clusterId + "\"]}")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
// Catches: an instance's or the master's private DNS name in the wrong region's domain.
|
||||
@Test
|
||||
void listedInstancesUseTheClustersRegionalPrivateDnsDomain() {
|
||||
String clusterId = call(HOME, "RunJobFlow",
|
||||
"{\"Name\":\"region-dns\",\"ReleaseLabel\":\"emr-7.5.0\","
|
||||
+ "\"Instances\":{\"KeepJobFlowAliveWhenNoSteps\":true,"
|
||||
+ "\"InstanceGroups\":[{\"Name\":\"master\",\"InstanceRole\":\"MASTER\","
|
||||
+ "\"InstanceType\":\"m5.xlarge\",\"InstanceCount\":1}]}}")
|
||||
.then().statusCode(200)
|
||||
.extract().path("JobFlowId");
|
||||
|
||||
call(HOME, "ListInstances", "{\"ClusterId\":\"" + clusterId + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Instances[0].PrivateDnsName", equalTo("ip-10-0-0-1.eu-west-1.compute.internal"))
|
||||
.body("Instances[0].PrivateIpAddress", equalTo("10.0.0.1"));
|
||||
call(HOME, "DescribeCluster", "{\"ClusterId\":\"" + clusterId + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Cluster.MasterPublicDnsName", equalTo("ip-10-0-0-1.eu-west-1.compute.internal"));
|
||||
|
||||
call(HOME, "TerminateJobFlows", "{\"JobFlowIds\":[\"" + clusterId + "\"]}")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.emr;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.restassured.response.Response;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
@@ -10,6 +11,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
@@ -30,6 +32,9 @@ class EmrIntegrationTest {
|
||||
private static String clusterId;
|
||||
private static String stepId;
|
||||
|
||||
@Inject
|
||||
EmrService emrService;
|
||||
|
||||
@BeforeAll
|
||||
static void configure() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
@@ -67,7 +72,8 @@ class EmrIntegrationTest {
|
||||
.body("Cluster.Status.State", equalTo("WAITING"))
|
||||
.body("Cluster.ReleaseLabel", equalTo("emr-7.5.0"))
|
||||
.body("Cluster.InstanceCollectionType", equalTo("INSTANCE_GROUP"))
|
||||
.body("Cluster.AutoTerminate", equalTo(false));
|
||||
.body("Cluster.AutoTerminate", equalTo(false))
|
||||
.body("Cluster.MasterPublicDnsName", equalTo("ip-10-0-0-1.ec2.internal"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +99,8 @@ class EmrIntegrationTest {
|
||||
call("ListInstances", "{\"ClusterId\":\"" + clusterId + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Instances", hasSize(3)) // 1 master + 2 core
|
||||
.body("Instances[0].Status.State", equalTo("RUNNING"));
|
||||
.body("Instances[0].Status.State", equalTo("RUNNING"))
|
||||
.body("Instances[0].PrivateDnsName", endsWith(".ec2.internal"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,4 +252,24 @@ class EmrIntegrationTest {
|
||||
.then().statusCode(200)
|
||||
.body("Cluster.Status.State", equalTo("WAITING"));
|
||||
}
|
||||
|
||||
// Catches: a cluster stored before the DNS fix keeps reporting its old us-east-1 master name.
|
||||
@Test
|
||||
void storedClusterReportsTheRegionalMasterDnsName() {
|
||||
String id = call("RunJobFlow",
|
||||
"{\"Name\":\"stale-dns\",\"ReleaseLabel\":\"emr-7.5.0\","
|
||||
+ "\"Instances\":{\"KeepJobFlowAliveWhenNoSteps\":true,"
|
||||
+ "\"InstanceGroups\":[{\"Name\":\"master\",\"InstanceRole\":\"MASTER\","
|
||||
+ "\"InstanceType\":\"m5.xlarge\",\"InstanceCount\":1}]}}")
|
||||
.then().statusCode(200)
|
||||
.extract().path("JobFlowId");
|
||||
emrService.describeCluster(id).setMasterPublicDnsName("ip-10-0-0-1.us-east-1.compute.internal");
|
||||
|
||||
call("DescribeCluster", "{\"ClusterId\":\"" + id + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Cluster.MasterPublicDnsName", equalTo("ip-10-0-0-1.ec2.internal"));
|
||||
|
||||
call("TerminateJobFlows", "{\"JobFlowIds\":[\"" + id + "\"]}")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user