mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(emr): reject steps after cluster termination (#6115)
* fix(emr): reject steps after cluster termination * docs(emr): document terminated cluster step rejection
This commit is contained in:
1 parent
03f87285a0
commit
0dab646373
3 files changed
+37
-3
No files matched your search
@@ -61,6 +61,8 @@ steps added later complete, reporting `ALL_STEPS_COMPLETED`. A cluster with no s
|
||||
`WAITING` until steps are added. Set `KeepJobFlowAliveWhenNoSteps` to `true` to keep the cluster
|
||||
`WAITING` after its steps complete. Automatic step-completion termination also applies when
|
||||
termination protection is enabled.
|
||||
`AddJobFlowSteps` rejects a terminated cluster without adding steps or changing its
|
||||
termination status.
|
||||
After automatic or manual termination, instance groups and fleets report `TERMINATED` with zero
|
||||
running or provisioned capacity; their requested and target capacities remain recorded.
|
||||
`ListInstances` retains each group's instances with their original synthetic IDs and `TERMINATED`
|
||||
|
||||
@@ -201,6 +201,10 @@ public class EmrService {
|
||||
|
||||
public synchronized List<String> addJobFlowSteps(String clusterId, List<EmrStep> steps) {
|
||||
EmrCluster cluster = requireCluster(clusterId);
|
||||
if ("TERMINATED".equals(cluster.getState())) {
|
||||
throw new AwsException("ValidationException",
|
||||
"A job flow that is shutting down, terminated, or finished may not be modified.", 400);
|
||||
}
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (EmrStep step : steps) {
|
||||
initStep(step);
|
||||
|
||||
+31
-3
@@ -84,7 +84,7 @@ class EmrTransientIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void addingStepsAfterUserTerminationPreservesReasonAndEndTime() {
|
||||
void addingStepsAfterUserTerminationIsRejectedWithoutChangingCluster() {
|
||||
String clusterId = emr("RunJobFlow", "{\"Name\":\"manually-ended-transient\",\"Instances\":{}}")
|
||||
.then().statusCode(200).extract().path("JobFlowId");
|
||||
String clusterRequest = "{\"ClusterId\":\"" + clusterId + "\"}";
|
||||
@@ -97,14 +97,42 @@ class EmrTransientIntegrationTest {
|
||||
emr("AddJobFlowSteps",
|
||||
"{\"JobFlowId\":\"" + clusterId + "\",\"Steps\":[{\"Name\":\"late\","
|
||||
+ "\"HadoopJarStep\":{\"Jar\":\"command-runner.jar\"}}]}")
|
||||
.then().statusCode(200);
|
||||
emr("ListSteps", clusterRequest).then().statusCode(200).body("Steps", hasSize(1));
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo(
|
||||
"A job flow that is shutting down, terminated, or finished may not be modified."));
|
||||
emr("ListSteps", clusterRequest).then().statusCode(200).body("Steps", hasSize(0));
|
||||
emr("DescribeCluster", clusterRequest).then().statusCode(200)
|
||||
.body("Cluster.Status.State", equalTo("TERMINATED"))
|
||||
.body("Cluster.Status.StateChangeReason.Code", equalTo("USER_REQUEST"))
|
||||
.body("Cluster.Status.Timeline.EndDateTime", equalTo(endTime));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addingStepsAfterAutomaticTerminationIsRejected() {
|
||||
String clusterId = emr("RunJobFlow",
|
||||
"{\"Name\":\"auto-ended\",\"Instances\":{},"
|
||||
+ "\"Steps\":[{\"Name\":\"initial\","
|
||||
+ "\"HadoopJarStep\":{\"Jar\":\"command-runner.jar\"}}]}")
|
||||
.then().statusCode(200).extract().path("JobFlowId");
|
||||
String clusterRequest = "{\"ClusterId\":\"" + clusterId + "\"}";
|
||||
emr("DescribeCluster", clusterRequest).then().statusCode(200)
|
||||
.body("Cluster.Status.State", equalTo("TERMINATED"))
|
||||
.body("Cluster.Status.StateChangeReason.Code", equalTo("ALL_STEPS_COMPLETED"));
|
||||
|
||||
emr("AddJobFlowSteps",
|
||||
"{\"JobFlowId\":\"" + clusterId + "\",\"Steps\":[{\"Name\":\"late\","
|
||||
+ "\"HadoopJarStep\":{\"Jar\":\"command-runner.jar\"}}]}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo(
|
||||
"A job flow that is shutting down, terminated, or finished may not be modified."));
|
||||
emr("ListSteps", clusterRequest).then().statusCode(200).body("Steps", hasSize(1));
|
||||
emr("DescribeCluster", clusterRequest).then().statusCode(200)
|
||||
.body("Cluster.Status.State", equalTo("TERMINATED"))
|
||||
.body("Cluster.Status.StateChangeReason.Code", equalTo("ALL_STEPS_COMPLETED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void protectedCompletedClusterIsSkippedDuringMixedTermination() {
|
||||
String completedId = emr("RunJobFlow",
|
||||
|
||||
Reference in new issue
Block a user