mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ec2): stage user data outside guest temporary mounts (#3736)
* fix(ec2): stage user data outside guest temporary mounts * docs(ec2): correct user-data script staging path
This commit is contained in:
1 parent
ef12a83418
commit
03603aeacd
3 files changed
+29
-6
No files matched your search
@@ -436,7 +436,7 @@ class Ec2ContainerManagerTest {
|
||||
|
||||
@Test
|
||||
void userDataExecutionCommandRunsScriptDirectlySoShebangIsHonored() {
|
||||
assertArrayEquals(new String[]{"/tmp/user-data.sh"}, Ec2ContainerManager.userDataExecutionCommand());
|
||||
assertArrayEquals(new String[]{"/var/lib/user-data.sh"}, Ec2ContainerManager.userDataExecutionCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1198,6 +1198,28 @@ class Ec2ContainerManagerTest {
|
||||
awaitUntil(() -> "running".equals(instance.getState().getName()), Duration.ofSeconds(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void userDataIsCopiedAndExecutedOutsideGuestTemporaryMounts() throws Exception {
|
||||
LaunchHarness harness = launchHarness();
|
||||
InspectContainerCmd inspect = mock(InspectContainerCmd.class);
|
||||
when(harness.dockerClient.inspectContainerCmd(TEST_CONTAINER_ID)).thenReturn(inspect);
|
||||
InspectContainerResponse withIp = inspectResponse("172.18.0.10");
|
||||
when(inspect.exec()).thenReturn(withIp);
|
||||
CountDownLatch userDataStarted = new CountDownLatch(1);
|
||||
harness.stubSuccessfulExecs(userDataStarted, new CountDownLatch(0));
|
||||
CopyArchiveToContainerCmd copy = harness.dockerClient.copyArchiveToContainerCmd(TEST_CONTAINER_ID);
|
||||
Instance instance = instance("i-userdata-persistent-path");
|
||||
instance.setUserData("#!/bin/sh\necho ready\n");
|
||||
|
||||
harness.manager.launch(instance, "amazonlinux:2023", null, "us-west-2");
|
||||
|
||||
assertTrue(userDataStarted.await(2, TimeUnit.SECONDS), "user data should start");
|
||||
verify(copy).withRemotePath("/var/lib");
|
||||
verify(copy, never()).withRemotePath("/tmp");
|
||||
assertTrue(harness.executedCommands.stream()
|
||||
.anyMatch(command -> Arrays.equals(command, new String[]{"/var/lib/user-data.sh"})));
|
||||
}
|
||||
|
||||
@Test
|
||||
void launchAppliesBackpressureWhenDockerLaunchesAreSaturated() throws Exception {
|
||||
ThreadPoolExecutor launchExecutor = new ThreadPoolExecutor(
|
||||
@@ -1653,7 +1675,7 @@ class Ec2ContainerManagerTest {
|
||||
});
|
||||
when(execCreate.exec()).thenAnswer(invocation -> {
|
||||
String[] command = currentCommand.get();
|
||||
return command != null && command.length == 1 && "/tmp/user-data.sh".equals(command[0])
|
||||
return command != null && command.length == 1 && "/var/lib/user-data.sh".equals(command[0])
|
||||
? userDataExec : metadataExec;
|
||||
});
|
||||
|
||||
@@ -1816,7 +1838,7 @@ class Ec2ContainerManagerTest {
|
||||
});
|
||||
when(execCreate.exec()).thenAnswer(invocation -> {
|
||||
String[] command = currentCommand.get();
|
||||
if (command != null && command.length == 1 && "/tmp/user-data.sh".equals(command[0])) {
|
||||
if (command != null && command.length == 1 && "/var/lib/user-data.sh".equals(command[0])) {
|
||||
return userDataExec;
|
||||
}
|
||||
return metadataExec;
|
||||
|
||||
Reference in new issue
Block a user