fix(ec2): log user data output to /var/log/cloud-init-output.log (#9433)

EC2 user data now appends each part's stdout and stderr to /var/log/cloud-init-output.log in the guest, as cloud-init does on AWS. The guest log keeps the full output; Floci's own 2048-byte summary line is unchanged.

The script still runs as a command, so its shebang selects the interpreter. A POSIX shell wrapper merges stderr into stdout, tees both into the log, and carries the script's exit status on a dedicated file descriptor, so Floci reports the script's code rather than tee's. The script runs with those descriptors closed, so a background service it starts cannot keep the status pipe or the exec stream open. If the guest has no tee or a read-only /var/log, the wrapper falls back to running the script directly and warns on stderr. The EKS caller of the shared UserDataPipeline keeps its current path.

Closes #9386
This commit is contained in:
Chang Liu authored and GitHub committed 2026-11-29 00:16:55 -04:00
1 parent 5ed7187e28
commit fd6fff87be
6 files changed
+348 -18

No files matched your search

+1 -1
View File
@@ -287,7 +287,7 @@ Notes and limitations:
## UserData
`UserData` must be base64-encoded in the request (matching the AWS wire format). Floci decodes it, copies the script into `/var/lib/user-data.sh` inside the container, and executes the script directly after SSH key injection so the script shebang selects the interpreter. Output is captured and logged.
`UserData` must be base64-encoded in the request (matching the AWS wire format). Floci decodes it, copies the script into `/var/lib/user-data.sh` inside the container, and executes the script directly after SSH key injection so the script shebang selects the interpreter. Its stdout and stderr are appended to `/var/log/cloud-init-output.log` in the guest, as cloud-init does, while Floci keeps the last 2048 bytes for its own log line. If the guest cannot create that file (no `tee`, or `/var/log` is not writable), the script still runs and its output stays in Floci's log.
EC2 containers receive `AWS_EC2_METADATA_SERVICE_ENDPOINT` for IMDS and `AWS_ENDPOINT_URL` for AWS service API calls back to Floci.
@@ -44,6 +44,7 @@ public final class UserDataPipeline {
public static final int MAX_EXEC_OUTPUT_BYTES = 2048;
public static final int MAX_CONCURRENT_USER_DATA_DECOMPRESSIONS = 4;
public static final Duration DEFAULT_EXECUTION_TIMEOUT = Duration.ofMinutes(30);
public static final String CLOUD_INIT_OUTPUT_LOG_PATH = "/var/log/cloud-init-output.log";
private static final Semaphore USER_DATA_DECOMPRESSION_BUDGET =
new Semaphore(MAX_CONCURRENT_USER_DATA_DECOMPRESSIONS);
@@ -53,6 +54,38 @@ public final class UserDataPipeline {
private UserDataPipeline() {
}
/**
* The exec argv for one user-data part.
*
* <p>Without a guest log path this is the script itself, so the shebang picks the interpreter.
* With one, the script still runs as a command (never as {@code sh script}), while a POSIX shell
* merges its stdout and stderr, copies them to the guest log through {@code tee}, and reports the
* script's own exit status rather than {@code tee}'s. The status rides a dedicated file descriptor
* instead of a temporary file, so there is no status probe or cleanup to fail. The script runs in
* a subshell with those descriptors closed, so a background service it starts cannot keep the
* status pipe or the exec stream open. The fallback covers guests without {@code tee} or without
* a writable {@code /var/log}: user data keeps running exactly as it did before, and the warning
* goes to the exec stream that Floci already logs. The writability probe runs in a subshell: a
* redirection failure on {@code :} is fatal to a non-interactive POSIX shell, which would
* otherwise end the wrapper before the fallback runs.
*/
public static String[] executionCommand(String guestOutputLogPath) {
if (guestOutputLogPath == null) {
return new String[]{USER_DATA_SCRIPT_PATH};
}
String wrapper = """
log=%1$s
if ( mkdir -p /var/log 2>/dev/null && : >> "$log" ) 2>/dev/null && command -v tee >/dev/null 2>&1; then
exec 4>&1
code=$( { { ( exec 3>&- 4>&-; %2$s ) 2>&1; echo $? >&3; } | tee -a "$log" >&4; } 3>&1 )
exit "${code:-1}"
fi
echo "floci: cannot write $log; running user data without the guest log" >&2
exec %2$s
""".formatted(guestOutputLogPath, USER_DATA_SCRIPT_PATH);
return new String[]{"/bin/sh", "-c", wrapper};
}
public static List<String> extractShellScripts(String userData) {
String decoded = decodeUserDataPayload(userData);
if (decoded == null || decoded.isBlank()) {
@@ -231,7 +264,27 @@ public final class UserDataPipeline {
Set<ResultCallback<Frame>> activeCallbacks
) {
return executeUserData(dockerClient, streamingDockerClient, containerId, contextDescription, userData, timeout,
outputLineConsumer, activeCallbacks, RetryingTarCopier.DEFAULT_BACKOFF_MS);
outputLineConsumer, activeCallbacks, RetryingTarCopier.DEFAULT_BACKOFF_MS, null);
}
/**
* Same as {@link #executeUserData(DockerClient, DockerClient, String, String, String, Duration,
* Consumer, Set)}, but appends each part's output to {@code guestOutputLogPath} inside the guest
* when the path is non-null.
*/
public static ExecutionResult executeUserData(
DockerClient dockerClient,
DockerClient streamingDockerClient,
String containerId,
String contextDescription,
String userData,
Duration timeout,
Consumer<String> outputLineConsumer,
Set<ResultCallback<Frame>> activeCallbacks,
String guestOutputLogPath
) {
return executeUserData(dockerClient, streamingDockerClient, containerId, contextDescription, userData, timeout,
outputLineConsumer, activeCallbacks, RetryingTarCopier.DEFAULT_BACKOFF_MS, guestOutputLogPath);
}
static ExecutionResult executeUserData(
@@ -244,6 +297,22 @@ public final class UserDataPipeline {
Consumer<String> outputLineConsumer,
Set<ResultCallback<Frame>> activeCallbacks,
long archiveRetryBackoffMillis
) {
return executeUserData(dockerClient, streamingDockerClient, containerId, contextDescription, userData, timeout,
outputLineConsumer, activeCallbacks, archiveRetryBackoffMillis, null);
}
static ExecutionResult executeUserData(
DockerClient dockerClient,
DockerClient streamingDockerClient,
String containerId,
String contextDescription,
String userData,
Duration timeout,
Consumer<String> outputLineConsumer,
Set<ResultCallback<Frame>> activeCallbacks,
long archiveRetryBackoffMillis,
String guestOutputLogPath
) {
if (dockerClient == null || streamingDockerClient == null || containerId == null || containerId.isBlank()) {
return ExecutionResult.skipped("No container available");
@@ -261,7 +330,8 @@ public final class UserDataPipeline {
ExecutionResult partResult = executeSingleScript(
dockerClient, streamingDockerClient, containerId, contextDescription, scriptContent, partNumber,
partCount,
effectiveTimeout, outputLineConsumer, activeCallbacks, archiveRetryBackoffMillis);
effectiveTimeout, outputLineConsumer, activeCallbacks, archiveRetryBackoffMillis,
guestOutputLogPath);
if (!partResult.isSuccess()) {
return partResult;
}
@@ -280,7 +350,8 @@ public final class UserDataPipeline {
Duration timeout,
Consumer<String> outputLineConsumer,
Set<ResultCallback<Frame>> activeCallbacks,
long archiveRetryBackoffMillis
long archiveRetryBackoffMillis,
String guestOutputLogPath
) {
byte[] script = scriptContent.getBytes(StandardCharsets.UTF_8);
try {
@@ -288,7 +359,7 @@ public final class UserDataPipeline {
RetryingTarCopier.DEFAULT_MAX_ATTEMPTS, archiveRetryBackoffMillis);
String execId = dockerClient.execCreateCmd(containerId)
.withCmd(USER_DATA_SCRIPT_PATH)
.withCmd(executionCommand(guestOutputLogPath))
.withAttachStdout(true)
.withAttachStderr(true)
.exec()
@@ -86,8 +86,6 @@ import java.util.zip.GZIPInputStream;
public class Ec2ContainerManager {
private static final Logger LOG = Logger.getLogger(Ec2ContainerManager.class);
// Guest-created /tmp mounts hide files copied through Docker's archive API.
private static final String USER_DATA_SCRIPT_PATH = UserDataPipeline.USER_DATA_SCRIPT_PATH;
private static final List<String> ALLOWED_SSHD_PATHS = List.of("/usr/sbin/sshd", "/usr/local/sbin/sshd", "/sbin/sshd");
// Inside containers, systemd's generators read PID 1's arguments instead of /proc/cmdline,
// so these arguments apply runtime unit masks when container=docker is set.
@@ -2148,7 +2146,8 @@ public class Ec2ContainerManager {
UserDataPipeline.executeUserData(
dockerClient, lifecycleManager.getStreamingDockerClient(), containerId, "EC2 instance " + instanceId,
userData, userDataExecutionTimeout, lineConsumer, activeUserDataCallbacks);
userData, userDataExecutionTimeout, lineConsumer, activeUserDataCallbacks,
UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH);
}
private void closeActiveUserDataCallbacks() {
@@ -2172,7 +2171,7 @@ public class Ec2ContainerManager {
}
static String[] userDataExecutionCommand() {
return new String[]{USER_DATA_SCRIPT_PATH};
return UserDataPipeline.executionCommand(UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH);
}
/**
@@ -0,0 +1,196 @@
package io.floci.aws.core.common.docker;
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.CreateContainerResponse;
import com.github.dockerjava.api.model.AccessMode;
import com.github.dockerjava.api.model.Bind;
import com.github.dockerjava.api.model.HostConfig;
import com.github.dockerjava.api.model.Volume;
import io.floci.aws.services.lambda.launcher.ImageCacheService;
import io.floci.aws.testing.DockerAvailability;
import io.floci.aws.testing.TestImages;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Path;
import java.time.Duration;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* The guest log contract against a real container: every part's merged output lands in
* {@code /var/log/cloud-init-output.log}, the log is not capped at the 2048 bytes Floci keeps for
* its own log line, and the exec still reports the script's exit status rather than {@code tee}'s.
*/
@QuarkusTest
@EnabledOnOs(OS.LINUX)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class UserDataPipelineDockerIntegrationTest {
private static final String LOG = UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH;
@Inject
DockerClient dockerClient;
@Inject
ImageCacheService imageCacheService;
private String containerId;
@BeforeAll
void startGuest() throws InterruptedException {
Assumptions.assumeTrue(DockerAvailability.isAvailable(), "Docker daemon must be available");
imageCacheService.ensureImageExists(TestImages.PYTHON_ALPINE);
CreateContainerResponse container = dockerClient.createContainerCmd(TestImages.PYTHON_ALPINE)
.withName("floci-user-data-log-" + UUID.randomUUID())
.withCmd("tail", "-f", "/dev/null")
.exec();
containerId = container.getId();
dockerClient.startContainerCmd(containerId).exec();
}
@BeforeEach
void clearGuestLog() {
ContainerExec.run(dockerClient, containerId, new String[]{"rm", "-f", LOG}, 10);
}
@AfterAll
void removeGuest() {
if (containerId != null) {
dockerClient.removeContainerCmd(containerId).withForce(true).exec();
}
}
@Test
void appendsEveryPartToTheGuestLogInOrder() {
String first = "#!/bin/sh\n"
+ "i=0\n"
+ "while [ $i -lt 400 ]; do echo \"line-$i\"; i=$((i+1)); done\n"
+ "echo stderr-line >&2\n";
String second = "#!/usr/bin/env python3\nprint('from-python')\n";
String multipart = "Content-Type: multipart/mixed; boundary=\"//\"\n"
+ "MIME-Version: 1.0\n\n"
+ "--//\nContent-Type: text/x-shellscript; charset=\"us-ascii\"\n\n" + first
+ "--//\nContent-Type: text/x-shellscript; charset=\"us-ascii\"\n\n" + second
+ "--//--\n";
UserDataPipeline.ExecutionResult result = UserDataPipeline.executeUserData(
dockerClient, dockerClient, containerId, "test guest", multipart, Duration.ofSeconds(60), null, null,
LOG);
assertTrue(result.isSuccess(), result.getFailureMessage());
String log = readLog();
assertTrue(log.contains("line-0\n"), "the first part's stdout is logged");
assertTrue(log.contains("line-399\n"), "the whole first part is logged");
assertTrue(log.contains("stderr-line\n"), "stderr is merged into the log");
assertTrue(log.contains("from-python\n"), "the second part runs through its own shebang");
assertTrue(log.indexOf("line-399") < log.indexOf("from-python"), "parts append in order");
assertTrue(log.length() > UserDataPipeline.MAX_EXEC_OUTPUT_BYTES,
"the guest log is not capped at Floci's 2048-byte summary");
}
@Test
void reportsTheScriptExitStatusAndStillLogsItsOutput() {
String script = "#!/bin/sh\necho failing-line >&2\nexit 7\n";
UserDataPipeline.ExecutionResult result = UserDataPipeline.executeUserData(
dockerClient, dockerClient, containerId, "test guest", script, Duration.ofSeconds(30), null, null,
LOG);
assertFalse(result.isSuccess());
assertEquals(7L, result.getExitCode(), "the wrapper must return the script's status, not tee's");
assertTrue(readLog().contains("failing-line\n"));
}
@Test
void createsTheLogForAScriptWithNoOutput() {
ContainerExec.run(dockerClient, containerId, new String[]{"rm", "-f", LOG}, 10);
String script = "#!/bin/sh\nexit 0\n";
UserDataPipeline.ExecutionResult result = UserDataPipeline.executeUserData(
dockerClient, dockerClient, containerId, "test guest", script, Duration.ofSeconds(30), null, null,
LOG);
assertTrue(result.isSuccess(), result.getFailureMessage());
ContainerExec.Result size = ContainerExec.run(dockerClient, containerId, new String[]{"wc", "-c", LOG}, 10);
assertEquals(0, size.exitCode(), size.stderr());
assertTrue(size.stdout().trim().startsWith("0 "), size.stdout());
}
@Test
void doesNotWaitForABackgroundServiceThatClosesItsStandardStreams() {
String script = "#!/bin/sh\n"
+ "nohup sleep 300 </dev/null >/dev/null 2>&1 &\n"
+ "echo started\n"
+ "exit 0\n";
UserDataPipeline.ExecutionResult result = UserDataPipeline.executeUserData(
dockerClient, dockerClient, containerId, "background service", script, Duration.ofSeconds(5), null,
null, LOG);
assertTrue(result.isSuccess(), result.getFailureMessage());
assertTrue(readLog().contains("started\n"));
}
@Test
void runsTheScriptOnceWhenTheGuestLogIsNotWritable(@TempDir Path readOnlyLog) {
String guest = startGuestWithReadOnlyBind(readOnlyLog, "/var/log");
try {
String script = "#!/bin/sh\necho ran-once >> /var/lib/floci-ran\nexit 7\n";
UserDataPipeline.ExecutionResult result = execute(guest, script);
assertFalse(result.isSuccess());
assertEquals(7L, result.getExitCode(), "the fallback must preserve the script's exit status");
assertEquals("ran-once\n", readFile(guest, "/var/lib/floci-ran"),
"the script must run exactly once when the log cannot be created");
} finally {
removeGuest(guest);
}
}
private String startGuestWithReadOnlyBind(Path hostDirectory, String containerPath) {
Bind bind = new Bind(hostDirectory.toString(), new Volume(containerPath), AccessMode.ro);
CreateContainerResponse container = dockerClient.createContainerCmd(TestImages.PYTHON_ALPINE)
.withName("floci-user-data-log-" + UUID.randomUUID())
.withCmd("tail", "-f", "/dev/null")
.withHostConfig(HostConfig.newHostConfig().withBinds(bind))
.exec();
dockerClient.startContainerCmd(container.getId()).exec();
return container.getId();
}
private UserDataPipeline.ExecutionResult execute(String guest, String userData) {
return UserDataPipeline.executeUserData(dockerClient, dockerClient, guest, "test guest", userData,
Duration.ofSeconds(30), null, null, LOG);
}
private String readFile(String guest, String path) {
ContainerExec.Result result = ContainerExec.run(dockerClient, guest, new String[]{"cat", path}, 10);
assertEquals(0, result.exitCode(), result.stderr());
return result.stdout();
}
private void removeGuest(String guest) {
dockerClient.removeContainerCmd(guest).withForce(true).exec();
}
private String readLog() {
ContainerExec.Result result = ContainerExec.run(dockerClient, containerId,
new String[]{"cat", LOG}, 10);
assertEquals(0, result.exitCode(), result.stderr());
return result.stdout();
}
}
@@ -218,4 +218,47 @@ class UserDataPipelineTest {
assertTrue(skipped.isSuccess());
assertEquals(0L, skipped.getExitCode());
}
@Test
void cloudInitOutputCommandTeesMergedOutputAndKeepsTheScriptExitStatus() {
String expected = """
log=/var/log/cloud-init-output.log
if ( mkdir -p /var/log 2>/dev/null && : >> "$log" ) 2>/dev/null && command -v tee >/dev/null 2>&1; then
exec 4>&1
code=$( { { ( exec 3>&- 4>&-; /var/lib/user-data.sh ) 2>&1; echo $? >&3; } | tee -a "$log" >&4; } 3>&1 )
exit "${code:-1}"
fi
echo "floci: cannot write $log; running user data without the guest log" >&2
exec /var/lib/user-data.sh
""";
assertArrayEquals(new String[]{"/bin/sh", "-c", expected},
UserDataPipeline.executionCommand(UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH));
}
@Test
void executionWithoutAGuestLogRunsTheBareScript() {
assertArrayEquals(new String[]{UserDataPipeline.USER_DATA_SCRIPT_PATH},
UserDataPipeline.executionCommand(null));
}
@Test
void userDataExecutionPassesTheGuestLogCommandToDocker() {
String script = "#!/bin/sh\nprintf 'logged\\n'\n";
DockerClient docker = mock(DockerClient.class);
CopyArchiveToContainerCmd copyCmd = mock(CopyArchiveToContainerCmd.class, RETURNS_SELF);
when(docker.copyArchiveToContainerCmd("container-id")).thenReturn(copyCmd);
DockerClient streaming = mock(DockerClient.class);
List<List<String>> commands = ContainerExecStubs.completeEveryExec(docker, streaming, "container-id", 0L,
"logged\n", "");
UserDataPipeline.ExecutionResult result = UserDataPipeline.executeUserData(docker, streaming, "container-id",
"test instance", script, Duration.ofSeconds(1), null, null, 0L,
UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH);
assertTrue(result.isSuccess(), result.getFailureMessage());
assertEquals(1, commands.size());
assertArrayEquals(UserDataPipeline.executionCommand(UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH),
commands.getFirst().toArray(String[]::new));
}
}
@@ -94,6 +94,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.zip.GZIPOutputStream;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@@ -1026,7 +1027,8 @@ class Ec2ContainerManagerTest {
@Test
void userDataExecutionCommandRunsScriptDirectlySoShebangIsHonored() {
assertArrayEquals(new String[]{"/var/lib/user-data.sh"}, Ec2ContainerManager.userDataExecutionCommand());
assertArrayEquals(UserDataPipeline.executionCommand(UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH),
Ec2ContainerManager.userDataExecutionCommand());
}
@Test
@@ -2124,7 +2126,8 @@ class Ec2ContainerManagerTest {
verify(harness.builder).withReadOnlyBind("/lib/modules/6.8.0-test", "/lib/modules/6.8.0-test");
verify(harness.builder, never()).withReadOnlyBind(eq("/lib/modules"), anyString());
// User data runs after the sshd step, so once it has started that step is settled.
awaitUntil(() -> commandIndex(harness.executedCommands, "/var/lib/user-data.sh") >= 0, Duration.ofSeconds(2));
awaitUntil(() -> commandIndex(harness.executedCommands, Ec2ContainerManagerTest::isUserDataCommand) >= 0,
Duration.ofSeconds(2));
assertEquals(-1, commandIndex(harness.executedCommands, "/usr/sbin/sshd"),
"a systemd guest's init starts sshd; Floci must not start a second one");
verify(harness.lifecycleManager).create(any(ContainerSpec.class), eq("linux/arm64"));
@@ -2574,8 +2577,10 @@ class Ec2ContainerManagerTest {
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"})));
assertTrue(harness.executedCommands.stream().anyMatch(command ->
Arrays.equals(command,
UserDataPipeline.executionCommand(UserDataPipeline.CLOUD_INIT_OUTPUT_LOG_PATH))),
"launch must pass the guest logging wrapper to the user-data exec");
}
@Test
@@ -2743,7 +2748,8 @@ class Ec2ContainerManagerTest {
harness.manager.launch(instance, "ubuntu:24.04", null, "us-west-2");
// UserData is the next step after sshd, so its exec marks sshd startup as finished.
awaitUntil(() -> commandIndex(harness.executedCommands, "/var/lib/user-data.sh") >= 0, Duration.ofSeconds(2));
awaitUntil(() -> commandIndex(harness.executedCommands, Ec2ContainerManagerTest::isUserDataCommand) >= 0,
Duration.ofSeconds(2));
assertEquals(-1, commandIndex(harness.executedCommands, "/usr/local/sbin/sshd"));
}
@@ -3173,8 +3179,7 @@ class Ec2ContainerManagerTest {
});
when(execCreate.exec()).thenAnswer(invocation -> {
String[] command = currentCommand.get();
return command != null && command.length == 1 && "/var/lib/user-data.sh".equals(command[0])
? userDataExec : metadataExec;
return command != null && isUserDataCommand(command) ? userDataExec : metadataExec;
});
Answer<ExecStartCmd> start = invocation -> {
@@ -3212,14 +3217,30 @@ class Ec2ContainerManagerTest {
* Index of the first exec matching {@code expected} exactly, or -1 when it was never run.
*/
private static int commandIndex(List<String[]> executedCommands, String... expected) {
return commandIndex(executedCommands, command -> Arrays.equals(command, expected));
}
private static int commandIndex(List<String[]> executedCommands, Predicate<String[]> predicate) {
for (int i = 0; i < executedCommands.size(); i++) {
if (Arrays.equals(executedCommands.get(i), expected)) {
if (predicate.test(executedCommands.get(i))) {
return i;
}
}
return -1;
}
private static boolean isUserDataCommand(String[] command) {
if (command == null) {
return false;
}
for (String argument : command) {
if (argument != null && argument.contains(UserDataPipeline.USER_DATA_SCRIPT_PATH)) {
return true;
}
}
return false;
}
private static Instance instance(String instanceId) {
Instance instance = new Instance();
instance.setInstanceId(instanceId);
@@ -3554,7 +3575,7 @@ class Ec2ContainerManagerTest {
});
when(execCreate.exec()).thenAnswer(invocation -> {
String[] command = currentCommand.get();
if (command != null && command.length == 1 && "/var/lib/user-data.sh".equals(command[0])) {
if (command != null && isUserDataCommand(command)) {
return userDataExec;
}
return metadataExec;