diff --git a/docs/services/emr-serverless.md b/docs/services/emr-serverless.md index 28a0c7aa24..dbdde8668e 100644 --- a/docs/services/emr-serverless.md +++ b/docs/services/emr-serverless.md @@ -97,7 +97,9 @@ runner mode a Spark run executes; see [Running Spark job runs](#running-spark-jo (HTTP 409) "Request did not match the original". * **Execution timeout**: `executionTimeoutMinutes` is 0 to 1,000,000, 0 meaning no timeout. From release `emr-7.11.0`, a `BATCH` run's timeout must be 1 to 10080 minutes (7 days), as the model and - the 7.11.0 release notes say; a run outside that is refused with `ValidationException`. + the 7.11.0 release notes say; a run outside that is refused with `ValidationException`. The AWS runtime for + Apache Spark's releases, `emr-spark-8.0.0` on, hold their `BATCH` runs to it too: the notes apply it "from this + release onwards", and the release list puts them after EMR Serverless 7.14.0. * **CancelJobRun** moves a run that has not finished to `CANCELLED`. A finished run answers `ValidationException` "Job run is not in a cancellable state". * **StopApplication** refuses an application with a run that has not finished, a `STREAMING` run or diff --git a/src/main/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunService.java b/src/main/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunService.java index 5b1e434ecd..a9792338a4 100644 --- a/src/main/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunService.java +++ b/src/main/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunService.java @@ -1085,8 +1085,7 @@ public class EmrServerlessJobRunService implements Resettable { // "EMR Serverless releases 7.1.0 and higher support retry attempts for streaming jobs and batch jobs." private static boolean retriesAttempts(String releaseLabel) { - return releaseAtLeast(RELEASE_LABEL, releaseLabel, 7, 1) - || SPARK_RUNTIME_RELEASE_LABEL.matcher(releaseLabel != null ? releaseLabel : "").matches(); + return releaseAtLeast(RELEASE_LABEL, releaseLabel, 7, 1) || sparkRuntime(releaseLabel); } private static void addProperties(Map properties, Map configuration, String classification) { @@ -1277,9 +1276,10 @@ public class EmrServerlessJobRunService implements Resettable { } /** - * From Amazon EMR release 7.11.0 a BATCH run's timeout is 1 to 10080 minutes; an earlier release, or - * a STREAMING run, keeps the model's 0 to 1,000,000, 0 meaning none. No source gives AWS's error, so - * the wording is Floci's. + * From Amazon EMR release 7.11.0 a BATCH run's timeout is 1 to 10080 minutes, on the AWS runtime for Apache + * Spark's releases too, as the 7.11.0 release notes' "from this release onwards" reads and the release list puts + * them after EMR Serverless 7.14.0; an earlier release, or a STREAMING run, keeps the model's 0 to 1,000,000, 0 + * meaning none. No source gives AWS's error, so the wording is Floci's. */ private static void checkBatchTimeout(Application app, StartJobRunRequest request) { Long minutes = request.getExecutionTimeoutMinutes(); @@ -1295,7 +1295,13 @@ public class EmrServerlessJobRunService implements Resettable { } private static boolean boundsBatchTimeouts(String releaseLabel) { - return releaseAtLeast(RELEASE_LABEL, releaseLabel, 7, 11); + return releaseAtLeast(RELEASE_LABEL, releaseLabel, 7, 11) || sparkRuntime(releaseLabel); + } + + // A release of the AWS runtime for Apache Spark, which starts at emr-spark-8.0-preview and comes after EMR + // Serverless 7.14.0 in the release list. + private static boolean sparkRuntime(String releaseLabel) { + return releaseAtLeast(SPARK_RUNTIME_RELEASE_LABEL, releaseLabel, 8, 0); } // Whether releaseLabel is of the family labelPattern matches, at major.minor or later. diff --git a/src/test/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunIntegrationTest.java b/src/test/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunIntegrationTest.java index 5963bc7cb3..69351ebce6 100644 --- a/src/test/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/emrserverless/EmrServerlessJobRunIntegrationTest.java @@ -599,6 +599,25 @@ class EmrServerlessJobRunIntegrationTest { } } + @Test + void theAwsRuntimeForApacheSparksBatchRunsTimeoutIsOneToTenThousandEightyMinutesToo() { + for (String release : List.of("emr-spark-8.0.0", "emr-spark-8.0-preview")) { + String runtime = createApplicationOn(release, ""); + for (String timeout : List.of(", \"executionTimeoutMinutes\": 0", ", \"executionTimeoutMinutes\": 10081")) { + startJobRun(runtime, sparkRun(UUID.randomUUID().toString(), timeout)) + .then().statusCode(400) + .body("__type", equalTo("ValidationException")) + .body("message", equalTo("executionTimeoutMinutes must be between 1 and 10080 for a BATCH " + + "job run on release emr-7.11.0 or later.")); + } + startJobRun(runtime, sparkRun(UUID.randomUUID().toString(), ", \"executionTimeoutMinutes\": 10080")) + .then().statusCode(200); + startJobRun(runtime, sparkRun(UUID.randomUUID().toString(), + ", \"mode\": \"STREAMING\", \"executionTimeoutMinutes\": 0")) + .then().statusCode(200); + } + } + @Test void aRunIsItsOneAttempt() { String applicationId = createApplication("");