fix(batch): put a job's container on its compute environment's VPC network (#8509)

This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-15 18:09:00 -04:00
1 parent ca032c1a03
commit 0fccd475b7
8 files changed
+323 -89

No files matched your search

@@ -60,7 +60,7 @@ class BatchDockerRunnerDockerIntegrationTest {
test "$FLOCI_HOSTNAME" = "%s"
""".formatted(expectedEndpoint, expectedEndpoint, expectedHostname)));
BatchRunResult result = runner.run(job, 1);
BatchRunResult result = runner.run(job, 1, null);
assertEquals(0, result.exitCode(), result.reason());
}
@@ -1,7 +1,10 @@
package io.floci.aws.services.batch;
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.InspectContainerResponse;
import com.github.dockerjava.api.exception.NotFoundException;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.common.dns.EmbeddedDnsServer;
import io.floci.aws.core.common.docker.ContainerBuilder;
import io.floci.aws.core.common.docker.ContainerDetector;
@@ -11,8 +14,14 @@ import io.floci.aws.core.common.docker.ContainerSpec;
import io.floci.aws.services.batch.model.BatchJob;
import io.floci.aws.services.batch.model.BatchNodeExecution;
import io.floci.aws.services.batch.model.BatchRunResult;
import io.floci.aws.services.ec2.Ec2Service;
import io.floci.aws.services.ec2.model.Subnet;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -33,6 +42,7 @@ import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.RETURNS_SELF;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -65,21 +75,13 @@ class BatchDockerRunnerTest {
@Test
void runLabelsContainerWithResourceIdentity() {
EmulatorConfig config = mock(EmulatorConfig.class);
EmulatorConfig.ServicesConfig services = mock(EmulatorConfig.ServicesConfig.class);
EmulatorConfig.BatchServiceConfig batch = mock(EmulatorConfig.BatchServiceConfig.class);
when(config.services()).thenReturn(services);
when(services.batch()).thenReturn(batch);
when(batch.dockerNetwork()).thenReturn(Optional.empty());
when(config.port()).thenReturn(4566);
when(config.hostname()).thenReturn(Optional.empty());
EmulatorConfig config = batchConfig();
ContainerDetector detector = mock(ContainerDetector.class);
when(detector.isRunningInContainer()).thenReturn(false);
ContainerLifecycleManager lifecycleManager = mock(ContainerLifecycleManager.class);
when(lifecycleManager.createAndStart(any())).thenReturn(
new ContainerLifecycleManager.ContainerInfo("container-id", Map.of()));
when(lifecycleManager.create(any())).thenReturn("container-id");
DockerClient dockerClient =
mock(DockerClient.class, RETURNS_DEEP_STUBS);
when(lifecycleManager.getDockerClient()).thenReturn(dockerClient);
@@ -92,7 +94,7 @@ class BatchDockerRunnerTest {
when(builder.build()).thenReturn(new ContainerSpec("test-image"));
BatchDockerRunner runner = new BatchDockerRunner(containerBuilder, lifecycleManager,
mock(ContainerLogStreamer.class), config, detector);
mock(ContainerLogStreamer.class), config, detector, null, null);
BatchJob job = new BatchJob();
job.setJobId("job-1");
@@ -103,33 +105,32 @@ class BatchDockerRunnerTest {
job.setRegion("us-east-1");
job.setAccountId("000000000000");
runner.run(job, 1);
runner.run(job, 1, null);
verify(builder).withLabels(Map.of(
ArgumentCaptor<Map<String, String>> labels = ArgumentCaptor.captor();
verify(builder).withLabels(labels.capture());
assertEquals(Map.of(
"io.floci", "aws",
"io.floci.service", "batch",
"io.floci.resource-id", "job-1",
"io.floci.account", "000000000000",
"io.floci.region", "us-east-1"));
"io.floci.region", "us-east-1",
"io.floci.owner", "4566"), withoutRunLabel(labels.getValue()));
// The run label lets a later run tell this run's containers from a crash's leftovers.
assertTrue(labels.getValue().containsKey(BatchDockerRunner.RUN_LABEL));
// A job's JVMs trust Floci's CA as well.
verify(builder).withJavaTrustStore();
}
@Test
void stopJobStopsAnInFlightContainer() throws Exception {
EmulatorConfig config = mock(EmulatorConfig.class);
EmulatorConfig.ServicesConfig services = mock(EmulatorConfig.ServicesConfig.class);
EmulatorConfig.BatchServiceConfig batch = mock(EmulatorConfig.BatchServiceConfig.class);
when(config.services()).thenReturn(services);
when(services.batch()).thenReturn(batch);
when(batch.dockerNetwork()).thenReturn(Optional.empty());
when(config.port()).thenReturn(4566);
when(config.hostname()).thenReturn(Optional.empty());
EmulatorConfig config = batchConfig();
CountDownLatch containerStarted = new CountDownLatch(1);
AtomicBoolean stopped = new AtomicBoolean();
ContainerLifecycleManager lifecycleManager = mock(ContainerLifecycleManager.class);
when(lifecycleManager.createAndStart(any())).thenAnswer(invocation -> {
when(lifecycleManager.create(any())).thenReturn("container-id");
when(lifecycleManager.startCreated(eq("container-id"), any())).thenAnswer(invocation -> {
containerStarted.countDown();
return new ContainerLifecycleManager.ContainerInfo("container-id", Map.of());
});
@@ -148,11 +149,11 @@ class BatchDockerRunnerTest {
when(containerBuilder.newContainer(anyString())).thenReturn(builder);
when(builder.build()).thenReturn(new ContainerSpec("test-image"));
BatchDockerRunner runner = new BatchDockerRunner(containerBuilder, lifecycleManager,
mock(ContainerLogStreamer.class), config, mock(ContainerDetector.class));
mock(ContainerLogStreamer.class), config, mock(ContainerDetector.class), null, null);
BatchJob job = job();
AtomicReference<BatchRunResult> result = new AtomicReference<>();
Thread runThread = Thread.startVirtualThread(() -> result.set(runner.run(job, 1)));
Thread runThread = Thread.startVirtualThread(() -> result.set(runner.run(job, 1, null)));
assertTrue(containerStarted.await(2, TimeUnit.SECONDS));
runner.requestStop(job.getJobId());
runner.stopJob(job.getJobId());
@@ -174,8 +175,7 @@ class BatchDockerRunnerTest {
when(config.port()).thenReturn(4566);
ContainerLifecycleManager lifecycleManager = mock(ContainerLifecycleManager.class);
when(lifecycleManager.createAndStart(any())).thenReturn(
new ContainerLifecycleManager.ContainerInfo("container-id", Map.of()));
when(lifecycleManager.create(any())).thenReturn("container-id");
DockerClient dockerClient = mock(DockerClient.class, RETURNS_DEEP_STUBS);
when(lifecycleManager.getDockerClient()).thenReturn(dockerClient);
when(dockerClient.inspectContainerCmd("container-id").exec().getState().getRunning()).thenReturn(false);
@@ -185,15 +185,16 @@ class BatchDockerRunnerTest {
when(containerBuilder.newContainer(anyString())).thenReturn(builder);
when(builder.build()).thenReturn(new ContainerSpec("test-image"));
BatchDockerRunner runner = new BatchDockerRunner(containerBuilder, lifecycleManager,
mock(ContainerLogStreamer.class), config, mock(ContainerDetector.class));
mock(ContainerLogStreamer.class), config, mock(ContainerDetector.class), null, null);
runner.requestStop("job-1");
runner.clearStopRequest("job-1");
runner.stopJob("job-1");
BatchRunResult result = runner.run(job(), 1);
BatchRunResult result = runner.run(job(), 1, null);
assertEquals(0, result.exitCode());
verify(lifecycleManager).createAndStart(any());
verify(lifecycleManager).create(any());
verify(lifecycleManager).startCreated(eq("container-id"), any());
}
@Test
@@ -210,10 +211,11 @@ class BatchDockerRunnerTest {
AtomicInteger containerSequence = new AtomicInteger();
Set<String> stoppedContainers = ConcurrentHashMap.newKeySet();
ContainerLifecycleManager lifecycleManager = mock(ContainerLifecycleManager.class);
when(lifecycleManager.createAndStart(any())).thenAnswer(invocation -> {
String containerId = "container-" + containerSequence.getAndIncrement();
when(lifecycleManager.create(any()))
.thenAnswer(invocation -> "container-" + containerSequence.getAndIncrement());
when(lifecycleManager.startCreated(anyString(), any())).thenAnswer(invocation -> {
containersStarted.countDown();
return new ContainerLifecycleManager.ContainerInfo(containerId, Map.of());
return new ContainerLifecycleManager.ContainerInfo(invocation.getArgument(0), Map.of());
});
DockerClient dockerClient = mock(DockerClient.class, RETURNS_DEEP_STUBS);
when(lifecycleManager.getDockerClient()).thenReturn(dockerClient);
@@ -232,15 +234,15 @@ class BatchDockerRunnerTest {
when(containerBuilder.newContainer(anyString())).thenReturn(builder);
when(builder.build()).thenReturn(new ContainerSpec("test-image"));
BatchDockerRunner runner = new BatchDockerRunner(containerBuilder, lifecycleManager,
mock(ContainerLogStreamer.class), config, mock(ContainerDetector.class));
mock(ContainerLogStreamer.class), config, mock(ContainerDetector.class), null, null);
BatchJob job = job();
BatchNodeExecution firstNode = node(0);
BatchNodeExecution secondNode = node(1);
AtomicReference<BatchRunResult> firstResult = new AtomicReference<>();
AtomicReference<BatchRunResult> secondResult = new AtomicReference<>();
Thread firstThread = Thread.startVirtualThread(() -> firstResult.set(runner.run(job, 1, firstNode)));
Thread secondThread = Thread.startVirtualThread(() -> secondResult.set(runner.run(job, 1, secondNode)));
Thread firstThread = Thread.startVirtualThread(() -> firstResult.set(runner.run(job, 1, firstNode, null)));
Thread secondThread = Thread.startVirtualThread(() -> secondResult.set(runner.run(job, 1, secondNode, null)));
assertTrue(containersStarted.await(2, TimeUnit.SECONDS));
runner.requestStop(job.getJobId());
runner.stopJob(job.getJobId());
@@ -274,13 +276,91 @@ class BatchDockerRunnerTest {
return node;
}
@Test
void aJobInAVpcJoinsItsSubnetsNetworkAndGivesTheAddressBackOnceItsContainerIsGone() {
Ec2Service ec2 = mock(Ec2Service.class);
doAnswer(invocation -> {
invocation.<Runnable>getArgument(1).run();
return null;
}).when(ec2).runWithSubnetReferencesHeld(eq("us-east-1"), any());
Subnet subnet = new Subnet();
subnet.setSubnetId("subnet-a");
subnet.setVpcId("vpc-1");
when(ec2.describeSubnets("us-east-1", List.of("subnet-a"), Map.of())).thenReturn(List.of(subnet));
when(ec2.allocateVpcPrivateIp("us-east-1", "subnet-a")).thenReturn(Optional.of("10.0.1.30"));
when(ec2.attachContainerToVpc("us-east-1", "vpc-1", "subnet-a", "container-id", "10.0.1.30"))
.thenReturn(Optional.of("10.0.1.30"));
RegionResolver regionResolver = mock(RegionResolver.class);
when(regionResolver.getAccountId()).thenReturn("000000000000");
ContainerLifecycleManager lifecycleManager = mock(ContainerLifecycleManager.class);
when(lifecycleManager.create(any())).thenReturn("container-id");
DockerClient dockerClient = mock(DockerClient.class, RETURNS_DEEP_STUBS);
when(lifecycleManager.getDockerClient()).thenReturn(dockerClient);
InspectContainerResponse exited = mock(InspectContainerResponse.class, RETURNS_DEEP_STUBS);
when(exited.getState().getRunning()).thenReturn(false);
when(exited.getState().getExitCodeLong()).thenReturn(0L);
AtomicBoolean removed = new AtomicBoolean();
AtomicBoolean heldWhileRunning = new AtomicBoolean();
BatchDockerRunner[] runnerRef = new BatchDockerRunner[1];
when(dockerClient.inspectContainerCmd("container-id").exec()).thenAnswer(invocation -> {
if (removed.get()) {
throw new NotFoundException("gone");
}
heldWhileRunning.compareAndSet(false, runnerRef[0].hasSubnetDependency("us-east-1", "subnet-a"));
return exited;
});
doAnswer(invocation -> {
removed.set(true);
return null;
}).when(lifecycleManager).stopAndRemove(eq("container-id"), any());
ContainerBuilder containerBuilder = mock(ContainerBuilder.class);
ContainerBuilder.Builder builder = mock(ContainerBuilder.Builder.class, RETURNS_SELF);
when(containerBuilder.newContainer(anyString())).thenReturn(builder);
when(builder.build()).thenReturn(new ContainerSpec("test-image"));
BatchDockerRunner runner = new BatchDockerRunner(containerBuilder, lifecycleManager,
mock(ContainerLogStreamer.class), batchConfig(), mock(ContainerDetector.class), regionResolver, ec2);
runnerRef[0] = runner;
BatchRunResult result = runner.run(job(), 1, "subnet-a");
assertEquals(0, result.exitCode());
// The job's command is the entrypoint, so the container is on the VPC network before it starts.
InOrder order = inOrder(ec2, lifecycleManager);
order.verify(ec2).attachContainerToVpc("us-east-1", "vpc-1", "subnet-a", "container-id", "10.0.1.30");
order.verify(lifecycleManager).startCreated(eq("container-id"), any());
assertTrue(heldWhileRunning.get(), "the job's address holds its subnet while it runs");
verify(ec2).releaseVpcPrivateIp("us-east-1", "subnet-a", "10.0.1.30");
assertFalse(runner.hasSubnetDependency("us-east-1", "subnet-a"));
}
private static Map<String, String> withoutRunLabel(Map<String, String> labels) {
Map<String, String> rest = new HashMap<>(labels);
rest.remove(BatchDockerRunner.RUN_LABEL);
return rest;
}
private static EmulatorConfig batchConfig() {
EmulatorConfig config = mock(EmulatorConfig.class);
EmulatorConfig.ServicesConfig services = mock(EmulatorConfig.ServicesConfig.class);
EmulatorConfig.BatchServiceConfig batch = mock(EmulatorConfig.BatchServiceConfig.class);
when(config.services()).thenReturn(services);
when(services.batch()).thenReturn(batch);
when(batch.dockerNetwork()).thenReturn(Optional.empty());
when(config.port()).thenReturn(4566);
when(config.hostname()).thenReturn(Optional.empty());
return config;
}
private BatchDockerRunner runner(EmulatorConfig config, ContainerDetector detector) {
return new BatchDockerRunner(
mock(ContainerBuilder.class),
mock(ContainerLifecycleManager.class),
mock(ContainerLogStreamer.class),
config,
detector);
detector,
null,
null);
}
private EmulatorConfig config(Optional<String> hostname) {
@@ -37,6 +37,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -51,10 +53,41 @@ class BatchServiceTest {
private final ObjectMapper objectMapper = new ObjectMapper();
@Test
void aJobRunsInTheFirstSubnetOfTheFirstComputeEnvironmentOfItsQueueThatNamesAny() throws Exception {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
when(runner.run(any(BatchJob.class), anyInt(), nullable(String.class)))
.thenReturn(new BatchRunResult(0, null, "log-stream", 1L, 2L, false));
BatchService service = dockerService(runner);
String unmanaged = service.createComputeEnvironment(json("""
{"computeEnvironmentName":"unmanaged-ce","type":"UNMANAGED"}
"""), REGION).path("computeEnvironmentArn").asText();
String fargate = service.createComputeEnvironment(json("""
{"computeEnvironmentName":"fargate-ce","type":"MANAGED",
"computeResources":{"type":"FARGATE","maxvCpus":4,"subnets":["subnet-a","subnet-b"],
"securityGroupIds":["sg-1"]}}
"""), REGION).path("computeEnvironmentArn").asText();
String queueArn = service.createJobQueue(json("""
{"jobQueueName":"vpc-queue","priority":1,"computeEnvironmentOrder":[
{"order":2,"computeEnvironment":"%s"},{"order":1,"computeEnvironment":"%s"}]}
""".formatted(fargate, unmanaged)), REGION).path("jobQueueArn").asText();
String definitionArn = service.registerJobDefinition(json("""
{"jobDefinitionName":"vpc-job","type":"container",
"containerProperties":{"image":"public.ecr.aws/example/job:latest"}}
"""), REGION).path("jobDefinitionArn").asText();
String jobId = service.submitJob(json("""
{"jobName":"vpc-submit","jobQueue":"%s","jobDefinition":"%s"}
""".formatted(queueArn, definitionArn)), REGION).path("jobId").asText();
assertNotNull(waitForJobStatus(service, jobId, "SUCCEEDED"));
verify(runner).run(any(BatchJob.class), eq(1), eq("subnet-a"));
}
@Test
void dockerTimeoutFailsWithoutRetryingRemainingAttempts() throws Exception {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
when(runner.run(any(BatchJob.class), anyInt()))
when(runner.run(any(BatchJob.class), anyInt(), nullable(String.class)))
.thenReturn(new BatchRunResult(137, "Job timed out", "log-stream", 1L, 2L, true));
BatchService service = dockerService(runner);
@@ -90,13 +123,13 @@ class BatchServiceTest {
assertNotNull(job);
assertEquals("Job timed out", job.path("statusReason").asText());
assertEquals(1, job.path("attempts").size());
verify(runner, times(1)).run(any(BatchJob.class), anyInt());
verify(runner, times(1)).run(any(BatchJob.class), anyInt(), nullable(String.class));
}
@Test
void dockerRetriesFailedAttemptAndCanSucceed() throws Exception {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
when(runner.run(any(BatchJob.class), anyInt()))
when(runner.run(any(BatchJob.class), anyInt(), nullable(String.class)))
.thenReturn(new BatchRunResult(1, "first failed", "log-1", 1L, 2L, false))
.thenReturn(new BatchRunResult(0, null, "log-2", 3L, 4L, false));
BatchService service = dockerService(runner);
@@ -128,13 +161,13 @@ class BatchServiceTest {
assertNotNull(job);
assertEquals(2, job.path("attempts").size());
assertEquals(0, job.path("attempts").get(1).path("container").path("exitCode").asInt());
verify(runner, times(2)).run(any(BatchJob.class), anyInt());
verify(runner, times(2)).run(any(BatchJob.class), anyInt(), nullable(String.class));
}
@Test
void dockerRetryExhaustionFailsJobAndKeepsAttempts() throws Exception {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
when(runner.run(any(BatchJob.class), anyInt()))
when(runner.run(any(BatchJob.class), anyInt(), nullable(String.class)))
.thenReturn(new BatchRunResult(1, "failed once", "log-1", 1L, 2L, false))
.thenReturn(new BatchRunResult(2, "failed twice", "log-2", 3L, 4L, false));
BatchService service = dockerService(runner);
@@ -167,7 +200,7 @@ class BatchServiceTest {
assertEquals("failed twice", job.path("statusReason").asText());
assertEquals(2, job.path("attempts").size());
assertEquals(2, job.path("attempts").get(1).path("container").path("exitCode").asInt());
verify(runner, times(2)).run(any(BatchJob.class), anyInt());
verify(runner, times(2)).run(any(BatchJob.class), anyInt(), nullable(String.class));
}
@Test
@@ -647,7 +680,7 @@ class BatchServiceTest {
void submitMultiNodeJobSucceedsWhenOnlyAChildNodeFails() throws Exception {
// AWS determines the job's outcome solely from the main node, per the MNP user guide.
BatchDockerRunner runner = mock(BatchDockerRunner.class);
when(runner.run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class)))
when(runner.run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class), nullable(String.class)))
.thenAnswer(invocation -> {
BatchNodeExecution node = invocation.getArgument(2);
return node.getNodeIndex() == 1
@@ -674,7 +707,7 @@ class BatchServiceTest {
JsonNode job = waitForJobStatus(service, jobId, "SUCCEEDED");
assertNotNull(job);
verify(runner, times(2)).run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class));
verify(runner, times(2)).run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class), nullable(String.class));
JsonNode nodes = service.listJobs(json("""
{"multiNodeJobId":"%s"}
@@ -685,7 +718,7 @@ class BatchServiceTest {
@Test
void submitMultiNodeJobFailsWhenTheMainNodeFails() throws Exception {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
when(runner.run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class)))
when(runner.run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class), nullable(String.class)))
.thenAnswer(invocation -> {
BatchNodeExecution node = invocation.getArgument(2);
return node.isMainNode()
@@ -713,7 +746,7 @@ class BatchServiceTest {
JsonNode job = waitForJobStatus(service, jobId, "FAILED");
assertNotNull(job);
assertEquals("main crashed", job.path("statusReason").asText());
verify(runner, times(2)).run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class));
verify(runner, times(2)).run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class), nullable(String.class));
}
@Test
@@ -812,7 +845,7 @@ class BatchServiceTest {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
CountDownLatch runStarted = new CountDownLatch(1);
CountDownLatch releaseRun = new CountDownLatch(1);
when(runner.run(any(BatchJob.class), anyInt())).thenAnswer(invocation -> {
when(runner.run(any(BatchJob.class), anyInt(), nullable(String.class))).thenAnswer(invocation -> {
runStarted.countDown();
assertTrue(releaseRun.await(2, TimeUnit.SECONDS));
return new BatchRunResult(0, null, "log-stream", 1L, 2L, false);
@@ -852,7 +885,7 @@ class BatchServiceTest {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
CountDownLatch runStarted = new CountDownLatch(1);
CountDownLatch stopRequested = new CountDownLatch(1);
when(runner.run(any(BatchJob.class), anyInt())).thenAnswer(invocation -> {
when(runner.run(any(BatchJob.class), anyInt(), nullable(String.class))).thenAnswer(invocation -> {
runStarted.countDown();
assertTrue(stopRequested.await(2, TimeUnit.SECONDS));
return new BatchRunResult(137, "Job terminated", "log-stream", 1L, 2L, false);
@@ -967,7 +1000,7 @@ class BatchServiceTest {
BatchDockerRunner runner = mock(BatchDockerRunner.class);
CountDownLatch nodesStarted = new CountDownLatch(2);
CountDownLatch stopRequested = new CountDownLatch(1);
when(runner.run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class)))
when(runner.run(any(BatchJob.class), anyInt(), any(BatchNodeExecution.class), nullable(String.class)))
.thenAnswer(invocation -> {
BatchNodeExecution node = invocation.getArgument(2);
nodesStarted.countDown();