feat(ecs): mount efsVolumeConfiguration task volumes as shared local volumes (#1569)

* feat(ecs): mount efsVolumeConfiguration task volumes as shared local volumes

ECS task definitions can declare EFS-backed volumes via
`efsVolumeConfiguration`, but Floci modelled only `host` volumes — an EFS
volume's mountPoint resolved to no source path and was skipped, so the
container launched without the mount. Terraform/ECS workloads that rely on
a shared EFS working directory (e.g. provisioner tasks reading/writing
/mnt/efs) had no filesystem at the mount path.

Parse and round-trip `efsVolumeConfiguration` (fileSystemId, rootDirectory,
transitEncryption, transitEncryptionPort, authorizationConfig) in
Register/DescribeTaskDefinition, and materialise an EFS volume as a shared
local Docker named volume `floci-efs-<fileSystemId>` mounted at the
container path (read-only/read-write per the mountPoint). Containers that
mount the same file system share persistent storage that survives task
restarts — the local stand-in for an EFS mount, since Docker cannot mount a
real EFS file system. This mirrors the documented LocalStack EFS-simulation
pattern at the ECS layer.

Tests cover the volume->named-volume resolution by access mode and the
efsVolumeConfiguration JSON round-trip.

* chore: re-trigger CI

Unrelated flaky CodeBuildTest.batchGetBuilds_eventuallySucceeds; root-cause
fix in floci-io/floci#1577.
This commit is contained in:
Alex Banna authored and GitHub committed 2026-06-25 22:42:34 -05:00
1 parent eea1e70d93
commit 56f846988f
7 files changed
+213 -17

No files matched your search

@@ -96,4 +96,50 @@ class EcsJsonHandlerVolumesTest {
assertEquals("/root/.aws", mps.get(1).path("containerPath").asText());
assertFalse(mps.get(1).path("readOnly").asBoolean(), "aws mount is read-write");
}
@Test
void registerTaskDefinitionRoundTripsEfsVolumeConfiguration() throws Exception {
String requestJson = """
{
"family": "efs-family",
"containerDefinitions": [
{
"name": "app",
"image": "alpine:latest",
"mountPoints": [
{"sourceVolume": "customer-data", "containerPath": "/mnt/efs", "readOnly": false}
]
}
],
"volumes": [
{
"name": "customer-data",
"efsVolumeConfiguration": {
"fileSystemId": "fs-0123456789abcdef0",
"rootDirectory": "/dps",
"transitEncryption": "ENABLED",
"transitEncryptionPort": 2999,
"authorizationConfig": {"accessPointId": "fsap-0abc", "iam": "ENABLED"}
}
}
]
}
""";
JsonNode request = objectMapper.readTree(requestJson);
Response response = handler.handle("RegisterTaskDefinition", request, "us-east-1");
JsonNode td = objectMapper.valueToTree(response.getEntity()).path("taskDefinition");
// The efsVolumeConfiguration round-trips faithfully (no drift on Terraform reads).
JsonNode vol = td.path("volumes").get(0);
assertEquals("customer-data", vol.path("name").asText());
assertTrue(vol.path("host").isMissingNode(), "EFS volume must not carry a host shape");
JsonNode efs = vol.path("efsVolumeConfiguration");
assertEquals("fs-0123456789abcdef0", efs.path("fileSystemId").asText());
assertEquals("/dps", efs.path("rootDirectory").asText());
assertEquals("ENABLED", efs.path("transitEncryption").asText());
assertEquals(2999, efs.path("transitEncryptionPort").asInt());
assertEquals("fsap-0abc", efs.path("authorizationConfig").path("accessPointId").asText());
assertEquals("ENABLED", efs.path("authorizationConfig").path("iam").asText());
}
}
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.C
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.services.ecs.model.ContainerDefinition;
import io.github.hectorvent.floci.services.ecs.model.EcsTask;
import io.github.hectorvent.floci.services.ecs.model.EfsVolumeConfiguration;
import io.github.hectorvent.floci.services.ecs.model.MountPoint;
import io.github.hectorvent.floci.services.ecs.model.TaskDefinition;
import io.github.hectorvent.floci.services.ecs.model.Volume;
@@ -106,4 +107,37 @@ class EcsContainerManagerVolumesTest {
// The unresolved "missing-vol" mountPoint contributes no bind beyond the two above.
verify(builder, never()).withBind("/app/nope", "/app/nope");
}
@Test
void efsVolumeMountPointsResolveToSharedNamedVolumesByAccessMode() {
ContainerDefinition app = new ContainerDefinition();
app.setName("app");
app.setImage("app:latest");
app.setMountPoints(List.of(
new MountPoint("customer-data", "/mnt/efs", false), // read-write
new MountPoint("shared-ro", "/mnt/shared", true))); // read-only
TaskDefinition taskDef = new TaskDefinition();
taskDef.setFamily("efs-family");
taskDef.setContainerDefinitions(List.of(app));
taskDef.setVolumes(List.of(
new Volume("customer-data", null,
new EfsVolumeConfiguration("fs-0123456789abcdef0", "/dps", "ENABLED", null, null, null)),
new Volume("shared-ro", null,
new EfsVolumeConfiguration("fs-00000000000000001", null, null, null, null, null))));
EcsTask task = new EcsTask();
task.setTaskArn("arn:aws:ecs:us-east-1:000000000000:task/test-cluster/efs1");
manager.startTask(task, taskDef, List.of(), "us-east-1");
// Each EFS volume -> a shared local Docker named volume keyed by file system id,
// read-write or read-only per the mountPoint.
verify(builder, times(1)).withNamedVolume("floci-efs-fs-0123456789abcdef0", "/mnt/efs", false);
verify(builder, times(1)).withNamedVolume("floci-efs-fs-00000000000000001", "/mnt/shared", true);
// EFS volumes are never bind-mounted as host paths.
verify(builder, never()).withBind(any(), any());
verify(builder, never()).withReadOnlyBind(any(), any());
}
}