fix(emr-serverless): release capacity after driver address failure (#8250)

Signed-off-by: Andre Kurait <AndreKurait@users.noreply.github.com>
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Jackson PriceandAndre Kurait authored and GitHub committed 2026-11-14 00:01:18 -04:00
1 parent e201709363
commit f087599883
2 files changed
+27

No files matched your search

@@ -559,6 +559,8 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
// application's capacity with them.
if (executors != null) {
executors.removeAll();
}
if (capacity != null) {
leaveCapacity(job.executors().application(), capacity);
}
String unclaimed = launches.end(job.runId(), launch);
@@ -547,6 +547,31 @@ class EmrServerlessSparkRunnerTest {
assertNotSame(first, runner.joinCapacity("arn:aws:emr-serverless:eu-west-1:123456789012:/app/a"));
}
@Test
void aDriverWhoseAddressLookupFailsLeavesItsApplicationsCapacity() {
String application = "arn:aws:emr-serverless:eu-west-1:123456789012:/app/failed-driver";
ContainerBuilder builder = mock(ContainerBuilder.class);
ContainerBuilder.Builder spec = mock(ContainerBuilder.Builder.class, RETURNS_SELF);
when(builder.newContainer(anyString())).thenReturn(spec);
when(builder.resolveDockerNetwork(Optional.of("floci-network"))).thenReturn(Optional.of("floci-network"));
EmrServerlessSparkRunner runner = runner(builder);
NotFoundException addressFailure = new NotFoundException("driver disappeared during address lookup");
when(lifecycle.resolveContainerNetworkIp("driver", "floci-network")).thenThrow(addressFailure);
SparkJobRunner.Job job = executorsJob(Map.of()).withExecutors(
new SparkJobRunner.Executors(2, null, 0, 0, 0, application));
SparkJobRunner.Outcome outcome = runner.run(job, progress);
assertEquals(SparkJobRunner.Outcome.couldNotStart(addressFailure.getMessage()), outcome);
verify(progress).started();
verify(lifecycle).stopAndRemove("driver", null, 0);
verify(lifecycle, never()).createAndStart(any());
SparkExecutors.Capacity firstAfterFailure = runner.joinCapacity(application);
runner.leaveCapacity(application, firstAfterFailure);
SparkExecutors.Capacity secondAfterFailure = runner.joinCapacity(application);
assertNotSame(firstAfterFailure, secondAfterFailure,
"a balanced subsequent membership must retire its capacity object");
}
@Test
void theReleasesImageForARunsExecutorsIsPulledWhenMissingBeforeTheDriverStarts() {
ContainerBuilder builder = mock(ContainerBuilder.class);