mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(emr): preserve request-level step execution role (#6061)
* fix(emr): preserve request-level step execution role * test(emr): keep integration test order unique * fix(emr): align step roles with AWS response shapes
This commit is contained in:
1 parent
c6551a47bc
commit
ae53c4b352
3 files changed
+56
-15
No files matched your search
@@ -148,7 +148,7 @@ public class EmrHandler {
|
||||
cluster.setEc2Attributes(buildEc2Attributes(instances));
|
||||
cluster.setInstanceGroups(parseInstanceGroups(instances.path("InstanceGroups")));
|
||||
cluster.setInstanceFleets(parseInstanceFleets(instances.path("InstanceFleets")));
|
||||
cluster.setSteps(parseSteps(request.path("Steps")));
|
||||
cluster.setSteps(parseSteps(request.path("Steps"), text(request, "StepExecutionRoleArn")));
|
||||
|
||||
EmrCluster created = service.runJobFlow(cluster, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
@@ -212,7 +212,8 @@ public class EmrHandler {
|
||||
// ──────────────────────────── Steps ────────────────────────────
|
||||
|
||||
private Response handleAddJobFlowSteps(JsonNode request) {
|
||||
List<String> ids = service.addJobFlowSteps(text(request, "JobFlowId"), parseSteps(request.path("Steps")));
|
||||
List<String> ids = service.addJobFlowSteps(text(request, "JobFlowId"),
|
||||
parseSteps(request.path("Steps"), text(request, "ExecutionRoleArn")));
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode arr = response.putArray("StepIds");
|
||||
ids.forEach(arr::add);
|
||||
@@ -222,7 +223,7 @@ public class EmrHandler {
|
||||
private Response handleDescribeStep(JsonNode request) {
|
||||
EmrStep step = service.describeStep(text(request, "ClusterId"), text(request, "StepId"));
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.set("Step", stepNode(step));
|
||||
response.set("Step", stepNode(step, true));
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@@ -232,7 +233,7 @@ public class EmrHandler {
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode arr = response.putArray("Steps");
|
||||
for (EmrStep step : steps) {
|
||||
arr.add(stepNode(step));
|
||||
arr.add(stepNode(step, false));
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
@@ -606,7 +607,7 @@ public class EmrHandler {
|
||||
return status;
|
||||
}
|
||||
|
||||
private ObjectNode stepNode(EmrStep step) {
|
||||
private ObjectNode stepNode(EmrStep step, boolean includeExecutionRole) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("Id", step.getId());
|
||||
node.put("Name", step.getName());
|
||||
@@ -622,6 +623,9 @@ public class EmrHandler {
|
||||
ObjectNode props = config.putObject("Properties");
|
||||
step.getProperties().forEach(props::put);
|
||||
node.put("ActionOnFailure", step.getActionOnFailure());
|
||||
if (includeExecutionRole && step.getExecutionRoleArn() != null) {
|
||||
node.put("ExecutionRoleArn", step.getExecutionRoleArn());
|
||||
}
|
||||
ObjectNode status = node.putObject("Status");
|
||||
status.put("State", step.getState());
|
||||
if (step.getStateChangeReason() != null) {
|
||||
@@ -723,7 +727,7 @@ public class EmrHandler {
|
||||
|
||||
// ──────────────────────────── Parsing ────────────────────────────
|
||||
|
||||
private List<EmrStep> parseSteps(JsonNode stepsNode) {
|
||||
private List<EmrStep> parseSteps(JsonNode stepsNode, String executionRoleArn) {
|
||||
List<EmrStep> steps = new ArrayList<>();
|
||||
if (!stepsNode.isArray()) {
|
||||
return steps;
|
||||
@@ -732,7 +736,7 @@ public class EmrHandler {
|
||||
EmrStep step = new EmrStep();
|
||||
step.setName(s.path("Name").asText(null));
|
||||
step.setActionOnFailure(s.path("ActionOnFailure").asText(null));
|
||||
step.setExecutionRoleArn(s.path("ExecutionRoleArn").asText(null));
|
||||
step.setExecutionRoleArn(executionRoleArn);
|
||||
JsonNode jar = s.path("HadoopJarStep");
|
||||
step.setJar(jar.path("Jar").asText(null));
|
||||
step.setMainClass(jar.path("MainClass").asText(null));
|
||||
|
||||
Reference in new issue
Block a user