apache/dolphinscheduler · error · TaskException

emr task submit fail

Error message

emr task submit fail

What it means

EmrAddStepsTask.submitApplication wraps EmrTaskException and AWS SDK SdkBaseException from the add-steps flow (runJobFlow for cluster creation and AddSteps) into TaskException 'emr task submit fail'. The finally block computes an exit status from the (possibly null) stepStatus. The real AWS error is in the cause and in the 'emr task submit failed with error' log line.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java:93

    @Override
    public void submitApplication() throws TaskException {
        StepStatus stepStatus = null;
        try {
            AddJobFlowStepsRequest addJobFlowStepsRequest = createAddJobFlowStepsRequest();

            // submit addJobFlowStepsRequest to aws
            AddJobFlowStepsResult result = emrClient.addJobFlowSteps(addJobFlowStepsRequest);

            clusterId = addJobFlowStepsRequest.getJobFlowId();
            stepId = result.getStepIds().get(0);
            // use clusterId-stepId as appIds
            setAppIds(clusterId + TaskConstants.SUBTRACT_STRING + stepId);

            stepStatus = getStepStatus();

        } catch (EmrTaskException | SdkBaseException e) {
            log.error("emr task submit failed with error", e);
            throw new TaskException("emr task submit fail", e);
        } finally {
            final int exitStatusCode = calculateExitStatusCode(stepStatus);
            setExitStatusCode(exitStatusCode);
            log.info("emr task finished with step status : {}", stepStatus);
        }
    }

    @Override
    public void trackApplicationStatus() throws TaskException {
        StepStatus stepStatus = getStepStatus();

        try {
            while (waitingStateSet.contains(stepStatus.getState())) {
                TimeUnit.SECONDS.sleep(10);
                stepStatus = getStepStatus();
            }
        } catch (EmrTaskException | SdkBaseException e) {
            log.error("emr task failed with error", e);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Read the 'caused by' AWS error in the log line 'emr task submit failed with error'
  2. Verify IAM: task's execution credentials need emr:RunJobFlow/emr:AddSteps and the configured service role/instance profile exist
  3. Confirm S3 paths for jars/scripts/bootstrap actions are correct and readable by the EMR instance profile
  4. Check releaseLabel vs configured applications (e.g. Hive/Spark installed) and region
  5. If InsufficientInstanceCapacity, retry later or change instance types/subnet

Example fix

// before
"steps": [{ "name": "s1", "jarPath": "s3://mybucket/missing.jar" }] // path wrong -> step rejected
// after
"steps": [{ "name": "s1", "jarPath": "s3://mybucket/lib/app-1.0.jar", "mainClass": "com.x.Main" }]
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: IAM + step config sanity before RunJobFlow/AddSteps
AWSCredentials creds = new DefaultAWSCredentialsProviderChain().getCredentials();
// caller-side check on task definition:
if (StringUtils.isBlank(emrParameters.getClusterId()) && emrParameters.getSteps().isEmpty()) {
    throw new IllegalArgumentException("Provide clusterId for existing cluster or steps for RunJobFlow");
}
// verify S3 paths exist:
// new AmazonS3Client().doesObjectExist(bucket, key) for jarPath/script paths

Type guard

boolean isServiceError(SdkBaseException e) {
    return e instanceof AmazonServiceException
        && ((AmazonServiceException) e).getErrorCode() != null;
}

Try / catch

try {
    submitApplication();
} catch (TaskException e) {
    Throwable cause = e.getCause();
    if (cause instanceof AmazonServiceException) {
        AmazonServiceException ase = (AmazonServiceException) cause;
        log.error("EMR submit rejected: code={}, msg={}", ase.getErrorCode(), ase.getErrorMessage());
        if ("InsufficientInstanceCapacity".equals(ase.getErrorCode())) { /* retry later */ }
    }
    throw e;
}

Prevention

When it happens

Trigger: runJobFlow or addJobFlowSteps throws SdkBaseException: invalid cluster/run-job-flow params, missing EMR IAM (service role/instance profile), S3 script path inaccessible, capacity errors, or the EMR API rejects the step configuration.

Common situations: EMR service role missing; bootstrap action or application name invalid for the releaseLabel; VPC/subnet lacks capacity (InsufficientInstanceCapacity); user lacks emr:RunJobFlow/emr:AddSteps; step jar/script path typo in S3.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/a39e25dc83ef137a. Report an issue: GitHub.