Commit Graph
32 Commits
Author SHA1 Message Date
Priamo Germosen 7ebed877a8 feat(emr): run a cluster's core and task nodes in containers of their own (#8066)
A docker cluster's YARN and HDFS ran on its primary node alone, however
many instances the cluster named. On EMR "Core nodes run the Data Node
daemon", "a core node runs YARN NodeManager daemons, Hadoop MapReduce
tasks, and Spark executors", and "Task nodes don't run the Data Node
daemon".

- Each core and task node is a container of its own on the cluster's
  network, with its data in a volume of its own, its name there the
  private DNS name ListInstances gives it. The primary node keeps a
  DataNode and a NodeManager only on a cluster created with no core
  node, which keeps them as core nodes are added, and a primary node
  whose volume holds a DataNode's data runs it in any case, so the
  blocks on it stay in reach.
- ListInstances gives each group's instances addresses of their own, so
  an instance keeps its address while another group resizes.
- How many follows the instance groups' counts or the instance fleets'
  target capacities, at most yarn-max-worker-nodes, core nodes first. A
  fleet's unit of capacity is one node. With 0 a cluster runs on its
  primary node alone.
- HDFS keeps what EMR's does: one copy of a block below four core nodes,
  two below ten, three otherwise, or the hdfs-site classification's
  dfs.replication. Steps' Spark, Hive and hadoop clients write that many.
- A resize reaches the nodes of a cluster a step has started them on, on
  another thread: a new node takes work once it has registered, and one
  no longer wanted is decommissioned, HDFS and YARN telling when it may
  go, within EMR's default hour, each node its own, then goes with its
  data. Core nodes stop at the copies HDFS keeps.
- A core node's NodeManager is decommissioned only once HDFS has moved
  its blocks, as a decommissioned NodeManager exits, which ends the
  node's container, its DataNode with it. A core node that has gone
  stays among HDFS's excluded nodes until the NameNode has it dead, 40s
  after it stopped, so the copies it held never count again.
- A core node that stops before HDFS has moved its blocks starts again
  on its data, and one a shutdown cut off while it was decommissioned
  starts again with the cluster's next step, from its volume, which
  carries its name, to be decommissioned then. A task node's volume a
  shutdown left goes.
- A decommissioning round that fails, a refresh of HDFS's or YARN's
  lists among them, is tried again on the next; a node Docker will not
  remove yet stays to be removed then, and one whose start a teardown
  passed goes. A cluster's end removes the volumes of nodes that have no
  container, and finishes even when Docker cannot list its nodes.
- The node list is read inside the cluster's lock, so a step queued
  before a resize starts the nodes asked for by then.
- Container logs come from every node, a decommissioned one's first.
2026-11-12 13:59:34 -04:00
Priamo Germosen c9d9ba24f4 fix(emr): refuse reading the managed scaling policy of an ended cluster (#8065)
GetManagedScalingPolicy returned the policy of a cluster that was
shutting down or had ended. AWS answers ValidationException "A job flow
that is shutting down, terminated, or finished may not be modified."
there, as Terraform's acceptance runs recorded, and Terraform's provider
reads that answer as the policy being gone. Floci kept returning it, so
a refresh after termination kept a policy AWS reports gone.

A TERMINATING, TERMINATED or TERMINATED_WITH_ERRORS cluster now gets
that answer. emr.md no longer says no answer is recorded for the managed
scaling calls: Terraform's provider also expects it from
RemoveManagedScalingPolicy.
2026-11-11 19:50:26 -06:00
Priamo Germosen 4c9572b95b fix(emr): refuse changes to a cluster that is shutting down or ended (#8037)
ModifyCluster, the four Set* setters, and Put and Remove of a cluster's
managed scaling, auto-termination and automatic scaling policies all
changed a TERMINATED cluster, and AddTags and RemoveTags its tags.

AWS documents these for running clusters, but no answer for an ended
one is recorded. So they give the one AWS gives AddJobFlowSteps and
ModifyInstanceFleet, "A job flow that is shutting down, terminated, or
finished may not be modified.", in the code each operation's model
points at, as AddInstanceGroups and AddInstanceFleet already did for a
TERMINATING cluster: InvalidRequestException with ErrorCode
INVALID_JOB_SHUT_DOWN for ModifyCluster, ValidationException for the
others, whose models declare no InvalidRequestException. A Set* request
naming such a cluster changes none of the clusters it names.

AddInstanceGroups and AddInstanceFleet now answer a TERMINATED cluster
that way too, in place of "Cluster <id> is terminated.", which no source
has.

The Management Guide says "you cannot add, edit, or remove tags from a
terminated cluster" and names no error. AddTags and RemoveTags refuse an
ended cluster with InvalidRequestException "Tags cannot be modified on
terminated clusters.", the message a tagging tool matches from AWS.
2026-11-11 14:08:56 -06:00
Priamo Germosen 874493c446 feat(emr): run a cluster's Spark steps on YARN on its primary node (#7864)
A docker cluster's Spark steps ran in local mode, in one container, so a
script's own spark-submit --master yarn failed and a step's --deploy-mode
was dropped. On EMR "the primary node runs the YARN ResourceManager
service" and a core node "YARN NodeManager daemons, Hadoop MapReduce
tasks, and Spark executors".

- On a Docker network of the cluster's own, the primary node's container
  also runs a ResourceManager and a NodeManager, whose capacity is
  yarn-node-memory-mb and yarn-node-vcores.
- The node needs Spark, Python and what the bootstrap actions installed,
  so it runs from the image the steps run in: the bootstrap's, else the
  release's EMR Serverless image with its Hive image's HDFS, MapReduce
  and YARN, and Hive on a cluster with Hive. A cluster without Hive gets
  no hive, so its Hive step still says "Hive isn't installed.".
- Spark steps submit with --master yarn, keeping the step's own --master
  and --deploy-mode; a command's own spark-submit reads the same from its
  spark-defaults. Executors and a cluster-mode driver are sized for the
  NodeManager, which the cluster's spark-defaults replace, get the step's
  AWS environment, and reach Floci at its address on the cluster's
  network; a client-mode driver is reached at its container's name there.
- A YARN application's container logs go to
  <LogUri>/<cluster-id>/containers/<application>/<container>/ when a step
  ends, as a cluster-mode driver's output is there and not in the step's,
  without launch_container.sh, which holds the step's session.

A node that does not become ready leaves the last of its output in
Floci's log, as the container goes with its cluster.

YARN's Java 17 options go through JDK_JAVA_OPTIONS, which the Java 8 of
an emr-6.x image ignores.

An emr-spark-* release has no Hive image, and emr-7.5.0's HDFS and YARN
do not run on its newer Hadoop, so its image holds the whole of
emr-7.5.0's Hadoop in /opt, which only the node's daemons run from, and
Spark keeps the release's own. Those daemons are Hadoop 3.4.0's, where
the Release Guide lists 3.4.2 for these releases.

Clusters in a namespace the steps share or with no network stay in local
mode, as do MapReduce and Tez, and core and task instances get no
NodeManager yet.
2026-11-10 22:22:16 -06:00
Priamo Germosen 6974d8c096 feat(emr): give a cluster with HCatalog Hive's client and metastore (#7719)
A docker cluster ran Hive steps, made its steps' image with Hive and ran
Hive's metastore service on its primary node only when its Applications
named Hive. EMR installs Hive's client and its HCatalog server with
HCatalog too, and the Release Guide's HCatalog page says "HCatalog is a
tool that allows you to access Hive metastore tables within Pig, Spark
SQL, and/or custom MapReduce applications".

- EMR's hive-script, in the emr-scripts package every node has, checks
  only "which hive" ("Hive isn't installed." otherwise), and the hive
  it finds is hive-client's, which HCatalog installs, so a Hive step
  runs on a cluster with HCatalog alone.
- Its HCatalog server, hcatalog-server, is the metastore service:
  Hive's hcat_server.sh runs "hive --service metastore".

So a cluster whose Applications name HCatalog installs Hive as one
naming Hive does: its Hive steps run, in the release's image with Hive,
on the metastore service its primary node runs, which its Spark steps'
Hive client uses too.

An emr-spark-* release, the AWS runtime for Apache Spark, includes
neither ("This release includes the following applications:
AmazonCloudWatchAgent, Delta, Hudi, Iceberg, JupyterEnterpriseGateway,
Livy, and Spark."), and has no Hive image to make its steps' image with
Hive from, so a cluster of one installs neither, whatever its
Applications name; one naming Hive asked for that image since #7459.

emr.md now backs a cluster's Spark steps using its metastore with the
Release Guide's EMR pages, in place of the Glue page #7636 quoted:
Spark's default catalog "always connects to a Hive metastore", and
Using HCatalog has Spark SQL read a table the HCat CLI made.
2026-11-07 00:34:27 -06:00
Priamo Germosen ba9a9c8155 feat(emr): run Hive's metastore service on a docker cluster with Hive (#7636)
A cluster's Hive steps kept their metastore in an embedded Derby
database in the cluster's /mnt, so only one Hive step at a time could
use it ("Another instance of Derby may have already booted the
database"), and Spark steps, with a catalog of their own, saw a Hive
step's tables only through the Glue Data Catalog. "By default, Hive
records metastore information in a MySQL database on the primary node's
file system", and the Glue Data Catalog is the one to pick "when you
require a persistent Hive metastore or a Hive metastore shared by
different clusters".

- On a cluster whose Applications name Hive, the primary node's
  container runs Hive's metastore service on port 9083, once its HDFS
  is up: with the image's Hadoop configuration, as Hive steps run, the
  cluster's HDFS, its Derby database in the node's own volume, which
  only the service opens, and its warehouse in the HDFS. The node is
  ready once it listens, and ends if it exits, as for the HDFS daemons.
- It is on the cluster's own Docker network with the HDFS, so only the
  cluster's steps reach it. It reaches tables' S3 locations through S3A
  on Floci's S3, with a session for the cluster's EC2 instance
  profile's role, which goes with the container: at the host's address
  when Floci runs on the host, and as floci when Floci runs in a
  container, which joins the cluster's network for it, as it joins EC2
  VPC networks, and leaves it when the HDFS container goes. A start
  that fails, or a container an earlier Floci left, does not keep
  Floci there, and one Docker keeps Floci on stays known for the next
  teardown.
- It gets the cluster's core-site and hive-site after its own
  settings, as EMR's primary node does, so a hive-site warehouse folder
  holds for it as for the steps. One an earlier Floci left running
  starts again, as its session went with that Floci, and so does one
  given Floci's address before Floci could join its network.
- A Floci that crashed is still on that network when it starts again,
  and Docker lists it first, so what Floci launched then joined it and
  reached the cluster's HDFS and metastore. Floci's own network is no
  longer one it made, an EMR cluster's or a VPC's, its earlier owner
  label included, or one Docker cannot inspect, unless it is on no
  other, and its DNS server takes its address from that network.
- In a namespace the steps share, host or container:<id>, it does not
  run: Hive 3.1 has no setting for the address it listens on, so it
  would serve every interface of the namespace. Hive steps keep the
  embedded Derby database there, as they do with no network.
- Hive steps get its URI in place of the embedded Derby settings, and
  Spark steps' Hive client gets it too, so a Spark step reads a Hive
  step's tables and makes tables a Hive step reads; a hive-site or
  spark-hive-site naming the Glue Data Catalog's client factory still
  uses Floci's Glue.
- Two Hive sessions starting at once both upload Hive's exec jar to
  the same HDFS folder when it is not there, and one could launch Tez
  tasks with a jar that changed under it, so the primary node puts it
  there first, under the name Hive gives it.

EmrHiveStepsDockerIntegrationTest runs two Hive steps at once on a
cluster's metastore, and a Spark step that reads a Hive step's table
and makes one the next Hive step reads.
2026-11-06 23:02:33 -06:00
Priamo Germosen 3a64d2b761 feat(emr): give each docker cluster a real HDFS on its primary node (#7496)
Every EMR cluster runs HDFS: its primary node "also runs the HDFS
NameNode service". In the docker runner mode a cluster's HDFS was a
folder of its /mnt volume behind a view of the hdfs scheme, so an
hdfs:// path naming a host was not served, hadoop fs -ls / failed, and
Hive, which looks up the encryption zone of any hdfs:// path, reached it
under viewfs, where a table at an hdfs:// location failed. Each cluster
now runs a NameNode and a DataNode.

- EmrClusterStorage starts them in a container of their own, from the
  release's EMR Serverless Hive image, which has HDFS's daemons where
  the release's image has only the client. It runs as root only to add
  the primary node's name to its hosts file and give its data volume to
  the hadoop user, then runs both daemons as that user, with one copy of
  each block and permissions off, and makes /tmp and /user/hadoop once
  the DataNode has joined. The data is in a volume of its own, so the
  first container to mount the cluster's /mnt volume is still a step's,
  which fills it with what the bootstrap actions left there. It is on a
  Docker network of the cluster's own, which only the cluster's steps
  join besides theirs, as its HDFS serves its files to any client that
  reaches it, so another cluster's steps, another account's too, do not.
- The AWS runtime for Apache Spark's releases, emr-spark-8.0.0 on,
  publish no Hive image, so their clusters run HDFS from emr-7.5.0's.
  Hadoop keeps its client-server protocols compatible across a major
  version's minor releases, so their newer client reaches its NameNode.
- A step's thread starts it after the cluster's volumes, from the id
  its image's pull, when it is missing, resolves, and waits up to two
  minutes from then, the
  NameNode on its port its own, the DataNode joined and the NameNode out
  of safe mode, as the NameNode's JMX says; a step that comes while
  it starts waits, and one that finds it running uses it. A failure
  fails the step ("The step could not start: ..."), and one whose
  container Docker cannot tell the state of leaves it as it is.
- The daemons log their warnings and errors to the container's output.
- When either daemon exits, the container ends and its readiness goes,
  so the next step starts it again on the data its volume keeps; one
  that finds it about to stop starts it again once.
- Steps reach it by the primary instance's PrivateDnsName, as
  ListInstances gives it, on port 8020: their containers resolve that
  name to the HDFS container's address, and fs.defaultFS names it, so
  hdfs:// paths without a host and paths without a scheme lead there.
  ListInstances numbers the MASTER group's instance first, so the name
  holds while other groups resize.
  In a namespace the steps share, the host's or another container's,
  which the HDFS container joins too, they reach it on its loopback, and
  its daemons listen there only, so no other interface serves its files,
  which any client could change; one cluster's HDFS runs there at a
  time, another's refused while it does. One a process with another
  docker-network left running, in another namespace than the steps', is
  started again in theirs on its data. With none, steps have no network,
  so the cluster runs no HDFS.
- Hadoop's local job runner copies a job's -files to
  /tmp/hadoop/mapred/staging on the local file system, then looks for
  them at that path of the default file system, as JobResourceUploader
  drops the folder's scheme. So in the hadoop command's configuration,
  which a custom JAR's MapReduce in the driver reads too, the hdfs
  scheme is a view of the cluster's HDFS in which that one folder is
  the container's own. Spark and Hive keep HDFS's own client, as Hive
  casts an hdfs:// file system to it to look up its encryption zone,
  so a Spark step writes a Hive table in HDFS too.
- A reset or a shutdown removes the HDFS containers this process
  started, found running or kept from an earlier process, after the
  drivers that use them are stopped, and a step or a bootstrap handed to
  its thread before it, however it then ends, starts no HDFS, driver or
  successor after it but is left as one whose driver was stopped, and
  none is handed to a thread until the reset is over; a container Docker
  refuses to remove stays known for the next; a cluster's next step
  starts its HDFS again on the data its volume keeps. The container and
  its network go with the cluster's storage, and the startup sweep
  removes those of clusters that are gone or have ended.

Every cluster now needs a Hive image, so the documentation of
image-template and hive-image-template says a mirror sets both.

The Docker-gated tests now cover a Hive table at an hdfs:// location, a
bootstrap action's file in /mnt, a structured streaming query keeping
its checkpoints in HDFS, a Spark step writing a Hive table there, hadoop
fs -ls /, and a DataNode that exits, after which the next step reads an
earlier step's file. The CI prefetch queues the Hive image for
EmrDockerRunnerDockerIntegrationTest's shard too.
2026-11-04 21:50:36 -06:00
Priamo Germosen 5a4632229e feat(emr): run Hive steps in the docker runner mode (#7459)
In the docker runner mode a Hive step failed without running ("hive-script
and pig-script are not in the image steps run in"). On a cluster whose
Applications name Hive, a command-runner.jar step running hive-script, as
the AWS CLI writes a Type=Hive step ("hive-script --run-hive-script
--args" and the step's Args), or hive itself, now runs: the image's
hive-script runs hive with the arguments after --args, with Tez in local
mode, on the cluster's storage and Floci's S3.

- An EMR cluster's nodes hold every application it installs, so a
  cluster with Hive bootstraps and runs every step in one image: the
  release's EMR Serverless image with the Hive, Tez, HDFS, MapReduce and
  YARN of its EMR Serverless Hive image (or the new hive-image-template).
  EmrReleaseImages makes it the first time a release's cluster needs it:
  a container of the EMR Serverless image, created and never started,
  gets the Hive image's folders streamed in from a container of that
  image, and is committed, as a bootstrap's container is, with no image
  builder involved. The two images ship different builds of
  emr-serverless-goodies-common under one name, so Tez keeps the Hive
  image's in a folder of its own, its links rewritten to lead there, and
  the Hive image's Hadoop configuration, which puts Tez on the class
  path, goes to /etc/hadoop/conf.hive, which Hive runs with.
- The image is named after the release, the ids of the two images as a
  container would run them (an image-registry-base included) and what
  is copied, so a newer pull of either makes another; it is kept for the
  release's next cluster, and made once at a time. The bootstrap and the
  steps get its id, as they get a bootstrap image's, from their own
  thread, which makes it first, unless the cluster has ended by then; a
  failure to make it fails the step, or ends a bootstrapping cluster with
  INTERNAL_ERROR.
- hive gets Floci's settings, then the cluster's core-site, tez-site and
  hive-site properties as --hiveconf settings, then the step's own
  arguments, so a step's --hiveconf wins as it does over hive-site.xml;
  the cluster's hive-env exports are its environment.
- Its metastore is the cluster's own, as "Hive records metastore
  information in a MySQL database on the primary node's file system": an
  embedded Derby database in the cluster's /mnt, so a table one Hive step
  makes is there for the next until the cluster ends. A hive-site naming
  the Glue Data Catalog's client factory uses Floci's Glue instead.
- Hive reaches the cluster's HDFS through the same view of /mnt/hdfs
  under the viewfs scheme: Hive looks up the HDFS encryption zone of any
  hdfs:// path, which only an HDFS NameNode answers. A table without a
  LOCATION is in /user/hive/warehouse there, which other steps read as
  hdfs://.
- On a cluster without Hive, hive-script runs in the release's image, as
  EMR's does without Hive ("Hive isn't installed."); NOT_RUN is
  pig-script's alone.

The Docker-gated EmrHiveStepsDockerIntegrationTest runs the AWS CLI's
Hive steps on a cluster's metastore and HDFS, a hive-site for the Glue
Data Catalog, a cluster without Hive, and a bootstrapped cluster whose
installs a Hive step and a later step both find, in the emr-7.5.0
images, which the CI prefetch pulls for its shard.
EmrServerlessSparkRunner's hiveSettings now builds both services'
--hiveconf settings.
2026-11-03 23:18:20 -06:00
Priamo Germosen cfd7e83776 fix(glue): let the Glue catalog client read back tables and partitions (#7329)
The Glue Data Catalog client, which Spark's Glue catalog and Hive's
Glue metastore use on EMR, could not read back a table it had just
created on Floci: "NullPointerException: Cannot invoke
java.lang.Integer.intValue() because the return value of
Table.retention() is null". Floci's Table had no Retention, and its
StorageDescriptor no StoredAsSubDirectories, SortColumns, BucketColumns,
SkewedInfo or AdditionalLocations, so what the client wrote was
dropped, and the client unboxes Retention, Compressed, NumberOfBuckets,
StoredAsSubDirectories and an Order's SortOrder without a null check.
Past that, a partitioned table came back with each partition, and so
each row, five times: the client reads a table's partitions in five
GetPartitions segments by default, and Floci answered every segment
with all of them.

Now:

- Table keeps Retention and IsRegisteredWithLakeFormation, and
  StorageDescriptor keeps AdditionalLocations, BucketColumns,
  SortColumns, SkewedInfo and StoredAsSubDirectories, and the table and
  descriptor copies carry them.
- every table and partition a catalog action returns (GetTable,
  GetTables, SearchTables, GetTableVersion, GetTableVersions,
  GetPartition, GetPartitions, BatchGetPartition) reads Retention as 0,
  IsRegisteredWithLakeFormation as false, and a storage descriptor's
  Compressed, NumberOfBuckets, SortColumns and StoredAsSubDirectories
  as false, 0, an empty list and false when they were written without
  them, as the CLI reference's get-tables output shows Glue doing. The
  stored records keep their nulls: Spectrum reads a partition's missing
  Compressed as its table's.
- GetPartitions honours Segment, "a non-overlapping region of a
  table's partitions": a partition is in the one segment its values
  hash to, a SegmentNumber past the last holds none, and TotalSegments
  outside 1 to 10, a negative SegmentNumber or a missing member is a
  ValidationException, and a member that is not an integer a
  SerializationException.
- a SortColumns entry that is null, lacks Column or SortOrder, or has a
  SortOrder other than 0 or 1 fails the whole CreateTable, UpdateTable,
  CreatePartition, UpdatePartition, BatchCreatePartition or
  BatchUpdatePartition with a ValidationException before anything is
  stored, as the client unboxes SortOrder on read.

- the EMR runner gives the client the job's account as its
  hive.metastore.glue.catalogid, on a cluster and in an EMR Serverless
  run. Given none, the client in emr-7.10.0 asks STS GetCallerIdentity
  for it through an STS client no setting points at Floci, so a step
  reached real AWS STS and failed. The job's own account is what an
  unset one means, and a cluster's spark-hive-site or a run's
  spark-defaults one, for a Data Catalog in another account, still wins.

IsRegisteredWithLakeFormation is always false, as Floci does not tie a
table to a location registered with Lake Formation.
2026-11-02 17:31:48 -06:00
Priamo Germosen db3efe8186 feat(emr): run a custom JAR's MapReduce and apply Hadoop classifications (#7294)
In the docker runner mode a custom JAR step whose main class starts a
MapReduce job, such as the Management Guide's wordcount of Hadoop's
examples JAR, never ended: its spark-submit read the image's
mapred-site.xml, which names YARN, and the job kept retrying a
ResourceManager at 0.0.0.0:8032. A Jar of
/usr/lib/hadoop-mapreduce/hadoop-streaming.jar, where EMR has it, named
a file the image lacks. And a cluster's mapred-site, hadoop-log4j and
hadoop-env classifications reached none of its steps.

Now, on a cluster:

- a custom JAR or Spark step's spark-submit runs after the Hadoop setup
  a command gets, so its HADOOP_CONF_DIR is the copy with Floci's S3,
  the cluster's HDFS and MapReduce in local mode, which spark-submit
  puts on its class path; a MapReduce job its main class starts runs in
  the driver's JVM.
- a Jar of /usr/lib/hadoop-mapreduce/hadoop-streaming.jar runs the
  image's /usr/lib/hadoop/hadoop-streaming.jar.
- mapred-site, which will "Change values in the MapReduce application's
  mapred-site.xml file", goes in the copied mapred-site.xml ahead of
  Floci's local mode and staging folder, which win.
- hadoop-log4j, which will "Change values in Hadoop's log4j.properties
  file", follows the copied log4j.properties, a later key winning.
- hadoop-env's export classification starts the copied hadoop-env.sh,
  which the hadoop command reads, each value as given, single-quoted,
  as spark-env's exports are set without shell expansion; a name a
  shell cannot export is left out. The image's own lines come after
  and add to HADOOP_CLASSPATH rather than set it, so the Release
  Guide's HADOOP_CLASSPATH of /path/to/my.jar keeps the LZO codec the
  image's core-site.xml names, without which every job fails.
- a jar the MapReduce home links that the image lacks is named on the
  step's standard error, as a job that needs it fails later, on its
  class path, and emr.md says which releases this has run on (emr-7.5.0
  and emr-7.10.0).

An EMR Serverless run still starts spark-submit as it is. A custom JAR
step's spark-submit reads neither hadoop-env.sh nor Hadoop's
log4j.properties, so those two do not reach it.
2026-11-02 07:53:24 -06:00
Priamo Germosen 048070e699 feat(emr): run hadoop-streaming and hadoop-lzo steps (#7264)
In the docker runner mode a command-runner.jar step running
hadoop-streaming, which "Submits an Hadoop streaming program. In the
console and some SDKs, this is a streaming step", or hadoop-lzo, the LZO
indexer, failed without running, as the image's hadoop had no MapReduce;
and a command's hadoop fs could not reach S3, its classpath having no
AWS SDK v2 and the image's EMRFS not being pointed at Floci.

Now a step's hadoop command, on its cluster:

- runs MapReduce in local mode: links to Spark's shaded Hadoop client,
  the image's only copy of MapReduce, and to the jar Spark's own S3A
  finds the AWS SDK in make up its MapReduce home, so they are on its
  class path whatever HADOOP_CLASSPATH a command sets, and a copy of its
  mapred-site.xml sets mapreduce.framework.name to local. The local job
  runner names a job's -files and -archives by their path alone, which
  the default file system, the cluster's HDFS, resolves, so its staging
  folder is a link to the same path in the HDFS folder.
- reaches Floci's S3 through S3A, with the settings its spark-submit
  gets, now one list for both, ahead of the cluster's HDFS and
  core-site.
- logs to standard error when its log4j.properties is empty, as the
  image's is, in the layout of the Management Guide's step log lines, so
  a failed job's reason is in the step's stderr.
- runs hadoop-streaming from the jar the image has, where the image's
  own hadoop-streaming names /usr/lib/hadoop-mapreduce, which it lacks.

hive-script and pig-script steps still fail without running.
2026-11-01 20:57:59 -06:00
Priamo Germosen b4ae0ce9e0 feat(emr): apply a step's Properties, core-site and spark-log4j2 (#7226)
In the docker runner mode a step's HadoopJarStep.Properties, "A list of
Java properties that are set when the step runs. You can use these
properties to pass key-value pairs to your main function", were kept
but never applied, and of a cluster's classifications only
spark-defaults, spark-hive-site and spark-env reached its steps.

Now:

- A custom JAR step's Properties are system properties of the JVM its
  main class runs in, through SPARK_SUBMIT_OPTS, each -Dkey=value in
  single quotes as spark-submit's launcher reads them, after any Java
  options a spark-env export puts there, so a step's own win. A
  command-runner.jar or script-runner.jar step's would be its runner's
  own JVM's, which Floci has none of, and a JVM's system properties do
  not pass to a process it starts, so they go nowhere. The API sentence
  is the only source; emr.md calls this Floci's reading.
- core-site, which will "Change values in Hadoop's core-site.xml file",
  reaches Spark as spark.hadoop. settings ahead of spark-hive-site's,
  as core-site.xml comes ahead of hive-site.xml, with spark-defaults
  winning over both; a command's hadoop command gets it too, after the
  cluster's HDFS settings in its core-site.xml copy, escaped for XML.
- spark-log4j2, which will "Change values in Spark's log4j2.properties
  file", follows the log4j2.properties of the Spark configuration a
  spark-env export of SPARK_CONF_DIR names, else the image's, in a copy
  of the step's own, a later key winning: a Spark step with some runs
  spark-submit after a wrapper that makes the copy, and a command's
  wrapper does the same before its own changes, now from that exported
  folder too, links followed. What is added starts on a line of its
  own, as the image's log4j2.properties has no line break at its end,
  and a value's leading spaces are escaped, as Properties.load would
  skip them.

SparkJobRunner.Job gets coreSite and sparkLog4j2 components, which an
EMR Serverless run leaves empty.
2026-11-01 17:17:26 -06:00
Priamo Germosen a74a9b0ffc feat(emr): run s3-dist-cp steps (#7192)
In the docker runner mode an s3-dist-cp step, the Release Guide's way of
moving data "from Amazon S3 into HDFS where it can be processed by
subsequent steps", between buckets or back to S3, was FAILED without
running, and on the default TERMINATE_CLUSTER it ended its cluster with
errors. The EMR Serverless image steps run in has neither s3-dist-cp nor
the MapReduce it runs on.

Now a command-runner.jar step whose first argument is s3-dist-cp runs
Floci's own S3DistCp: a Python program, emr/s3-dist-cp.py, which the step's
command writes into the container and runs through spark-submit, copying
through Hadoop's file systems in Spark's JVM. The command wrapper gives it
what a Spark step gets: S3 paths in Floci's S3 and hdfs:// paths, and
those without a scheme, in the cluster's HDFS. It takes the options of
the Release Guide's table, --name=value or --name value, and -D
property=value:

- --src and --dest, a source folder's files keeping their folders;
- --srcPattern and --groupBy matched against the whole path; --groupBy
  concatenates the files whose groups give the same name into one file
  named by them, and refuses an expression with no group, as the guide
  says S3DistCp does; --targetSize breaks a larger group into parts
  numbered before the extension ("myfile0.gz, myfile1.gz"); without
  --outputCodec a group keeps the compression its files share, named
  with that codec's extension, or has none when they differ, each file
  decompressed so the group is one stream;
- --outputCodec (gzip, gz, lzo, lzop, snappy, none) through Hadoop's
  codecs, each source decompressed by its own extension;
- --deleteOnSuccess, deleting the files but not their folders, as AWS's
  "Seven tips for using S3DistCp" says;
- --outputManifest, --previousManifest, --requirePreviousManifest and
  --copyFromManifest, the manifest gzipped JSON lines of path, baseName,
  srcDir and size, as that post shows them;
- --s3ServerSideEncryption, --storageClass, --disableMultipartUpload and
  --multipartUploadChunkSize as S3A's settings; --numberFiles,
  --startingIndex, --srcPrefixesFile and --appendToLastFile, the last
  through a copy renamed over the file, as neither S3 nor the cluster's
  HDFS appends in place. The copy has a name of its own and goes if the
  writing fails, and the file steps aside, under a name of its own too,
  until the copy has taken its place, coming back if it cannot, so a
  failed append leaves it as it was. --s3Endpoint is ignored, S3 being
  Floci's.

--requirePreviousManifest takes true or false, after = or as the next
argument, and alone is true, its default. A --srcPrefixesFile line ending
in / names that folder alone, its slash kept though Hadoop's Path drops
it; any other is a prefix as S3 lists one, logs/day taking in
logs/day-old/.

A bucket name with an underscore fails the step, as S3DistCp "does not
support" one, and so does a copy Hadoop fails, leaving what was copied.
A copy that would write two files to the same path, the manifest
included (a.log and a.log.gz with --outputCodec=gzip), a file over one
of its own sources, as with the same --src and --dest, or a file outside
--dest, through a .. in a manifest's baseName or in --outputManifest
(Hadoop's paths resolve it), or a file with no name, from a --groupBy
whose groups matched nothing say, fails before it writes anything. emr.md
says what is Floci's own reading: the grouped file's folder,
--numberFiles' naming, a group's compression without --outputCodec and
that refusal.
2026-11-01 10:10:13 -06:00
Priamo Germosen ebf91d1a8e feat(emr): keep a cluster's storage, HDFS included, across its steps (#7137)
In the docker runner mode each step of a cluster ran in a container of its
own, so nothing a step left in /home/hadoop, or in HDFS, was there for the
next, and the image has no HDFS at all: an hdfs:// path failed, and a path
without a scheme, which EMR reads as HDFS, went to the container's own
disk. The Management Guide calls HDFS "best used for caching the results produced by
intermediate job-flow steps", the prefix "hdfs:// (or no prefix)", and
"ephemeral storage that is reclaimed when you terminate a cluster"; the
Release Guide's S3DistCp page copies data "into HDFS where it can be
processed by subsequent steps".

Now a cluster's storage outlives its steps:

- each step's container mounts the cluster's two Docker volumes, one at
  /home/hadoop and one at /mnt, both of which the image gives its hadoop
  user, so Docker gives an empty volume that owner, and what the cluster's
  bootstrap left there in the image its steps run in;
- HDFS is /mnt/hdfs: Spark gets fs.defaultFS hdfs:/// and the hdfs scheme
  through Hadoop's ViewFileSystemOverloadScheme with a fallback link to
  that folder, so hdfs:// paths and those without a scheme lead there, a
  relative one under /user/hadoop, and a streaming query keeps its
  checkpoints through Spark's file system checkpoint manager, as
  FileContext refuses an hdfs:// path without a host. The cluster's
  spark-defaults can set any of these otherwise;
- a command step's hadoop fs gets the same, through a copy of the image's
  Hadoop configuration, or of the folder a spark-env export of
  HADOOP_CONF_DIR names, links followed, whose core-site.xml takes in
  the original's through Hadoop's XInclude and then those properties,
  with its HDFS, MapReduce and YARN homes set; hdfs dfs runs as hadoop
  fs, the image's hdfs command being unable to run;
- the volumes go once the cluster has ended and its last step is done,
  tried again while Docker refuses, as the bootstrap's image is; on a
  reset, a step's thread it overtook removing them again once its
  container is gone; and, for clusters that are gone or have ended, when
  the service starts, unless reconcile-containers-on-startup is off.

SparkJobRunner.Job carries the storage, which an EMR Serverless run leaves
null. ClusterStorage names, makes and removes the volumes;
EmrClusterStorage is its Docker side. A path without a scheme that a step
meant for its container's own disk now leads to HDFS, as on EMR. emr.md
says what HDFS lacks: no NameNode, no hdfs:// path with a host, no
hadoop fs -ls / and no S3 through hadoop fs.
2026-10-31 21:30:43 -05:00
Priamo Germosen 264513650c feat(emr): apply a cluster's spark-env and spark-hive-site to its steps (#7047)
In the docker runner mode a step's spark-submit got the spark-defaults
of the cluster's Configurations, and nothing else from them. The
Release Guide's other two Spark classifications that change what a job
does were ignored:

- spark-env "Sets values in the spark-env.sh file", through its nested
  export classification ("If any classification ends in env, use the
  export sub-classification"). It is how a cluster picks the Python
  PySpark runs (PYSPARK_PYTHON) or the JVM (JAVA_HOME). Its exports are
  now the step container's environment variables, replacing any of
  Floci's own with the same name. The image's spark-env.sh only
  defaults PYSPARK_PYTHON, PYSPARK_DRIVER_PYTHON, SPARK_HOME and
  HADOOP_CONF_DIR, so the exports win there.
- spark-hive-site "Sets values in the hive-site.xml for Spark", as the
  Management Guide uses it to put Spark's tables in the Glue Data
  Catalog (hive.metastore.client.factory.class). Its properties now
  reach spark-submit as spark.hadoop. settings, which Spark's Hive
  client reads as it would hive-site.xml; a spark.hadoop. setting in
  spark-defaults wins over them, as it would over hive-site.xml.

SparkJobRunner.Job carries the environment, which an EMR Serverless run
leaves empty. The exports are set as given, with no shell expansion,
and a command or script step sees them too; emr.md says so.

Separately, the pattern EcrRegistryManager reads an ECR image's Region
with, which EMR Serverless checks an application's custom image
against, now names the hosts it takes: AwsPartitions.dnsSuffixRegex()
for AWS's, as AWS_ECR_URI does, and localhost or localhost.floci.io
with a port for the repositoryUri Floci's ECR hands out. It took any
host after the Region before, so an image on a registry that only
looks like ECR's (<account>.dkr.ecr.<region>.registry.internal/...)
was refused for being in another Region.
2026-10-31 10:27:25 -05:00
Priamo Germosen c9bc1e7cb8 feat(emr): have the JVMs in EMR containers trust Floci's CA (#6926)
With TLS on, every container Floci launches gets the CA bundle and the
SSL_CERT_FILE family of variables, but the JVM reads none of them. So
in the docker runner mode a Spark job's own SDK clients that ignore
AWS_ENDPOINT_URL, the AWS SDK for Java 1.x's or an older 2.x's,
failed with "PKIX path building failed" against Floci's HTTPS, even
with FLOCI_DNS_SPOOF_AWS_ENDPOINTS sending AWS's endpoint names to
Floci. A job could only reach Floci over its HTTP endpoint.

Floci now also writes the bundle's certificates as a PKCS12 trust
store at boot, floci-ca-bundle.p12 beside the bundle. A launcher whose
workload is Java can copy it into a container before the container
starts (ContainerLifecycleManager.copyJavaTrustStore) and point the
container's JVMs at it through JAVA_TOOL_OPTIONS, with a shell line
that does so only when the file is there. The store has no password
and the line gives only its path, so a trust store a job or an image
names itself replaces Floci's, with that store's own type and
password. EMR Serverless job runs and EMR steps copy it into the
driver's container ahead of spark-submit or the step's command, and
the bootstrap actions' container gets it for its actions, then drops
it before the image is kept. Other services' containers are unchanged.

JAVA_TOOL_OPTIONS rather than spark.driver.extraJavaOptions, since
setting that key would replace what the image's spark-defaults.conf
gives it, and a job's own value would drop Floci's. Each JVM prints
"Picked up JAVA_TOOL_OPTIONS: ..." on its standard error, as the docs
now say.
2026-10-29 07:50:46 -05:00
Priamo Germosen 591d5f533b feat(emr): run a cluster's bootstrap actions in the docker runner mode (#6878)
In the docker runner mode a cluster's BootstrapActions were stored and
listed but never run, so a step that needed what they install, such as
a Python library a PySpark step imports, failed where on AWS it would
run. Now a cluster with bootstrap actions is BOOTSTRAPPING while they
run, one after the other, in one container of the release's EMR
Serverless image, and that container is then kept as the image the
cluster's steps run in.

- Each action's script is read from Floci's S3 (s3n:// and s3a:// name
  the same bucket) and runs with its Args in /home/hadoop through
  docker exec, with the credentials of the cluster's instance profile
  in that exec's environment alone, so they never become part of the
  image.
- "Bootstrap actions execute as the Hadoop user by default. You can
  execute a bootstrap action with root privileges by using sudo", but
  the image has no sudo: an action runs as root, with a sudo that runs
  its command as it is, and what it leaves in /home/hadoop is the
  hadoop user's. The kept image runs as the user of the image the
  container ran, as the steps do, and the steps get it by its id, which
  runs as it is whatever image-registry-base Floci pulls images from.
- An action that exits with another code than 0 ends the cluster
  TERMINATED_WITH_ERRORS, with BOOTSTRAP_FAILURE and "On the master
  instance (<instance-id>), bootstrap action <n> returned a non-zero
  return code", as a real cluster gave it
  (hashicorp/terraform-provider-aws#4378) and the Management Guide
  quotes it. A script that cannot be read ends it the same way, in
  Floci's words; a bootstrap that cannot run, or that a restart cut
  short, with INTERNAL_ERROR. TerminateJobFlows stops it at once.
- With a LogUri, each action's stdout.gz and stderr.gz go under
  <LogUri>/<cluster-id>/node/<instance-id>/bootstrap-actions/<n>/, the
  instance the master as ListInstances gives it. An action's output
  goes to Floci's log line by line as it runs, and to those files
  gzipped as it arrives, through a file on disk, so however much it
  writes, Floci keeps no more than a line of it in memory.
- The image goes once the cluster has ended and its last step is done,
  and the cluster names it until it is gone, so a removal Docker
  refuses is tried again the next time the cluster is read; a reset
  removes them all, and the startup sweep, before any restarted cluster
  can move on, the ones of clusters that are gone or have ended.

ContainerExec gets an overload that sets an environment for one
command alone. What the bootstrap has in common with the Spark runner
and the rest of Floci is shared rather than copied:

- core.common.docker.ContainerLaunches: the runs in progress and their
  containers, which a stop, a reset or a shutdown removes; both EMR
  runners keep theirs in it.
- ContainerLifecycleManager.commit and removeImage.
- ContainerLogStreamer.consoleLines, a stream that logs each line as it
  arrives through the line logger its attach methods now share.
- S3Uri.isS3 and parseAnyScheme, which read s3n:// and s3a:// as s3://.
- EmrServerlessSparkRunner.putLogs, the runner's S3 log writing, which
  now reads each file from a stream.
2026-10-28 21:59:40 -05:00
Priamo Germosen 897667f4e6 feat(emr): run command-runner.jar commands and script-runner.jar scripts (#6747)
In the docker runner mode a step that was not a Spark step failed
without running, so a cluster whose steps copy files with the AWS CLI,
run a shell or Python script, or call script-runner.jar could not run
its steps in Floci. Such steps now run in the same per-step container
of the release's EMR Serverless image, with the same credentials,
endpoint, logs and lifecycle as a Spark step, as the Release Guide's
"Run commands and scripts on an Amazon EMR cluster" describes them:

- command-runner.jar runs its arguments as a command, the first naming
  it, unless that is spark-submit (the Spark step, as before) or a tool
  the image does not have: hive-script, pig-script, hadoop-streaming,
  hadoop-lzo and s3-dist-cp still fail without running.
- script-runner.jar, by name (7.13 on) or by its
  s3://<region>.elasticmapreduce/libs/script-runner/script-runner.jar
  URI, fetches its script from S3 with the image's AWS CLI and the
  step's credentials, then runs it with the step's other arguments. A
  local script named without a path runs from the working directory
  when a file there has that name.

The image runs them as its hadoop user in /home/hadoop, with bash,
Python 3, Java, curl and AWS CLI v2, which reaches Floci through
AWS_ENDPOINT_URL. A spark-submit they start runs in local mode on
Floci's S3 with the cluster's spark-defaults: the image's
spark-defaults.conf names EMR Serverless's resource manager as its
master, which a system property cannot override, so the container
starts through a wrapper that copies the image's Spark configuration,
drops that master, and adds local mode, Floci's settings and the
cluster's spark-defaults, in a SPARK_CONF_DIR of its own, each setting
escaped for the Properties file Spark reads it as. A step's own --conf
still wins. A failed command reads "The step's command exited
with code N.".

SparkJobRunner.Job gets a command, run in place of spark-submit.
2026-10-27 23:41:56 -05:00
Priamo Germosen 0a47ddd5e4 feat(emr,emr-serverless): write Spark driver logs to S3 (#6620)
In the docker runner mode a Spark driver's output went only to Floci's
log. Once a driver ends, the shared runner now reads its standard output
and error from Docker and puts them, gzipped, into Floci's S3 as
stdout.gz and stderr.gz in the run's log folder, while the container is
still the run's. A driver a cancel or its timeout ended is stopped
first, through a new ContainerLifecycleManager.stop that leaves the
container in place, so it changes nothing more while its output is read
and the logs hold all it wrote; a driver Floci's teardown took writes
nothing. Logs that cannot be written leave the run as it ended.

- EMR steps: under the cluster's LogUri, at
  <LogUri>/<cluster-id>/steps/<step-id>/ (Management Guide, "Log
  locations"); without a LogUri "logs are not created". An s3n:// or
  s3a:// LogUri names the same bucket.
- EMR Serverless job runs: under the run's s3MonitoringConfiguration
  logUri, or else the application's (the user guide merges them by
  configuration type, and an empty one at the run removes it), at
  applications/<applicationId>/jobs/<jobRunId>/SPARK_DRIVER/, with
  attempts/1/ before SPARK_DRIVER/ for a STREAMING run or a BATCH run
  whose retry policy allows more than one attempt, on 7.1.0 or later.

FailureDetails gets no LogFile: the Management Guide ties it to a root
cause EMR identifies, and Floci's Reason is always "Unknown Error".

core.common.S3Uri splits the folder's s3:// URI into bucket and key.
2026-10-26 19:16:40 -05:00
Priamo Germosen 4b33002784 feat(emr): run Spark steps in containers in a docker runner mode (#6578)
Classic EMR steps never ran: each one completed after
step-duration-seconds, so a step could not fail, a failed step's
ActionOnFailure never applied, and no cluster ever ended
TERMINATED_WITH_ERRORS. A new floci.services.emr.runner-mode, immediate
by default (today's timed lifecycle), runs each step in docker mode:

- One container per step, from when the step goes RUNNING until its
  Spark driver exits, through the runner EMR Serverless's docker mode
  uses: spark-submit in local mode in the release's EMR Serverless image,
  with S3A and Glue pointed at Floci. The cluster gets no container.
- command-runner.jar running spark-submit gets the arguments after it,
  without --master and --deploy-mode; a custom JAR runs its MainClass,
  or its manifest's, with the JAR and its Args. Other steps (Hive, Pig,
  script-runner.jar, other commands) fail without running.
- The step is COMPLETED on exit code 0 and FAILED otherwise, with
  FailureDetails: Reason "Unknown Error", which the API reference says
  EMR gives when it cannot find the root cause, and Floci's message.
- ActionOnFailure as the API reference and the Management Guide give
  it: TERMINATE_CLUSTER ends the cluster unless it waits after its steps
  and is protected; CANCEL_AND_WAIT cancels the pending steps and waits,
  or ends a cluster set to end after its steps; CONTINUE goes on; none
  applies above concurrency level 1, nor CANCEL_AND_WAIT with other
  steps running. A cluster a failure ends is TERMINATED_WITH_ERRORS with
  STEP_FAILURE and "Shut down as step failed".
- Step FAILED (ERROR) and cluster TERMINATED_WITH_ERRORS (CRITICAL)
  events, with the messages of the guide's event tables.
- CancelSteps and TerminateJobFlows stop a running step's driver. A
  driver Floci's shutdown or a reset stops leaves its step as it is, so
  no other step starts once the teardown has passed: a step Floci was
  running is FAILED once Floci is back, and a reset's threads write
  nothing after it. Leftover drivers are removed when the service
  starts, before any step can, unless reconcile-containers-on-startup is
  off.
- The driver runs as the step's ExecutionRoleArn, or else the role of
  the cluster's JobFlowRole instance profile, and gets the spark-defaults
  of the cluster's Configurations.

New settings: runner-mode, docker-network, image-template and
reconcile-containers-on-startup, as EMR Serverless has.

The shared runner now reads Progress.cancelled() at every look at a
running driver, so a driver whose run a reset removed is stopped, and
removeLeftoverDrivers is on SparkJobRunner. EMR Serverless's job run
service counts a RUNNING run as not cancelled accordingly.
2026-10-25 22:30:25 -05:00
Priamo Germosen 55b060b891 feat(emr): add an optional timed lifecycle for clusters and steps (#6441)
Three settings, all 0 by default, hold an EMR cluster and its steps in
the states of the Management Guide's cluster lifecycle.
cluster-startup-delay-seconds, declared before but read by nothing,
keeps a new cluster STARTING for its first half and BOOTSTRAPPING for
its second; step-duration-seconds keeps each step RUNNING; and
cluster-termination-delay-seconds keeps a cluster TERMINATING before it
is TERMINATED. A ready cluster is RUNNING while it runs its steps, in
the order they were added and at most its StepConcurrencyLevel at a
time, and WAITING once none is left; a transient one ends after them
without waiting. ModifyCluster starts the steps a higher level makes
room for. TerminateJobFlows cancels every step not yet completed, as
its API reference says, and CancelSteps cancels a RUNNING step from
release emr-5.28.0, which makes room for the next. A waiter or a step
sensor now has something to wait for, and CancelSteps something to
cancel.

A new EmrClusterLifecycle works out when each change falls due from the
settings and the times already recorded. Every call that reads a
cluster first makes the changes due by then, and the service wakes at
each cluster's next change, also after a restart, so the change's
aws.emr event goes out when it happens, read or not; a wakeup sends its
events on a thread of their own, in order, so a slow rule target holds
up no cluster's change. A step's RUNNING now sends the step events
table's event, and a WAITING cluster that runs added steps sends
WAITING again once they are done. Every call that reads a cluster now
holds the service and publishes its events after, as the four that
changed one did, and answers from a copy made while it holds it.

With the settings at 0, a cluster is ready, and its steps complete,
before the call returns, as before; the step RUNNING events and the
second WAITING are the only new events. ModifyInstanceGroups and
ModifyInstanceFleet refuse a cluster that is not RUNNING or WAITING, a
STARTING or BOOTSTRAPPING one included, as their AWS messages say, and
AddJobFlowSteps and ModifyInstanceFleet a TERMINATING one, whose AWS
message names a cluster "shutting down". AddInstanceFleet gives a
TERMINATING one ModifyInstanceFleet's answer too, and AddInstanceGroups
AddJobFlowSteps' ValidationException, since its model declares no
InvalidRequestException; an AddJobFlowSteps with no steps leaves the
cluster as it is.

Part of #6046 (part 4).
2026-10-24 20:22:11 -05:00
Priamo Germosen 1174922522 feat(emr): publish aws.emr cluster and step events to EventBridge (#6403)
EMR now sends the "EMR Cluster State Change" and "EMR Step Status
Change" events AWS sends to the default EventBridge bus, so a rule can
start a Lambda function or a state machine when a cluster is ready or
ends, or when a step completes. Nothing published an aws.emr event
before.

Each event carries the detail of the EMR Management Guide's examples,
with the severity and message its "Monitoring Amazon EMR events" tables
give the state, times to the minute in UTC, and no resources, as in the
examples and in an event recorded from AWS. Since steps complete at
once, RunJobFlow sends the cluster STARTING, each step PENDING and then
each COMPLETED, and then the cluster WAITING, or TERMINATED with
ALL_STEPS_COMPLETED when it ends after its steps. AddJobFlowSteps sends
its steps' events and that TERMINATED. TerminateJobFlows sends
TERMINATED with USER_REQUEST for each cluster it ends, also when a
protected cluster fails the call, and CancelSteps CANCELLED for each
step it cancels. The tables have no row for BOOTSTRAPPING, RUNNING or
TERMINATING, which send nothing.

A request's steps are now all created PENDING before the first one
completes, as the guide's "Running steps to process data" describes;
each step was created only after the one before it had completed.

EmrService queues a call's events while it holds the service, so they
keep the order the changes were made in, and publishes the queue once
it has let go, so a rule's target that calls EMR back never waits on
the call that made the change. One call publishes at a time: a call
made while an event is delivered queues its events behind the rest, and
the call already publishing sends them after. Each event goes to the
account and Region of the call that queued it. The events go through a
new EventBridgeService.publishServiceEvent, which logs an entry the bus
rejects, or any failure publishing it, instead of failing the change
the event reports. The integration test reads them through a new shared
EventRuleQueue, an SQS queue an EventBridge rule routes them to, which
deletes what it reads and removes the rule and queue when closed.

Part of #6046 (part 5).
2026-10-24 08:38:24 -05:00
Priamo Germosen 94c4572fed feat(stepfunctions): add the elasticmapreduce optimized integrations (#6261)
A Task can now use the optimized EMR integrations the Step Functions
guide lists: createCluster, setClusterTerminationProtection,
terminateCluster, addStep, cancelStep, modifyInstanceFleetByName and
modifyInstanceGroupByName, with .sync for createCluster, terminateCluster
and addStep. Each calls Floci's EMR in the state machine's Region under
the guide's field names: ClusterId for JobFlowIds or JobFlowId, a single
Step or StepId, and the instance fleet or group found by name through
ListInstanceFleets or ListInstanceGroups. They failed with "Unsupported
resource" before.

A .sync Task records TaskSubmitted with the call's result and polls
DescribeCluster or DescribeStep under the Task's TimeoutSeconds and the
execution's budget, as ecs:runTask.sync does. Its result is the describe
response with the call's result after it, which is the createCluster.sync
output recorded on AWS (Cluster, then ClusterId). A step that ends FAILED,
CANCELLED or INTERRUPTED, or a cluster that terminates before WAITING,
fails the Task with States.TaskFailed and the describe response as the
cause. A wait that ends early cancels the step of an addStep.sync; a
cluster is left running, as the guide says Step Functions does.

An EMR error is named after the SDK exception class under EMR.:
InvalidRequestException and InternalServerException keep their names,
and any other code is EMR.AmazonElasticMapReduceException, as AWS reports
a ValidationException. createCluster refuses
KeepJobFlowAliveWhenNoSteps other than true and Steps, as the guide
requires, with States.TaskFailed and the guide's wording for each rule.
A Task without the ClusterId its API acts on, a cancelStep without a
StepId and a ByName request without its name fail the same way.

AddJobFlowSteps on an unknown cluster, or on one in another Region, now
answers ValidationException "Specified job flow ID does not exist.", as
AWS does: a botocore ClientError (raster-foundry/raster-foundry#352) and
a CloudTrail record on AWS re:Post show it. It answered DescribeCluster's
InvalidRequestException. That re:Post record is an addStep.sync failing
on an unknown cluster with EMR.AmazonElasticMapReduceException, which
addStep now reports as well.

ModifyInstanceGroups and ModifyInstanceFleet on a terminated cluster,
which modifyInstanceGroupByName and modifyInstanceFleetByName reach, now
answer as AWS does too: ValidationException "An instance group may only
be modified when the cluster is running or waiting."
(hashicorp/terraform-provider-aws#1355 and hashicorp/terraform-provider-aws#9400)
and InvalidRequestException "A job flow that is shutting down,
terminated, or finished may not be modified." with ErrorCode
INVALID_JOB_SHUT_DOWN (hashicorp/terraform-provider-aws#31375). Both answered InvalidRequestException "Cluster <id> is
terminated.", which no AWS response shows, and EMR's error body now
carries an error's extra members such as ErrorCode.

TerminateJobFlows, the four Set* cluster setters and CancelSteps now
refuse a request without a member their model requires (JobFlowIds and
the setting, or StepIds) with AWS's framework ValidationException, as
RunJobFlow does for Name. They read a missing list as empty and a missing
setting as its default and answered success, which the
setClusterTerminationProtection and terminateCluster integrations reached
too. The "Member must not be null" violation is now one helper in
SmithyValidationErrors.

Part of #6046 (part 10).
2026-10-22 17:06:23 -05:00
Jimmy Liu Jia 0dab646373 fix(emr): reject steps after cluster termination (#6115)
* fix(emr): reject steps after cluster termination

* docs(emr): document terminated cluster step rejection
2026-10-21 00:07:18 -04:00
Jimmy Liu Jia a578bb0811 fix(emr): release instance capacity when clusters terminate (#6095)
* fix(emr): release instance capacity when clusters terminate

I mark instance groups and fleets TERMINATED and clear their active capacity on automatic and manual cluster termination. I preserve requested and target capacity and cover both paths through HTTP regressions.

* fix(emr): retain terminated instances and reject capacity changes
2026-10-20 16:59:10 -04:00
Jimmy Liu Jia 67e4bfec1c fix(emr): terminate transient clusters after steps (#6085)
* fix(emr): terminate transient clusters after steps

* fix(emr): I preserve terminal state on later requests
2026-10-20 13:21:02 -04:00
Jimmy Liu Jia ae53c4b352 fix(emr): preserve request-level step execution role (#6061)
* fix(emr): preserve request-level step execution role

* test(emr): keep integration test order unique

* fix(emr): align step roles with AWS response shapes
2026-10-20 08:15:09 -04:00
David 7dc514b52f feat(emr): ListReleaseLabels, DescribeReleaseLabel and ListSupportedInstanceTypes (#5748)
* feat(emr): ListReleaseLabels, DescribeReleaseLabel and ListSupportedInstanceTypes

None was served, so Terraform's aws_emr_release_labels and
aws_emr_supported_instance_types data sources failed against Floci.

A curated catalogue of EMR releases (emr-7.5.0, Floci's default, and
emr-7.4.0, emr-6.15.0, emr-6.14.0 and emr-5.36.2) carries each
release's applications and versions from the EMR Release Guide and its
recent Amazon Linux releases, with common instance types and their EC2
sizes. The three actions filter and page it as the API documents, and
answer InvalidRequestException for an unknown release, a bad token or
an out-of-range MaxResults. A configured default release outside the
catalogue is still listed.

Closes #5734

* fix(emr): report EMR architecture values and match application versions without regard to case

ListSupportedInstanceTypes returned the EC2 spellings x86_64 and arm64; the EMR model gives X86_64 and AARCH64 for Architecture. The ListReleaseLabels application filter matched the name without regard to case but not the version, so phoenix@4.14.3-hbase-1.4 missed emr-5.36.2.

* refactor(emr): page the release catalogue with the shared Pagination

ListReleaseLabels and ListSupportedInstanceTypes now page through
core.common.Pagination, with the filters in the token namespace so a token
replayed with other filters, or altered, is refused. DescribeReleaseLabel
answers every application, as AWS reserves its MaxResults and NextToken.
The EMR integration tests share one request helper.
2026-10-18 15:11:42 -04:00
David 82977a7f03 feat(emr): resize instance groups and fleets, list bootstrap actions (#4900) 2026-10-04 09:52:41 -04:00
David 044c700d68 feat(emr): scaling and termination policies and block public access (#4893)
Serve PutManagedScalingPolicy, GetManagedScalingPolicy,
RemoveManagedScalingPolicy, PutAutoTerminationPolicy,
GetAutoTerminationPolicy, RemoveAutoTerminationPolicy,
PutAutoScalingPolicy, RemoveAutoScalingPolicy,
GetBlockPublicAccessConfiguration and PutBlockPublicAccessConfiguration.

The managed scaling and auto termination policies are stored on the
cluster and the automatic scaling policy on its instance group, as the
JSON given. RunJobFlow and AddInstanceGroups accept the same policies
instead of dropping them, and ListInstanceGroups reports an attached
automatic scaling policy. Validation follows the API model: ComputeLimits
members and minimum not above maximum, IdleTimeout 60 to 604800 seconds,
automatic scaling only on core and task groups, port ranges within 0 to
65535. Block public access is kept per account and Region and starts at
the AWS default (public rules blocked, port 22 permitted).

The cluster mutators are synchronized, since each reads, changes and
stores the whole cluster.

Refs #4888
2026-10-02 10:37:45 -04:00
TiM 7d70f64162 feat(docs): generate Supported Actions tables from handler source (#1641)
* feat(docs): generate Supported Actions tables from handler source

The "Supported Actions" tables in docs/services/*.md were hand-maintained and
drifted from the handlers. For example secrets-manager.md omitted RestoreSecret,
which SecretsManagerJsonHandler dispatches, and acm.md listed RenewCertificate,
which is not implemented anywhere in src/.

Derive the action list from handler source so it cannot drift, while keeping the
hand-written Description column:

- tools/docs/regen_action_docs.py extracts actions from `case "X" ->` switch arms
  (including multi-label arms) and JAX-RS REST controllers, and rewrites only the
  rows between the <!-- floci:actions --> markers. Descriptions are preserved by
  action name; new actions get a "-" placeholder. PascalCase-only matching avoids
  picking up SCREAMING_CASE labels from non-action switches.
- tools/docs/services.yaml registers 18 single-table switch services and lists the
  remaining switch handlers under deferred_handlers, so the new-service sentinel
  fires only on a genuinely unregistered handler.
- make docs-sync / docs-check / docs-test, plus a Python-only CI workflow that
  gates on handler, doc, and tooling changes.
- Migrate 18 service docs into marker blocks, reconciling real drift (adds
  RestoreSecret, ImportCertificate, and others; drops the unimplemented
  RenewCertificate).

Revives the parser and CI gate from #738 by @ericbsantana and completes the
description-preservation its spec described. REST-mode, mixed-mode, multi-table,
non-tabular, S3, and ecr docs are deferred and tracked in deferred_handlers.

* docs: drop standalone design spec from action-docs tooling

Remove ideas/auto-generated-action-tables.spec.md and the four references
to it (CONTRIBUTING.md, Makefile, regen_action_docs.py docstring,
services.yaml). It was a planning artifact; the operational docs live in
CONTRIBUTING.md and the tooling is self-documenting. The #738 / @ericbsantana
credit is preserved in the PR description.

* chore: address review on action-docs tooling

- pin actions/checkout to v7.0.0 in docs-actions workflow to match the
  repo-wide bump (#1690), so dependabot does not immediately flag the new file
- document in the generator docstring that a switch case label counts as
  supported purely by existing, so a per-action UnsupportedOperation stub
  would be a false positive (handlers here reject from the default arm)

* docs: regenerate action tables against current handler source

Resync the generated Supported Actions tables to handler source after
rebasing onto the latest main:

- cloudformation: add DescribeStackInstance and DescribeStackSetOperation
  now emitted by the handler, and keep the implemented StackSet descriptions
- cloudtrail: add LookupEvents
- firehose: add UpdateDestination
- step-functions: add PublishStateMachineVersion, ListStateMachineVersions,
  DeleteStateMachineVersion
- register the cloudcontrol handler in deferred_handlers so the strict
  unregistered-handler gate passes (no standalone action table yet)

* fix(docs): prevent action-table generator from silently dropping actions

Address the latest review pass on the action-docs tooling:

- switch extraction now captures case arms whose labels wrap across lines
  (valid Java 14+ syntax). The capture group excludes only `{ } ;` boundaries,
  so it spans newlines between labels but stops at the arm's `->`. A wrapped
  arm was previously missed, and docs-check would stay green because the doc
  and the generated output agreed on the omission, defeating the whole
  drift-prevention guarantee.
- REST extraction skips Javadoc / inline comments between a verb annotation
  and the method signature; such a line otherwise reset the lookahead and
  dropped the action.
- parse_marker_block raises a descriptive error when a marker is not on its
  own line, instead of a bare "substring not found".
- doc, source, and registry reads/writes are pinned to UTF-8 so generation is
  locale-independent (the docs contain non-ASCII text).
- the docs-actions push trigger watches Makefile and the workflow file,
  matching its pull_request trigger.

Adds regression tests for the multi-line arm and comment-skip paths (20 total).
2026-07-06 21:02:04 -05:00
Hector Ventura 717769857b docs: correct service count to 58 and add EMR, WAF v2, CloudTrail pages (#1398)
Reconcile inconsistent service counts (55/54/41) to 58 distinct services across the README, docs index, services overview, and the LocalStack migration guide. Add the missing per-service pages and Service Matrix rows for EMR, WAF v2, and CloudTrail, and wire them into the mkdocs nav and README service tables.
2026-06-16 18:57:37 -05:00