feat(emr): write the node files AWS documents on a cluster's nodes (#8473)

An EMR node keeps files about itself that bootstrap actions read to tell
which node they run on. AWS documents two fields of them: the EMR
Management Guide's bootstrap action reads isMaster from
/mnt/var/lib/info/instance.json, and AWS's Knowledge Center reads
instanceRole from /mnt/var/lib/instance-controller/extraInstanceData.json
with jq, comparing it, lowercased, with master, core and task.

Floci now writes those two fields, and nothing else: isMaster true and
instanceRole MASTER in the bootstrap actions' container and each step's,
which run as on the primary node, and in the primary node's own, and
false with CORE or TASK in each core or task node's, the roles as the
API's InstanceRoleType names them. They are written as the image's
hadoop user, whose /mnt is, so Hive's metastore can still write under
/mnt/var/lib, and moved into place whole, as steps share /mnt. The
bootstrap container's copies go before it is kept as the cluster's image.
Files that cannot be written fail the bootstrap, the step or the node.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-15 13:45:23 -04:00
1 parent f491a77dba
commit f71476037a
7 files changed
+164 -19

No files matched your search

+9
View File
@@ -462,6 +462,15 @@ holding the driver and its executors, or a command or a script. The cluster itse
`ErrorData` is a list of maps, and no source shows how AWS spreads the keys over them: Floci gives one map holding
them all. `ErrorMessage` is the reason's message and the error code's page, in Floci's words, as AWS advises
against parsing that text. A cluster that ends with `INTERNAL_ERROR` has no `ErrorDetails`.
* **Node files**: an EMR node's `/mnt/var/lib/info/instance.json` says whether it is the primary node, in its
`isMaster`, which the Management Guide's bootstrap action reads (`grep isMaster /mnt/var/lib/info/instance.json |
grep false` on any other node), and its `/mnt/var/lib/instance-controller/extraInstanceData.json` gives its
`instanceRole`, which AWS's Knowledge Center reads with `jq` and compares, lowercased, with `master`, `core` and
`task`. AWS documents nothing else in either file, so Floci writes those two fields alone: `{"isMaster": true}` and
`{"instanceRole": "MASTER"}` in the bootstrap actions' container and each step's, which run as on the primary node,
and in the primary node's own, and `false` with `CORE` or `TASK` in each core or task node's, the roles as the API's
`InstanceRoleType` names them. The actions run once, as on the primary node, so an action's branch for the other
nodes does not run. Files that cannot be written fail the bootstrap, the step or the node they are for.
* **States**: a step is `RUNNING` from when it starts until its driver or command exits; `step-duration-seconds`
does not apply. The first step of a release also waits while its image is pulled (3.5 to 4.3 GB
unpacked; see [`floci.docker.image-pull-timeout-seconds`](../configuration/docker.md)). It is then
@@ -60,6 +60,7 @@ public class EmrBootstrapRunner implements BootstrapRunner, ContainerTeardown {
private static final int STOP_TIMEOUT_SECONDS = 0;
// No source gives a bootstrap action a time limit: it runs until it ends, or its cluster does.
private static final int NO_TIMEOUT = Integer.MAX_VALUE;
private static final int NODE_INFO_TIMEOUT_SECONDS = 60;
// What each action runs as root, with the sudo a step has too (see EmrServerlessSparkRunner.SUDO), whose options
// the action, already root, has no need of: $1 is its script, and the rest that script's arguments. The JVMs it
// starts trust Floci's CA once the container has its trust store.
@@ -79,8 +80,11 @@ public class EmrBootstrapRunner implements BootstrapRunner, ContainerTeardown {
"exit $code");
// Run once every action has: what only the actions needed goes before the image is kept, the trust store
// included, which each step's container gets afresh.
// The primary node's files, which say which node it is, go too, so a node started from the image writes its own.
private static final String CLEANUP_COMMAND = "rm -f /tmp/floci-bin/sudo /tmp/floci-bootstrap-action-* "
+ ContainerCaBundle.JAVA_TRUST_STORE_PATH + "; rmdir /tmp/floci-bin";
+ ContainerCaBundle.JAVA_TRUST_STORE_PATH + " " + EmrServerlessSparkRunner.INSTANCE_FILE + " "
+ EmrServerlessSparkRunner.EXTRA_INSTANCE_DATA_FILE + "; rmdir /tmp/floci-bin;"
+ " rmdir /mnt/var/lib/info /mnt/var/lib/instance-controller 2>/dev/null";
// The bootstraps inside run(); a stop for one not here comes after its container has gone, and is dropped.
private final ContainerLaunches launches = new ContainerLaunches();
@@ -144,6 +148,8 @@ public class EmrBootstrapRunner implements BootstrapRunner, ContainerTeardown {
if (launch.stopRequested() || cancelled.getAsBoolean()) {
return Outcome.halted();
}
// The actions run on the primary node, whose files say so, as the Management Guide's own action reads them.
writeNodeInfo(containerId);
List<String> env = awsEnv.sdkBaselineEnv(bootstrap.region(), Optional.empty(), credentials,
bootstrap.accountId());
for (int number = 1; number <= bootstrap.actions().size(); number++) {
@@ -176,6 +182,17 @@ public class EmrBootstrapRunner implements BootstrapRunner, ContainerTeardown {
}
}
private void writeNodeInfo(String containerId) {
ContainerExec.Result written = ContainerExec.run(lifecycleManager.getDockerClient(), containerId,
new String[] {"env", EmrServerlessSparkRunner.INSTANCE_ROLE_VARIABLE + "=MASTER", "bash", "-c",
EmrServerlessSparkRunner.NODE_INFO}, NODE_INFO_TIMEOUT_SECONDS);
if (written.exitCode() != 0) {
String why = written.stderr().strip();
throw new IllegalStateException("Could not write the primary node's "
+ EmrServerlessSparkRunner.INSTANCE_FILE + (why.isEmpty() ? "" : ": " + why));
}
}
/**
* Runs action {@code number} in the container, its output going to Floci's log and to the action's log
* folder; null when it succeeded, or how it failed.
@@ -168,10 +168,12 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
+ " HADOOP_HDFS_HOME=$h/hadoop-hdfs HADOOP_MAPRED_HOME=$h/hadoop-mapreduce"
+ " HADOOP_YARN_HOME=$h/hadoop-yarn PATH=$h/hadoop-hdfs/bin:$h/hadoop-yarn/bin:$h/hadoop/bin:$PATH",
"fi");
// What every node of a cluster writes before its daemons start: the Hadoop configuration, its name among the
// nodes in HDFS's when it is given one, and the empty files listing the nodes being decommissioned.
// What every node of a cluster writes before its daemons start: the files that say which node it is, the Hadoop
// configuration, its name among the nodes in HDFS's when it is given one, and the empty files listing the nodes
// being decommissioned.
private static final String NODE_SETUP = String.join("\n",
"chown hadoop:hadoop /mnt || exit",
EmrServerlessSparkRunner.NODE_INFO,
EmrServerlessSparkRunner.HIVE_ONE_SDK,
"mkdir -p " + HDFS_CONF + " || exit",
"printf '%s\\n' '<configuration>'"
@@ -832,6 +834,7 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
.withName(name)
.withUser("root")
.withEntrypoint(List.of("/bin/bash", "-c", NODE_SCRIPT))
.withEnv(EmrServerlessSparkRunner.INSTANCE_ROLE_VARIABLE, core ? "CORE" : "TASK")
.withEnv("FLOCI_HDFS_HOST", request.host())
.withEnv("FLOCI_HDFS_BIND", "0.0.0.0")
.withEnv(NODE_HOST_VARIABLE, host)
@@ -1247,6 +1250,7 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
.withName(name)
.withUser("root")
.withEntrypoint(List.of("/bin/bash", "-c", HDFS_SCRIPT))
.withEnv(EmrServerlessSparkRunner.INSTANCE_ROLE_VARIABLE, "MASTER")
.withEnv("FLOCI_HDFS_HOST", host)
.withEnv("FLOCI_HDFS_BIND", shared ? LOOPBACK : "0.0.0.0")
.withEnv("HADOOP_CONF_DIR", HDFS_CONF)
@@ -177,6 +177,35 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
"exec env \"$@\"");
/** Writes {@link #SUDO} to /tmp/floci-bin/sudo, a folder that is there already. */
public static final String SUDO_FILE = String.join("\n", "cat > /tmp/floci-bin/sudo <<'SUDO'", SUDO, "SUDO");
/** The variable naming the instance role of an EMR cluster's container, MASTER, CORE or TASK (see NODE_INFO). */
public static final String INSTANCE_ROLE_VARIABLE = "FLOCI_INSTANCE_ROLE";
/** The file an EMR node's {@code isMaster} is in, which the EMR Management Guide's bootstrap action reads. */
public static final String INSTANCE_FILE = "/mnt/var/lib/info/instance.json";
/** The file an EMR node's {@code instanceRole} is in, which AWS's Knowledge Center reads with jq. */
public static final String EXTRA_INSTANCE_DATA_FILE = "/mnt/var/lib/instance-controller/extraInstanceData.json";
// Run as the image's user with the node's role as $1: each file written whole, then moved in place, so a step
// starting beside another, which shares its /mnt, reads it whole too.
private static final String NODE_INFO_FILES = String.join("\n",
"w() { t=$(mktemp \"$1.XXXXXX\") && printf \"%s\\n\" \"$2\" > \"$t\" && chmod 644 \"$t\""
+ " && mv -f \"$t\" \"$1\"; }",
"m=false; [ \"$1\" != MASTER ] || m=true",
"mkdir -p /mnt/var/lib/info /mnt/var/lib/instance-controller"
+ " && w " + INSTANCE_FILE + " \"{\\\"isMaster\\\": $m}\""
+ " && w " + EXTRA_INSTANCE_DATA_FILE + " \"{\\\"instanceRole\\\": \\\"$1\\\"}\"");
/**
* Where {@link #INSTANCE_ROLE_VARIABLE} names a role, writes what AWS documents of the files an EMR node keeps
* about itself, and only that: {@link #INSTANCE_FILE}'s {@code isMaster}, as the EMR Management Guide's bootstrap
* action reads it ("grep isMaster /mnt/var/lib/info/instance.json | grep false" on a node that is not the primary),
* and {@link #EXTRA_INSTANCE_DATA_FILE}'s {@code instanceRole}, which AWS's Knowledge Center reads with jq and
* compares, lowercased, with master, core and task, given as the API's {@code InstanceRoleType} names it. Written
* as the image's user, whose /mnt is, so a folder made there is that user's too, as Hive's metastore, which writes
* under /mnt/var/lib, runs as that user.
*/
public static final String NODE_INFO = String.join("\n",
"if [ -n \"${" + INSTANCE_ROLE_VARIABLE + ":-}\" ]; then",
" as=; [ \"$(id -u)\" != 0 ] || as=\"setpriv --reuid=hadoop --regid=hadoop --clear-groups\"",
" $as bash -c '" + NODE_INFO_FILES + "' floci \"$" + INSTANCE_ROLE_VARIABLE + "\" || exit",
"fi");
// A Spark configuration of the container's own: a copy of the folder a spark-env export of SPARK_CONF_DIR names,
// else of the image's, links followed, whose log4j2.properties ends with the job's lines, passed in
// SPARK_LOG4J2_VARIABLE, a later line winning. What is added to a file starts on a line of its own, as the
@@ -377,6 +406,7 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
" chmod 755 /tmp/floci-bin/sudo",
" export PATH=\"/tmp/floci-bin:$PATH\"",
"fi",
NODE_INFO,
HIVE_ONE_SDK,
"export HOME=~" + IMAGE_USER,
"cd \"$HOME\" || exit",
@@ -510,8 +540,10 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
container.withEnv(SPARK_LOG4J2_VARIABLE, sparkLog4j2File(job));
}
if (job.storage() != null) {
// A step runs on its cluster's primary node, whose files say so.
container.withNamedVolume(job.storage().home(), "/home/hadoop")
.withNamedVolume(job.storage().mnt(), "/mnt");
.withNamedVolume(job.storage().mnt(), "/mnt")
.withEnv(INSTANCE_ROLE_VARIABLE, "MASTER");
// The primary node's name leads to its HDFS, as the cluster's DNS resolves it.
if (job.storage().hdfsHost() != null) {
container.withExtraHost(job.storage().hdfsHost(), job.storage().hdfsAddress());
@@ -1300,7 +1332,7 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
// A wrapper's script: the lines of each part, in order, then what it runs.
@SafeVarargs
private static String wrapper(List<String>... parts) {
List<String> lines = new ArrayList<>();
List<String> lines = new ArrayList<>(List.of(NODE_INFO));
for (List<String> part : parts) {
lines.addAll(part);
}
@@ -124,12 +124,12 @@ class EmrBootstrapRunnerTest {
verify(s3).getObject("bucket", "bootstrap/install.sh");
verify(s3).getObject("bucket", "bootstrap/jars.sh");
assertEquals(List.of("bootstrap-action", "/tmp/floci-bootstrap-action-1-install.sh", "pandas", "2.2"),
commands.get(0).subList(3, commands.get(0).size()));
assertEquals(List.of("bootstrap-action", "/tmp/floci-bootstrap-action-2-jars.sh"),
commands.get(1).subList(3, commands.get(1).size()));
assertEquals(List.of("bash", "-c"), commands.get(0).subList(0, 2));
assertTrue(commands.get(0).get(2).contains("chown -R hadoop:hadoop /home/hadoop"));
assertEquals(3, commands.size());
assertEquals(List.of("bootstrap-action", "/tmp/floci-bootstrap-action-2-jars.sh"),
commands.get(2).subList(3, commands.get(2).size()));
assertEquals(List.of("bash", "-c"), commands.get(1).subList(0, 2));
assertTrue(commands.get(1).get(2).contains("chown -R hadoop:hadoop /home/hadoop"));
assertEquals(4, commands.size());
// The credentials go to each action's exec alone, never to the container the image is made of.
ExecCreateCmd exec = docker.execCreateCmd(CONTAINER);
verify(exec, times(2)).withEnv(ENV);
@@ -158,22 +158,23 @@ class EmrBootstrapRunnerTest {
// In once the container is up, before the first action runs, which points its JVMs at it.
assertEquals(List.of(0), execsBeforeTheCopy);
assertTrue(commands.get(0).get(2).startsWith(ContainerCaBundle.JAVA_TRUST_SHELL_LINE + "\n"));
assertTrue(commands.get(1).get(2).startsWith(ContainerCaBundle.JAVA_TRUST_SHELL_LINE + "\n"));
// Each step's container gets its own, so the image goes without it.
assertEquals(2, commands.size());
assertTrue(commands.get(1).get(2).contains("rm -f ") && commands.get(1).get(2).contains(
" " + ContainerCaBundle.JAVA_TRUST_STORE_PATH + ";"), commands.get(1).get(2));
assertEquals(3, commands.size());
assertTrue(commands.get(2).get(2).contains("rm -f ") && commands.get(2).get(2).contains(
" " + ContainerCaBundle.JAVA_TRUST_STORE_PATH + " "), commands.get(2).get(2));
}
@Test
void aFailingActionEndsTheBootstrapThereAndNothingIsKept() {
List<List<String>> commands = ContainerExecStubs.completeEveryExec(docker, CONTAINER, List.of(0L, 3L), "", "");
List<List<String>> commands = ContainerExecStubs.completeEveryExec(docker, CONTAINER, List.of(0L, 0L, 3L), "",
"");
BootstrapRunner.Outcome outcome = runner.run(bootstrap(null, action("s3://bucket/bootstrap/install.sh"),
action("s3://bucket/bootstrap/jars.sh"), action("s3://bucket/bootstrap/never.sh")), () -> false);
assertEquals(BootstrapRunner.Outcome.actionFailed(2, 3), outcome);
assertEquals(2, commands.size());
assertEquals(3, commands.size());
verify(lifecycle, never()).commit(any(), any(), any(), any(), any());
assertTrue(uploaded.isEmpty());
verify(lifecycle).stopAndRemove(CONTAINER, null, 0);
@@ -205,7 +206,8 @@ class EmrBootstrapRunnerTest {
() -> false);
assertEquals(BootstrapRunner.Outcome.notDownloaded(1, "The specified key does not exist."), outcome);
assertTrue(commands.isEmpty());
// The node's files alone.
assertEquals(1, commands.size());
}
@Test
@@ -221,6 +223,36 @@ class EmrBootstrapRunnerTest {
action("s3://bucket/bootstrap/jars.sh")), ended::get);
assertEquals(BootstrapRunner.Outcome.halted(), outcome);
assertEquals(2, commands.size());
verify(lifecycle, never()).commit(any(), any(), any(), any(), any());
}
@Test
void thePrimaryNodesFilesAreWrittenBeforeTheFirstActionAndGoBeforeTheImageIsKept() {
List<List<String>> commands = ContainerExecStubs.completeEveryExec(docker, CONTAINER, 0, "", "");
runner.run(bootstrap(null, action("s3://bucket/bootstrap/install.sh")), () -> false);
// The actions run as on the primary node, whose files say so.
assertEquals(List.of("env", "FLOCI_INSTANCE_ROLE=MASTER", "bash", "-c", EmrServerlessSparkRunner.NODE_INFO),
commands.get(0));
// A node started from the image writes its own.
String cleanup = commands.get(2).get(2);
assertTrue(cleanup.contains(" /mnt/var/lib/info/instance.json ")
&& cleanup.contains(" /mnt/var/lib/instance-controller/extraInstanceData.json;"), cleanup);
}
@Test
void filesThatCannotBeWrittenEndTheBootstrapBeforeAnyActionRuns() {
List<List<String>> commands = ContainerExecStubs.completeEveryExec(docker, CONTAINER, 1, "",
"mkdir: cannot create directory '/mnt/var': Permission denied\n");
BootstrapRunner.Outcome outcome = runner.run(bootstrap(null, action("s3://bucket/bootstrap/install.sh")),
() -> false);
assertEquals(BootstrapRunner.Outcome.couldNotRun("Could not write the primary node's "
+ "/mnt/var/lib/info/instance.json: mkdir: cannot create directory '/mnt/var': Permission denied"),
outcome);
assertEquals(1, commands.size());
verify(lifecycle, never()).commit(any(), any(), any(), any(), any());
}
@@ -180,6 +180,12 @@ class EmrClusterStorageTest {
// Only a core node holds a DataNode, and with one the primary node holds neither.
verify(spec).withEnv("FLOCI_NODE_CORE", "1");
verify(spec).withEnv("FLOCI_NODE_WORKERS", "1");
// Each node's files say which it is, before its daemons start.
verify(spec).withEnv("FLOCI_INSTANCE_ROLE", "MASTER");
verify(spec).withEnv("FLOCI_INSTANCE_ROLE", "CORE");
verify(spec).withEnv("FLOCI_INSTANCE_ROLE", "TASK");
verify(spec, times(3)).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(
"chown hadoop:hadoop /mnt || exit\n" + EmrServerlessSparkRunner.NODE_INFO + "\n")));
// What the primary node has of YARN too, and Floci in reach.
verify(spec, times(3)).withEnv("FLOCI_YARN_MEMORY_MB", "4096");
verify(spec, times(3)).withEnv("FLOCI_YARN_VCORES", "4");
@@ -1584,7 +1590,8 @@ class EmrClusterStorageTest {
// A table's location in S3 is the metastore's to look at, with S3A, so it too leaves Hive one SDK first, as
// root, which owns Hive's lib folder.
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(
"chown hadoop:hadoop /mnt || exit\n" + EmrServerlessSparkRunner.HIVE_ONE_SDK + "\n")));
"chown hadoop:hadoop /mnt || exit\n" + EmrServerlessSparkRunner.NODE_INFO + "\n"
+ EmrServerlessSparkRunner.HIVE_ONE_SDK + "\n")));
// The session goes with the container.
storage.remove("j-1");
@@ -1,5 +1,6 @@
package io.floci.aws.services.emrserverless;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.CopyArchiveToContainerCmd;
@@ -42,10 +43,12 @@ import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermissions;
import java.time.Duration;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
@@ -257,6 +260,10 @@ class EmrServerlessSparkRunnerTest {
verify(spec).withCmd(EmrServerlessSparkRunner.hiveArguments(step, ENDPOINT, List.of()));
verify(spec).withNamedVolume("j-1-home", "/home/hadoop");
verify(spec).withNamedVolume("j-1-mnt", "/mnt");
// It runs on its cluster's primary node, which its node's files name.
verify(spec).withEnv("FLOCI_INSTANCE_ROLE", "MASTER");
verify(spec).withEntrypoint(argThat((List<String> entrypoint) -> entrypoint.get(2).contains(
EmrServerlessSparkRunner.NODE_INFO)));
// In its cluster's image, which holds Spark too, Hive reads its own Hadoop configuration.
verify(spec).withEntrypoint(argThat((List<String> entrypoint) -> entrypoint.get(2).contains(
"if [ -d /etc/hadoop/conf.hive ]; then export HADOOP_CONF_DIR=/etc/hadoop/conf.hive; fi")));
@@ -367,8 +374,9 @@ class EmrServerlessSparkRunnerTest {
verify(lifecycle, never()).copyJavaTrustStore(anyString());
// The release's image is not in an ECR repository, so it is pulled once, as the container is created.
verify(lifecycle, never()).resolveImageForLaunch(anyString(), any(), any());
// An EMR Serverless run has no cluster, nor its storage or network.
// An EMR Serverless run has no cluster, nor its storage or network, nor a node's files.
verify(spec, never()).withNamedVolume(anyString(), anyString());
verify(spec, never()).withEnv(eq("FLOCI_INSTANCE_ROLE"), anyString());
verify(lifecycle, never()).connectToNetwork(anyString(), anyString(), any());
}
@@ -1399,6 +1407,41 @@ class EmrServerlessSparkRunnerTest {
assertFalse(ended.output().contains("hadoop-client-api"), ended.output());
}
@Test
void aClustersContainerWritesWhatAwsDocumentsOfItsNodesFilesAndNothingElse(@TempDir Path folder) throws Exception {
// As the test's user, root or not, in place of the image's hadoop user, whom the host need not have.
String script = EmrServerlessSparkRunner.NODE_INFO.replace("/mnt/", folder + "/")
.replace("setpriv --reuid=hadoop --regid=hadoop --clear-groups", "");
Path instance = folder.resolve("var/lib/info/instance.json");
Path extra = folder.resolve("var/lib/instance-controller/extraInstanceData.json");
// The Management Guide's bootstrap action, which tells the primary node from the others.
String guide = "if grep isMaster " + instance + " | grep false > /dev/null; then echo other;"
+ " else echo primary; fi";
ObjectMapper json = new ObjectMapper();
for (String role : List.of("MASTER", "CORE", "TASK")) {
ProcessBuilder shell = new ProcessBuilder("bash", "-c", script + "\n" + guide);
shell.environment().put("FLOCI_INSTANCE_ROLE", role);
BootstrapProcess.Result ended = BootstrapProcess.run(shell);
assertEquals(new BootstrapProcess.Result(0, "MASTER".equals(role) ? "primary\n" : "other\n"), ended);
assertEquals("{\"isMaster\": " + "MASTER".equals(role) + "}\n", Files.readString(instance));
assertEquals("{\"instanceRole\": \"" + role + "\"}\n", Files.readString(extra));
// AWS's Knowledge Center reads it with jq and compares it, lowercased, with master, core and task.
assertEquals(role.toLowerCase(Locale.ROOT), json.readTree(extra.toFile()).path("instanceRole").asText()
.toLowerCase(Locale.ROOT));
assertEquals(PosixFilePermissions.fromString("rw-r--r--"), Files.getPosixFilePermissions(instance));
}
// Nothing where no role is named, as in an EMR Serverless run.
Path unnamed = Files.createDirectory(folder.resolve("unnamed"));
BootstrapProcess.Result skipped = BootstrapProcess.run(new ProcessBuilder("bash", "-c",
script.replace(folder + "/", unnamed + "/")));
assertEquals(new BootstrapProcess.Result(0, ""), skipped);
try (Stream<Path> made = Files.list(unnamed)) {
assertEquals(0, made.count());
}
}
@Test
void aStepsCommandFindsASudoThatRunsItsCommandAsItIs(@TempDir Path folder) throws Exception {
ContainerBuilder builder = mock(ContainerBuilder.class);
@@ -1540,6 +1583,7 @@ class EmrServerlessSparkRunnerTest {
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.size() == 5
&& entrypoint.subList(0, 2).equals(List.of("/bin/bash", "-c"))
&& entrypoint.get(2).startsWith(String.join("\n",
EmrServerlessSparkRunner.NODE_INFO,
"conf=/tmp/floci-spark-conf",
"mkdir -p \"$conf\"",
"cp -rL \"${SPARK_CONF_DIR:-/usr/lib/spark/conf}/.\" \"$conf\" 2>/dev/null",