mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(emr): run no HDFS or YARN on a cluster with Trino alone from emr-7.14.0 (#9775)
From emr-7.14.0, "When you select Trino as the only application at launch, Amazon EMR no longer starts YARN and HDFS." A cluster whose Applications name Trino alone now runs neither: its primary node runs the metastore EMR still installs with Trino, and Trino, without a NameNode or DataNode, and it starts no YARN and no core or task node containers. Where Floci runs no Trino, such a cluster's steps get its volumes, and its network, where they read their primary node's instance metadata.
This commit is contained in:
1 parent
46a3d8ae33
commit
907217bbcd
10 files changed
+253
-33
No files matched your search
+14
-9
@@ -602,8 +602,8 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
container mounts the cluster's two Docker volumes, one at `/home/hadoop` and one at `/mnt`, so what a step leaves
|
||||
there is there for the steps after it, and for steps running at the same time. What the bootstrap actions left in
|
||||
`/home/hadoop` or `/mnt` comes with the image the steps run in, and Docker copies it into the volumes when the
|
||||
first step starts. Every cluster runs HDFS, "best used for caching the results produced by intermediate job-flow
|
||||
steps", as the Management Guide puts it: a NameNode and a DataNode on its primary node, which Floci runs in a
|
||||
first step starts. Every cluster runs HDFS but one with Trino alone from `emr-7.14.0` on (see **Trino**), "best used
|
||||
for caching the results produced by intermediate job-flow steps", as the Management Guide puts it: a NameNode and a DataNode on its primary node, which Floci runs in a
|
||||
container of their own, `emr-<cluster-id>-hdfs`, from the image the cluster's steps run in where it runs YARN (see
|
||||
**YARN**), else from the release's EMR Serverless Hive image, which has HDFS
|
||||
where the release's image has only its client (`hive-image-template` names another), or, for an `emr-spark-*`
|
||||
@@ -657,8 +657,9 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
cluster"), on a state reset, and, for clusters that are gone or have ended, when the EMR service starts, unless
|
||||
`reconcile-containers-on-startup` is off. A shutdown of Floci removes the HDFS containers of the clusters that are
|
||||
still up, and their next step starts them again, on the data their volume keeps. `/tmp` is each container's own.
|
||||
* **YARN**: on a Docker network of the cluster's own, the default, "the primary node runs the YARN ResourceManager
|
||||
service", as the Management Guide puts it, in the primary node's container, with a NodeManager beside it on a cluster
|
||||
* **YARN**: on a Docker network of the cluster's own, the default, but for a cluster with Trino alone from
|
||||
`emr-7.14.0` on (see **Trino**), "the primary node runs the YARN ResourceManager service", as the Management Guide
|
||||
puts it, in the primary node's container, with a NodeManager beside it on a cluster
|
||||
created with no core node, which keeps it, and its DataNode, as core nodes are added, the blocks it holds staying in
|
||||
reach, and the cluster's Spark, MapReduce (see **Hadoop streaming and MapReduce**) and Hive's Tez (see **Hive steps**)
|
||||
run on them. Beside them runs the MapReduce JobHistory server EMR's primary node runs too (a release's `mapred-site`
|
||||
@@ -839,7 +840,14 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
`trino-config`, which changes "Trino's config.properties file": its properties go there after Floci's, a coordinator
|
||||
that runs the queries too. EMR installs `hive-client` and `hcatalog-server` with Trino, so the cluster's image has
|
||||
Hive and its primary node runs Hive's metastore service, as on a cluster with HCatalog (see **Storage**), and Trino's
|
||||
`hive` catalog is that metastore, its warehouse in the cluster's HDFS and its tables' S3 locations on Floci's S3. With
|
||||
`hive` catalog is that metastore, its warehouse in the cluster's HDFS and its tables' S3 locations on Floci's S3.
|
||||
From `emr-7.14.0` on, "When you select Trino as the only application at launch, Amazon EMR no longer starts YARN and
|
||||
HDFS. To add Hadoop and HDFS to a Trino cluster, these applications will need to be explicitly added to the list of
|
||||
applications at cluster launch": a cluster whose `Applications` name Trino alone runs neither, its primary node the
|
||||
metastore EMR still installs with Trino, and Trino, and its core and task nodes nothing, as Floci runs no Trino
|
||||
workers. Its metastore's warehouse is still in HDFS, so a schema there needs a location of its own, in S3: a
|
||||
`CREATE SCHEMA` without one fails, "Call From ... failed on connection exception" (measured on Hive 3.1.3). A bare
|
||||
`trino-exchange-manager` spools in HDFS too, so on such a cluster its `exchange.base-directories` names S3. With
|
||||
`trino-connector-hive` setting `hive.metastore` to `glue`, as the Release Guide's "Launch an Amazon EMR cluster with
|
||||
Trino" does, the catalog is Floci's Glue Data Catalog instead. Each `trino-connector-<catalog>` classification, which
|
||||
changes "Trino's `<catalog>.properties` file", adds that catalog, of the connector of its name, Trino's `delta_lake`
|
||||
@@ -1129,10 +1137,7 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
EMR serves it over HTTPS on port 8446 with a security configuration's in-transit encryption, which its LDAP guide
|
||||
has password authentication need and which Floci does not apply, so Trino takes a password only through Floci with
|
||||
its TLS on, and a step's `trino-cli`, over plain HTTP, gets Trino's `403` once Trino takes passwords. With
|
||||
`docker-network` set
|
||||
to `host`, `container:<id>` or `none` it does not run, as the metastore service does not. From `emr-7.14.0` on, "When
|
||||
you select Trino as the only application at launch, Amazon EMR no longer starts YARN and HDFS"; Floci's primary node
|
||||
still runs the HDFS, beside the metastore.
|
||||
`docker-network` set to `host`, `container:<id>` or `none` it does not run, as the metastore service does not.
|
||||
- **Tez's intermediate data is not compressed on YARN.** The images name the LZO codec for it, whose native library they
|
||||
lack, so Floci turns that compression off, which a `tez-site` classification can turn back on with a codec they have.
|
||||
- **No Hive metastore service in a network namespace the steps share.** With `docker-network` set to `host` or
|
||||
|
||||
@@ -111,13 +111,20 @@ public interface ClusterStorage {
|
||||
* Hive's metastore service on a cluster's primary node, which reaches S3 as the cluster's EC2 instance profile's
|
||||
* {@code role} does, or as its account when that is null, with the cluster's {@code settings}, its
|
||||
* {@code core-site} and {@code hive-site} properties, after its own, and {@code trino} beside it unless that is
|
||||
* null, as EMR installs {@code hcatalog-server} with Trino.
|
||||
* null, as EMR installs {@code hcatalog-server} with Trino; with the cluster's HDFS unless {@code hdfs} is false,
|
||||
* as on a cluster with Trino alone from emr-7.14.0 ({@link EmrSparkSteps#trinoAlone}), whose primary node runs
|
||||
* the metastore without it.
|
||||
*/
|
||||
record HiveMetastore(String role, Map<String, String> settings, Trino trino) {
|
||||
record HiveMetastore(String role, Map<String, String> settings, Trino trino, boolean hdfs) {
|
||||
|
||||
/** The metastore alone. */
|
||||
/** The metastore alone, beside the cluster's HDFS. */
|
||||
HiveMetastore(String role, Map<String, String> settings) {
|
||||
this(role, settings, null);
|
||||
this(role, settings, null, true);
|
||||
}
|
||||
|
||||
/** The metastore and {@code trino}, beside the cluster's HDFS. */
|
||||
HiveMetastore(String role, Map<String, String> settings, Trino trino) {
|
||||
this(role, settings, trino, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ import java.util.zip.GZIPOutputStream;
|
||||
* has at the path it is first mounted on, owner included, so the steps, which run as that user, can write to both,
|
||||
* and what the cluster's bootstrap left there comes with them. Its HDFS, which every EMR cluster runs (from
|
||||
* emr-7.14.0 on, "When you select Trino as the only application at launch, Amazon EMR no longer starts YARN and
|
||||
* HDFS", a cluster Floci does not run), is a NameNode and a DataNode in a container of their own, the cluster's
|
||||
* HDFS", which Floci follows), is a NameNode and a DataNode in a container of their own, the cluster's
|
||||
* primary node's, with their data in a third volume, so that the first container to mount the {@code /mnt} one is a
|
||||
* step's, which fills it from the step's image. On a cluster with Hive or HCatalog the same container runs Hive's
|
||||
* metastore service, as EMR's primary node does, with its database in that third volume, reaching S3 with a session
|
||||
@@ -131,6 +131,9 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
// Set on a primary node whose cluster was created with core nodes, which hold its DataNodes and NodeManagers in its
|
||||
// place.
|
||||
private static final String NODE_WORKERS_VARIABLE = "FLOCI_NODE_WORKERS";
|
||||
// Set on a primary node that runs no HDFS, as on a cluster with Trino alone from emr-7.14.0, which runs its
|
||||
// metastore without it.
|
||||
private static final String NO_HDFS_VARIABLE = "FLOCI_NO_HDFS";
|
||||
private static final String REPLICATION_VARIABLE = "FLOCI_HDFS_REPLICATION";
|
||||
// The nodes being decommissioned, one host name to a line, as HDFS and YARN read them on the primary node.
|
||||
private static final String DFS_EXCLUDE = HDFS_CONF + "/dfs.exclude";
|
||||
@@ -351,7 +354,11 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
// does. HDFS_READY then says the node is ready, once the metastore takes connections, the NodeManager has
|
||||
// registered, and the JobHistory server and the Spark History Server answer. A daemon that exits, before or after,
|
||||
// the metastore among them, ends the container, its readiness gone, so the next step starts it again on its data.
|
||||
// With HADOOP_FOLDER_VARIABLE set, every daemon runs from the Hadoop in that folder.
|
||||
// With HADOOP_FOLDER_VARIABLE set, every daemon runs from the Hadoop in that folder. With NO_HDFS_VARIABLE set, as on
|
||||
// a cluster with Trino alone from emr-7.14.0, no NameNode or DataNode runs, and nothing waits for them or puts
|
||||
// anything in the HDFS: the node is ready once the metastore takes connections. The metastore's warehouse stays in
|
||||
// that HDFS, which Hive 3 starts without, so a schema made without a location of its own fails, "Call From ...
|
||||
// failed on connection exception" (measured on emr-7.5.0's Hive image).
|
||||
// Where a node's daemons listen: FLOCI_HDFS_BIND, or, with SUBNET_VARIABLE set, the node's own address in that subnet,
|
||||
// its cluster's network, alone, so another network it joins does not reach its HDFS or its YARN; written to
|
||||
// BIND_FILE. Hive 3's metastore has no setting for the address it listens on, so it takes every one.
|
||||
@@ -376,11 +383,13 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
"echo \"$address $FLOCI_HDFS_HOST\" >> /etc/hosts || exit",
|
||||
NODE_SETUP,
|
||||
"exec setpriv --reuid=hadoop --regid=hadoop --clear-groups bash -c '"
|
||||
+ "n=0; if [ -z \"$" + NO_HDFS_VARIABLE + "\" ]; then "
|
||||
+ "[ -d /mnt/namenode/current ] || hdfs namenode -format -nonInteractive || exit; "
|
||||
+ "cid=$(sed -n \"s/^clusterID=//p\" /mnt/namenode/current/VERSION); "
|
||||
+ "hdfs namenode & n=1; "
|
||||
+ "if [ -z \"$" + NODE_WORKERS_VARIABLE + "\" ] || [ -d /mnt/datanode/current ]; then "
|
||||
+ "hdfs datanode & n=2; fi; "
|
||||
+ "fi; "
|
||||
+ "dirs=\"/tmp /user/hadoop\"; "
|
||||
+ "[ -z \"$" + YARN_MEMORY_VARIABLE + "\" ] || dirs=\"$dirs "
|
||||
+ EmrServerlessSparkRunner.SPARK_EVENT_LOGS + "\"; "
|
||||
@@ -414,6 +423,7 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
+ "JDK_JAVA_OPTIONS=\"" + yarnOpens() + "\" yarn nodemanager & n=$((n + 1)); fi; "
|
||||
+ "JDK_JAVA_OPTIONS=\"" + yarnOpens() + "\" mapred historyserver & n=$((n + 1)); "
|
||||
+ "fi; "
|
||||
+ "if [ -z \"$" + NO_HDFS_VARIABLE + "\" ]; then "
|
||||
+ untilReady("curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"ClusterId\\\" : \\\"$cid\\\"\"")
|
||||
+ untilReady("curl -sf -m 5 \"" + NAMENODE_JMX + "FSNamesystemState\""
|
||||
@@ -421,6 +431,7 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
+ untilReady("curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"Safemode\\\" : \\\"\\\"\"")
|
||||
+ "hdfs dfs -mkdir -p $dirs || exit 1; "
|
||||
+ "fi; "
|
||||
+ "if [ -n \"$" + SPARK_HISTORY_VARIABLE + "\" ]; then "
|
||||
+ "SPARK_LOCAL_IP=$FLOCI_HDFS_BIND SPARK_HISTORY_OPTS=\"-Dspark.history.fs.logDirectory="
|
||||
+ "hdfs://$FLOCI_HDFS_HOST:8020" + EmrServerlessSparkRunner.SPARK_EVENT_LOGS
|
||||
@@ -428,9 +439,10 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
+ " /usr/lib/spark/bin/spark-class org.apache.spark.deploy.history.HistoryServer & n=$((n + 1)); "
|
||||
+ "fi; "
|
||||
+ "if [ -n \"$" + HIVE_METASTORE_VARIABLE + "\" ]; then "
|
||||
+ "if [ -z \"$" + NO_HDFS_VARIABLE + "\" ]; then "
|
||||
+ "jar=$(ls /usr/lib/hive/lib/hive-exec-[0-9]*.jar | head -1); "
|
||||
+ "hdfs dfs -put -f \"$jar\" " + HIVE_JARS
|
||||
+ "/$(basename \"$jar\" .jar)-$(sha256sum \"$jar\" | cut -d\" \" -f1).jar || exit 1; "
|
||||
+ "/$(basename \"$jar\" .jar)-$(sha256sum \"$jar\" | cut -d\" \" -f1).jar || exit 1; fi; "
|
||||
+ untilReady("(exec 3<>/dev/tcp/127.0.0.1/" + HIVE_METASTORE_PORT + ") 2>/dev/null")
|
||||
+ "fi; "
|
||||
+ "if [ -n \"$" + YARN_MEMORY_VARIABLE + "\" ]; then "
|
||||
@@ -853,6 +865,10 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
// Its steps have no network, so no HDFS reaches them: they run as without one.
|
||||
return volumes(clusterId);
|
||||
}
|
||||
if (hiveMetastore != null && !hiveMetastore.hdfs() && sharesNamespace(network)) {
|
||||
// It runs no HDFS, and its metastore does not run in a namespace the steps share: nothing does.
|
||||
return volumes(clusterId);
|
||||
}
|
||||
long teardown = teardowns.get();
|
||||
stopIfStopped(clusterId, teardown, stopped);
|
||||
// Its image is there first, pulled when missing: the first pull of the Hive image, 2.7 GB, is no part of the
|
||||
@@ -1551,6 +1567,9 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
spec.withEnv(TEZ_UI_VARIABLE, "1");
|
||||
}
|
||||
}
|
||||
if (hiveMetastore != null && !hiveMetastore.hdfs()) {
|
||||
spec.withEnv(NO_HDFS_VARIABLE, "1");
|
||||
}
|
||||
// The metastore and the executors YARN runs reach Floci, Floci on the host by its address, Floci's own
|
||||
// certificate trusted when it serves TLS.
|
||||
if (hiveMetastore != null || yarn != null) {
|
||||
|
||||
@@ -3121,11 +3121,14 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear
|
||||
|
||||
/**
|
||||
* Where a container runs on the cluster, {@link OnCluster}, with the cluster's storage made where {@code storage}
|
||||
* says one needs it and Floci keeps clusters' storage. Every EMR cluster runs HDFS on its primary node, which the
|
||||
* says one needs it and Floci keeps clusters' storage. An EMR cluster runs HDFS on its primary node, which the
|
||||
* container's thread starts when it is not running: a NameNode and a DataNode, on a cluster with Hive or HCatalog
|
||||
* its metastore service, and on one that runs YARN a ResourceManager and a NodeManager, in a container of the
|
||||
* image its steps run in, as an EMR cluster's nodes hold every application it installs, or else of the release's
|
||||
* Hive image, the one with HDFS's daemons.
|
||||
* Hive image, the one with HDFS's daemons. A cluster with Trino alone from emr-7.14.0 runs none of HDFS and YARN
|
||||
* ({@link EmrSparkSteps#trinoAlone}): its primary node runs the metastore that EMR installs with Trino, and Trino,
|
||||
* where Floci runs its Trino, and nothing otherwise, its steps getting the cluster's volumes alone, and its
|
||||
* network, where its instance metadata relay answers them.
|
||||
*/
|
||||
private OnCluster onCluster(EmrCluster cluster, String accountId, String region, boolean storage) {
|
||||
SparkJobRunner.Storage volumes = null;
|
||||
@@ -3151,11 +3154,16 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear
|
||||
EmrSparkSteps.trinoExchangeManager(cluster.getConfigurations(), SNAPSHOT_MAPPER),
|
||||
EmrSparkSteps.trinoPasswordAuthenticator(cluster.getConfigurations(), SNAPSHOT_MAPPER),
|
||||
cluster.getBootstrapImage());
|
||||
boolean withHdfs = !EmrSparkSteps.trinoAlone(cluster.getReleaseLabel(), cluster.getApplications(),
|
||||
SNAPSHOT_MAPPER);
|
||||
ClusterStorage.HiveMetastore hiveMetastore = withHiveImage(cluster)
|
||||
? new ClusterStorage.HiveMetastore(instanceProfileRole(cluster, accountId),
|
||||
EmrSparkSteps.hiveMetastoreSettings(cluster.getConfigurations(), SNAPSHOT_MAPPER), trino)
|
||||
EmrSparkSteps.hiveMetastoreSettings(cluster.getConfigurations(), SNAPSHOT_MAPPER), trino,
|
||||
withHdfs)
|
||||
: null;
|
||||
SparkJobRunner.Storage onlyVolumes = volumes;
|
||||
BiFunction<String, BooleanSupplier, SparkJobRunner.Storage> hdfs = volumes == null ? null
|
||||
: !withHdfs && hiveMetastore == null ? (stepImage, stopped) -> onlyVolumes
|
||||
: (stepImage, stopped) -> clusterStorage.hdfs(clusterId, accountId, region, hdfsHost,
|
||||
nodeYarn != null ? stepImage : hdfsImage, dockerNetwork, hiveMetastore, nodeYarn, stopped);
|
||||
return new OnCluster(volumes, image, releaseImage, hdfs, nodeInstance(cluster, accountId, 0, 1));
|
||||
@@ -3298,7 +3306,8 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear
|
||||
// A node a resize added since the cluster's bootstrap runs its actions before it starts.
|
||||
bootstrapAddedNodes(clusterId, accountId, region);
|
||||
SparkJobRunner.Storage storage = hdfs.apply(running.imageTemplate(), cancelled);
|
||||
running = running.onStorage(address != null ? storage.withMetadataAddress(address) : storage);
|
||||
// On the network the address is on, which a cluster that runs no HDFS gives its storage alone.
|
||||
running = running.onStorage(place != null ? storage.withMetadata(place.network(), address) : storage);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
@@ -3638,12 +3647,15 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear
|
||||
/**
|
||||
* Whether a cluster's primary node runs YARN, which its steps' Spark runs on: "the primary node runs the YARN
|
||||
* ResourceManager service", and a core node "YARN NodeManager daemons, Hadoop MapReduce tasks, and Spark executors".
|
||||
* It does on a network of the cluster's own, as its metastore does. A cluster bootstrapped by an earlier Floci runs
|
||||
* from an image that may hold no YARN, so it keeps to local mode, its HDFS in the release's Hive image, as it did.
|
||||
* It does on a network of the cluster's own, as its metastore does, unless the cluster has Trino alone from
|
||||
* emr-7.14.0, which runs no YARN ({@link EmrSparkSteps#trinoAlone}). A cluster bootstrapped by an earlier Floci
|
||||
* runs from an image that may hold no YARN, so it keeps to local mode, its HDFS in the release's Hive image, as it
|
||||
* did.
|
||||
*/
|
||||
private boolean runsYarn(EmrCluster cluster) {
|
||||
return releaseImages != null && clusterStorage != null && clusterStorage.ownNetwork(dockerNetwork)
|
||||
&& (cluster.getBootstrapImage() == null || cluster.isBootstrapImageRunsYarn());
|
||||
&& (cluster.getBootstrapImage() == null || cluster.isBootstrapImageRunsYarn())
|
||||
&& !EmrSparkSteps.trinoAlone(cluster.getReleaseLabel(), cluster.getApplications(), SNAPSHOT_MAPPER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -278,6 +278,25 @@ final class EmrSparkSteps {
|
||||
return installs(releaseLabel, applications, objectMapper, EmrTrino.APPLICATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a cluster runs neither YARN nor HDFS: from emr-7.14.0, "When you select Trino as the only application at
|
||||
* launch, Amazon EMR no longer starts YARN and HDFS. To add Hadoop and HDFS to a Trino cluster, these applications
|
||||
* will need to be explicitly added to the list of applications at cluster launch". Its {@code Applications} name
|
||||
* Trino and nothing else.
|
||||
*/
|
||||
static boolean trinoAlone(String releaseLabel, String applications, ObjectMapper objectMapper) {
|
||||
if (releaseLabel == null || !EmrService.releaseAtLeast(releaseLabel, 7, 14, 0)
|
||||
|| !installsTrino(releaseLabel, applications, objectMapper)) {
|
||||
return false;
|
||||
}
|
||||
for (JsonNode application : stored(applications, objectMapper)) {
|
||||
if (!EmrTrino.APPLICATION.equalsIgnoreCase(application.path("Name").asText())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The properties of a cluster's {@code trino-connector-<catalog>} classifications by catalog, in the order they
|
||||
* come, a later configuration's winning, each of which changes "Trino's {@code <catalog>.properties} file". One
|
||||
|
||||
@@ -670,7 +670,8 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
|
||||
launch.started(containerId);
|
||||
// A cluster's HDFS is on a network of its own, which only its steps join; on YARN the executors there reach
|
||||
// the driver at the name its container has on it.
|
||||
// With an address there, the cluster's instance metadata relay answers it as the cluster's primary node.
|
||||
// With an address there, the cluster's instance metadata relay answers it as the cluster's primary node; a
|
||||
// cluster that runs no HDFS still has that network, for its metadata.
|
||||
if (onYarn) {
|
||||
lifecycleManager.ensureConnected(containerId, job.storage().hdfsNetwork(), driverHost(job),
|
||||
job.storage().metadataAddress());
|
||||
|
||||
@@ -285,7 +285,8 @@ public interface SparkJobRunner {
|
||||
* {@code /home/hadoop} and {@code mnt} at {@code /mnt}; its HDFS, whose NameNode is on the cluster's primary
|
||||
* node, named {@code hdfsHost}, which a step's container reaches at {@code hdfsAddress} on the Docker network
|
||||
* {@code hdfsNetwork}, the cluster's own, which the container joins (all three null until it runs, the network
|
||||
* also on the host's own network, which steps share with it); and, on a cluster with Hive or HCatalog, the URI of
|
||||
* also on the host's own network, which steps share with it; the network alone where the cluster runs no HDFS but
|
||||
* its instance metadata relay answers there); and, on a cluster with Hive or HCatalog, the URI of
|
||||
* the Hive metastore service on that node, or null; how many copies of a block its HDFS keeps, when its core
|
||||
* nodes hold it, else 0; the host of the Spark History Server on that node, which reads its Spark applications'
|
||||
* event logs, or null where it runs none; and the host of the YARN timeline server on that node, which Tez logs its
|
||||
@@ -355,11 +356,13 @@ public interface SparkJobRunner {
|
||||
}
|
||||
|
||||
/**
|
||||
* This storage, the step's container given {@code address}, a link-local one, on the HDFS's network, where its
|
||||
* cluster's instance metadata relay answers it as the cluster's primary node.
|
||||
* This storage, the step's container given {@code address}, a link-local one, on {@code network}, the
|
||||
* cluster's own, which the container joins, where its cluster's instance metadata relay answers it as the
|
||||
* cluster's primary node: the HDFS's network where the cluster runs HDFS, and the container's way to its
|
||||
* metadata where it runs none.
|
||||
*/
|
||||
public Storage withMetadataAddress(String address) {
|
||||
return new Storage(home, mnt, hdfsHost, hdfsAddress, hdfsNetwork, hiveMetastore, resourceManager,
|
||||
public Storage withMetadata(String network, String address) {
|
||||
return new Storage(home, mnt, hdfsHost, hdfsAddress, network, hiveMetastore, resourceManager,
|
||||
flociEndpoint, replication, address, sparkHistoryServer,
|
||||
timelineServer);
|
||||
}
|
||||
|
||||
@@ -1247,7 +1247,7 @@ class EmrClusterStorageTest {
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(
|
||||
"cid=$(sed -n \"s/^clusterID=//p\" /mnt/namenode/current/VERSION);"
|
||||
+ " hdfs namenode & n=1; if [ -z \"$FLOCI_NODE_WORKERS\" ] || [ -d /mnt/datanode/current ];"
|
||||
+ " then hdfs datanode & n=2; fi; dirs=\"/tmp /user/hadoop\";")
|
||||
+ " then hdfs datanode & n=2; fi; fi; dirs=\"/tmp /user/hadoop\";")
|
||||
&& entrypoint.get(2).contains(String.join(" ",
|
||||
"until curl -sf -m 5 \"http://$(cat /tmp/floci-hdfs-bind):9870/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo\"",
|
||||
"| grep -q \"\\\"ClusterId\\\" : \\\"$cid\\\"\"; do",
|
||||
@@ -1386,7 +1386,8 @@ class EmrClusterStorageTest {
|
||||
// JobHistory server answers, and the node gone if any daemon exits while starting.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> Pattern.compile("yarn nodemanager & n=\\$\\(\\(n \\+ 1\\)\\); fi; "
|
||||
+ "JDK_JAVA_OPTIONS=\"--add-opens=java\\.base/java\\.lang=ALL-UNNAMED[^\"]*\" mapred historyserver & "
|
||||
+ "n=\\$\\(\\(n \\+ 1\\)\\); fi; until curl -sf -m 5 \"http://\\$\\(cat /tmp/floci-hdfs-bind\\):9870/jmx")
|
||||
+ "n=\\$\\(\\(n \\+ 1\\)\\); fi; if \\[ -z \"\\$FLOCI_NO_HDFS\" \\]; then "
|
||||
+ "until curl -sf -m 5 \"http://\\$\\(cat /tmp/floci-hdfs-bind\\):9870/jmx")
|
||||
.matcher(entrypoint.get(2)).find()
|
||||
&& entrypoint.get(2).contains("if [ -n \"$FLOCI_YARN_MEMORY_MB\" ]; then "
|
||||
+ waitUntil("curl -sf -m 5 http://$(cat /tmp/floci-hdfs-bind):8088/ws/v1/cluster/metrics"
|
||||
@@ -1963,10 +1964,10 @@ class EmrClusterStorageTest {
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(
|
||||
"if [ -n \"$FLOCI_HIVE_METASTORE\" ]; then dirs=\"$dirs /user/hive/warehouse /tmp/hadoop/.hiveJars\";")
|
||||
&& entrypoint.get(2).indexOf("hdfs dfs -mkdir -p $dirs || exit 1; ") < entrypoint.get(2).indexOf(
|
||||
"fi; if [ -n \"$FLOCI_HIVE_METASTORE\" ]; then "
|
||||
"fi; if [ -n \"$FLOCI_HIVE_METASTORE\" ]; then if [ -z \"$FLOCI_NO_HDFS\" ]; then "
|
||||
+ "jar=$(ls /usr/lib/hive/lib/hive-exec-[0-9]*.jar | head -1); hdfs dfs -put -f \"$jar\" "
|
||||
+ "/tmp/hadoop/.hiveJars/$(basename \"$jar\" .jar)"
|
||||
+ "-$(sha256sum \"$jar\" | cut -d\" \" -f1).jar || exit 1; until (exec 3<>/dev/tcp")));
|
||||
+ "-$(sha256sum \"$jar\" | cut -d\" \" -f1).jar || exit 1; fi; until (exec 3<>/dev/tcp")));
|
||||
// Started with the NameNode, as it needs no HDFS to start, and waited for once the HDFS is ready.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).indexOf("hive --service metastore")
|
||||
< entrypoint.get(2).indexOf("until curl -sf -m 5 \"http://$(cat /tmp/floci-hdfs-bind):9870/jmx")));
|
||||
@@ -2437,6 +2438,56 @@ class EmrClusterStorageTest {
|
||||
verify(roleCredentials).unregister("123456789012", "ASIAONE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aPrimaryNodeWithoutHdfsRunsItsMetastoreAloneAndIsReadyWithoutANameNode() {
|
||||
when(lifecycle.probeContainer(hdfsName)).thenReturn(ContainerLiveness.NOT_RUNNING);
|
||||
when(lifecycle.createAndStart(any())).thenReturn(new ContainerLifecycleManager.ContainerInfo("c-6", Map.of()));
|
||||
when(lifecycle.probeContainer("c-6")).thenReturn(ContainerLiveness.RUNNING);
|
||||
when(lifecycle.resolveContainerNetworkIp("c-6", hdfsName)).thenReturn("172.18.0.7");
|
||||
ContainerExecStubs.completeEveryExec(docker, "c-6", 0L, "", "");
|
||||
|
||||
// A cluster with Trino alone from emr-7.14.0, whose metastore EMR installs with Trino.
|
||||
SparkJobRunner.Storage started = storage.hdfs("j-1", "123456789012", "us-east-1", HOST, IMAGE,
|
||||
"floci-network", new ClusterStorage.HiveMetastore("arn:aws:iam::123456789012:role/r", Map.of(), null,
|
||||
false), null, NOT_STOPPED);
|
||||
|
||||
verify(spec).withEnv("FLOCI_NO_HDFS", "1");
|
||||
verify(spec).withEnv(eq("FLOCI_HIVE_METASTORE"), anyString());
|
||||
assertEquals("thrift://" + HOST + ":9083", started.hiveMetastore());
|
||||
// No NameNode or DataNode starts, and none is waited for, nor the folders and Hive's jar put in its HDFS.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(
|
||||
"n=0; if [ -z \"$FLOCI_NO_HDFS\" ]; then [ -d /mnt/namenode/current ]")
|
||||
&& entrypoint.get(2).contains("if [ -z \"$FLOCI_NO_HDFS\" ]; then until curl -sf -m 5 ")
|
||||
&& entrypoint.get(2).contains("hdfs dfs -mkdir -p $dirs || exit 1; fi; ")
|
||||
&& entrypoint.get(2).contains("if [ -z \"$FLOCI_NO_HDFS\" ]; then jar=$(ls /usr/lib/hive/lib/")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aPrimaryNodeWithHdfsIsToldNothingOfIt() {
|
||||
when(lifecycle.probeContainer(hdfsName)).thenReturn(ContainerLiveness.NOT_RUNNING);
|
||||
when(lifecycle.createAndStart(any())).thenReturn(new ContainerLifecycleManager.ContainerInfo("c-6", Map.of()));
|
||||
when(lifecycle.probeContainer("c-6")).thenReturn(ContainerLiveness.RUNNING);
|
||||
when(lifecycle.resolveContainerNetworkIp("c-6", hdfsName)).thenReturn("172.18.0.7");
|
||||
ContainerExecStubs.completeEveryExec(docker, "c-6", 0L, "", "");
|
||||
|
||||
storage.hdfs("j-1", "123456789012", "us-east-1", HOST, IMAGE, "floci-network", METASTORE, null, NOT_STOPPED);
|
||||
|
||||
verify(spec, never()).withEnv(eq("FLOCI_NO_HDFS"), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void inANamespaceTheStepsShareAPrimaryNodeWithoutHdfsRunsNothing() {
|
||||
when(containerBuilder.resolveDockerNetwork(Optional.of("host"))).thenReturn(Optional.of("host"));
|
||||
|
||||
// Its metastore does not run there, and it has no HDFS.
|
||||
SparkJobRunner.Storage started = storage.hdfs("j-1", "123456789012", "us-east-1", HOST, IMAGE, "host",
|
||||
new ClusterStorage.HiveMetastore("arn:aws:iam::123456789012:role/r", Map.of(), null, false), null,
|
||||
NOT_STOPPED);
|
||||
|
||||
assertEquals(storage.volumes("j-1"), started);
|
||||
verify(lifecycle, never()).createAndStart(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void inANamespaceTheStepsShareTheMetastoreServiceDoesNotRunAsItWouldServeEveryInterface() {
|
||||
when(containerBuilder.resolveDockerNetwork(Optional.of("host"))).thenReturn(Optional.of("host"));
|
||||
|
||||
@@ -1186,6 +1186,90 @@ class EmrServiceContainerStepsTest {
|
||||
"sha256:" + id), bootstrapping.clusterStorage.metastores.get(0).trino());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClusterWithTrinoAloneFromEmr714RunsItsMetastoreAndTrinoWithoutHdfsOrYarn() {
|
||||
fixture.clusterStorage.ownNetwork = true;
|
||||
EmrService withTrino = fixture.withTrino();
|
||||
EmrCluster requested = cluster("trino", true);
|
||||
requested.setReleaseLabel("emr-7.14.0");
|
||||
requested.setApplications(TRINO);
|
||||
|
||||
withTrino.runJobFlow(requested, REGION);
|
||||
fixture.runStepThread();
|
||||
fixture.runStepThread();
|
||||
|
||||
// "When you select Trino as the only application at launch, Amazon EMR no longer starts YARN and HDFS"; the
|
||||
// metastore EMR installs with Trino runs, and the release's Trino, 479.
|
||||
ClusterStorage.HiveMetastore metastore = fixture.clusterStorage.metastores.get(0);
|
||||
assertFalse(metastore.hdfs());
|
||||
assertEquals("trinodb/trino:479", metastore.trino().image());
|
||||
assertEquals(List.of(), fixture.clusterStorage.yarns);
|
||||
// In the release's Hive image, as on a cluster without YARN.
|
||||
assertEquals("public.ecr.aws/emr-serverless/hive/emr-7.14.0:latest", fixture.clusterStorage.hdfs.get(0).get(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClusterThatAddsHadoopToTrinoOrIsOfAnEarlierReleaseRunsHdfsAndYarnAsBefore() {
|
||||
fixture.clusterStorage.ownNetwork = true;
|
||||
EmrService withTrino = fixture.withTrino();
|
||||
// "To add Hadoop and HDFS to a Trino cluster, these applications will need to be explicitly added to the list
|
||||
// of applications at cluster launch."
|
||||
EmrCluster withHadoop = cluster("trino-hadoop", true);
|
||||
withHadoop.setReleaseLabel("emr-7.14.0");
|
||||
withHadoop.setApplications("[{\"Name\": \"Trino\"}, {\"Name\": \"Hadoop\"}]");
|
||||
EmrCluster earlier = cluster("trino-7.13", true);
|
||||
earlier.setReleaseLabel("emr-7.13.0");
|
||||
earlier.setApplications(TRINO);
|
||||
|
||||
withTrino.runJobFlow(withHadoop, REGION);
|
||||
withTrino.runJobFlow(earlier, REGION);
|
||||
while (fixture.stepThreadsWaiting() > 0) {
|
||||
fixture.runStepThread();
|
||||
}
|
||||
|
||||
assertEquals(List.of(true, true), fixture.clusterStorage.metastores.stream()
|
||||
.map(ClusterStorage.HiveMetastore::hdfs).toList());
|
||||
assertEquals(2, fixture.clusterStorage.yarns.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aStepOnAClusterWithTrinoAloneWhereFlociRunsNoTrinoGetsTheClustersVolumesAlone() {
|
||||
fixture.clusterStorage.ownNetwork = true;
|
||||
EmrStep step = sparkStep("ls", "CONTINUE");
|
||||
step.setArgs(List.of("bash", "-c", "ls"));
|
||||
EmrCluster requested = cluster("trino", true, step);
|
||||
requested.setReleaseLabel("emr-7.14.0");
|
||||
requested.setApplications(TRINO);
|
||||
EmrCluster cluster = service.runJobFlow(requested, REGION);
|
||||
|
||||
fixture.runStepThread();
|
||||
|
||||
// No HDFS, and no metastore, which Floci runs for its Trino.
|
||||
assertEquals(List.of(), fixture.clusterStorage.hdfs);
|
||||
assertEquals(new SparkJobRunner.Storage(cluster.getId() + "-home", cluster.getId() + "-mnt"),
|
||||
runner.jobs.get(0).storage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aStepOnAClusterWithTrinoAloneWhereFlociRunsNoTrinoStillJoinsTheNetworkOfItsInstanceMetadata() {
|
||||
fixture.clusterStorage.ownNetwork = true;
|
||||
fixture.clusterStorage.metadata = true;
|
||||
EmrStep step = sparkStep("ls", "CONTINUE");
|
||||
step.setArgs(List.of("bash", "-c", "ls"));
|
||||
EmrCluster requested = cluster("trino", true, step);
|
||||
requested.setReleaseLabel("emr-7.14.0");
|
||||
requested.setApplications(TRINO);
|
||||
EmrCluster cluster = service.runJobFlow(requested, REGION);
|
||||
|
||||
fixture.runStepThread();
|
||||
|
||||
// No HDFS, but the cluster's network, where the step reads its primary node's metadata, as on any cluster.
|
||||
assertEquals(List.of(), fixture.clusterStorage.hdfs);
|
||||
assertEquals(new SparkJobRunner.Storage(cluster.getId() + "-home", cluster.getId() + "-mnt")
|
||||
.withMetadata(EmrServiceFixture.RecordingStorage.HDFS_NETWORK, "169.254.0.1"),
|
||||
runner.jobs.get(0).storage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClusterWithoutFlocisTrinoStartsNothingAsItBecomesReady() {
|
||||
fixture.clusterStorage.ownNetwork = true;
|
||||
|
||||
@@ -249,6 +249,25 @@ class EmrSparkStepsTest {
|
||||
assertFalse(EmrSparkSteps.installsTrino("emr-spark-8.1.0", "[{\"Name\": \"Trino\"}]", objectMapper));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClusterWithTrinoAloneFromEmr714RunsNoHdfsOrYarn() {
|
||||
// "When you select Trino as the only application at launch, Amazon EMR no longer starts YARN and HDFS."
|
||||
assertTrue(EmrSparkSteps.trinoAlone("emr-7.14.0", "[{\"Name\": \"Trino\"}]", objectMapper));
|
||||
assertTrue(EmrSparkSteps.trinoAlone("emr-7.15.0", "[{\"Name\": \"trino\"}]", objectMapper));
|
||||
// "To add Hadoop and HDFS to a Trino cluster, these applications will need to be explicitly added".
|
||||
assertFalse(EmrSparkSteps.trinoAlone("emr-7.14.0", "[{\"Name\": \"Trino\"}, {\"Name\": \"Hadoop\"}]",
|
||||
objectMapper));
|
||||
assertFalse(EmrSparkSteps.trinoAlone("emr-7.14.0", "[{\"Name\": \"Trino\"}, {\"Name\": \"Spark\"}]",
|
||||
objectMapper));
|
||||
// Before emr-7.14.0, a cluster with Trino alone runs both, as one with no Trino does.
|
||||
assertFalse(EmrSparkSteps.trinoAlone("emr-7.13.0", "[{\"Name\": \"Trino\"}]", objectMapper));
|
||||
assertFalse(EmrSparkSteps.trinoAlone("emr-7.14.0", "[{\"Name\": \"Spark\"}]", objectMapper));
|
||||
assertFalse(EmrSparkSteps.trinoAlone("emr-7.14.0", "[]", objectMapper));
|
||||
assertFalse(EmrSparkSteps.trinoAlone(null, "[{\"Name\": \"Trino\"}]", objectMapper));
|
||||
// The AWS runtime for Apache Spark installs no Trino.
|
||||
assertFalse(EmrSparkSteps.trinoAlone("emr-spark-8.1.0", "[{\"Name\": \"Trino\"}]", objectMapper));
|
||||
}
|
||||
|
||||
@Test
|
||||
void trinosNodeLogAndEnvironmentAreTheClustersTrinoNodeLogAndEnvExports() {
|
||||
String configurations = """
|
||||
|
||||
Reference in new issue
Block a user