mirror of
https://github.com/floci-io/floci.git
synced 2026-12-04 10:38:00 -05:00
ab7fc6f81f2ea04dc73ccff59ffeefdf6335d5cd
60
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5fa518cf10 |
feat(emr): keep a cluster's application history and open its persistent UIs for real in the docker runner mode (#8817)
With runner-mode docker, GetPersistentAppUIPresignedURL now opens the persistent application UI's interface for real, SHS the Spark History Server, YTS the YARN timeline server and TEZ the Tez UI, on a host of its own as an on-cluster UI does: while the cluster runs, its primary node's; once it has ended, as "You can access application history and relevant log files for active and terminated clusters", its kept history's, for the 30 days for which "The logs are available ... after the application ends". The primary node of a cluster that runs either history interface mounts a volume of its own, which holds the timeline server's store (its entities kept 30 days rather than Hadoop's 7), and into which, as the cluster's storage goes, or as a reset or a shutdown removes a node still running, its Spark applications' event logs are copied out of its HDFS; the cluster's other storage goes as before, though a copy that fails keeps it, the event logs in it, for a later try or a restart to remove. The URL is not PresignedURLReady while the cluster is ending or its storage is going. Then a container of the image the cluster ran serves it, on a network of its own that no step's container is on, started by the first link, the URL not PresignedURLReady until it answers, and stopped once no link to it is valid, a later link starting it again; with no ResourceManager there, the Tez UI's asks for one go to the timeline server. A kept history goes once its 30 days have passed, whether or not a link asked for it. A restart keeps the histories of the clusters that ended within 30 days, a reset or a shutdown removes the containers, and a reset every history. Elsewhere, the link still opens Floci's own page. EmrAppUiNightlyIntegrationTest runs it for real: a persistent UI opens the cluster's Spark History Server while it runs, and, once it has ended and its storage has gone, its kept history: the Spark application, the Hive query's Tez DAG and the Tez UI's page. |
||
|
|
3210ee0263 |
feat(emr): run the YARN timeline server and the Tez UI on a cluster's primary node in the docker runner mode (#8804)
With runner-mode docker, a cluster with Hadoop now runs the YARN
timeline server on its primary node, and one with Tez too the Tez UI
("Tez | http://master-public-dns-name:8080/tez-ui"), and
GetOnClusterAppUIPresignedURL opens both for real, on their own hosts,
as the cluster's other interfaces open (YarnTimelineService, TezUI).
The timeline server is Hadoop's own on its default port, 8188, its
store on the primary node's volume; the ResourceManager publishes its
applications to it, and, as no source gives how EMR's Tez reaches it, a
Hive step's Tez logs its DAGs to it through its REST interface
(ATSHistoryLoggingService). The Tez UI is Tez's own page, served on
8080, whose configuration (/etc/tez-ui/conf/configs.js, which the
image's page links to and lacks) names the timeline server and the
ResourceManager by the node's name, which Floci makes the link's hosts;
both answer cross-origin requests from the Tez UI's host. Both start
with the node's other daemons, the timeline server before the
ResourceManager, and the node is ready once both answer. The Tez UI runs
where the cluster's image has Tez, one with Hive or Floci's Pig, and an
image without its files serves none rather than keep the node from being
ready. Neither runs
for a release of the AWS runtime for Apache Spark, as their persistent
interfaces are not there.
EmrAppUiNightlyIntegrationTest runs them for real: after a Hive step,
the timeline server holds its Tez DAG and its application history, and
the Tez UI's page and configuration open, the timeline server answering
a request from the Tez UI's host.
|
||
|
|
0475f96d85 |
feat(emr): run a Spark History Server on a cluster's primary node in the docker runner mode (#8796)
With runner-mode docker, a cluster with Spark now runs a Spark History
Server on its primary node, as EMR's does ("Spark HistoryServer |
http://master-public-dns-name:18080/"), and GetOnClusterAppUIPresignedURL
opens it for real, on its own host, as the cluster's other interfaces
open.
Where the primary node runs the server, a step's Spark on the cluster's
YARN keeps its event logs where "By
default, Amazon EMR stores event logs in the /var/log/spark/apps
directory of HDFS" (spark.eventLog.dir hdfs:///var/log/spark/apps, which
the cluster's spark-defaults may replace), and names the server as
spark.yarn.historyServer.address, so an ended application's tracking URL
leads to its page there. The primary node makes that folder with the
others in its HDFS, starts the server once it is there, reading it and
listening where HDFS does, as one of the node's daemons, and is ready
once it answers. Its port is published on the host's loopback interface
as the other interfaces' are. With an ApplicationId, the server's link
lands on the application's page.
EmrAppUiNightlyIntegrationTest runs it for real: after a SparkPi step,
the ResourceManager's proxy sends the application's tracking URL on to
its page on the server's own host, the server lists it from its event
logs, and the server's own link lands on it.
|
||
|
|
4b342dad3f |
feat(emr): open a cluster's on-cluster application UIs for real in the docker runner mode (#8773)
With runner-mode docker, GetOnClusterAppUIPresignedURL now opens the interfaces that run on the cluster's primary node for real: its ResourceManager, an application master through the ResourceManager's web proxy, its MapReduce JobHistory server, and the NodeManager of a primary node that works. Each opens on a host of its own, as AWS's application UIs do under emrappui-prod.<region>.amazonaws.com, which are on the Public Suffix List: http://<secret>-<port>.emrappui.<Floci's host and port>/, the secret 26 random base32 characters only the link holds, so the host is the link's authority, as the interface takes no AWS credentials. EmrAppUiProxy, a Vert.x route ahead of the REST layer, sends a request to that host on to the node's port, which the primary node publishes on the host's loopback interface (Floci in a container joins the cluster's network instead). It asks the interface under the browser's host, so the links the interface writes itself are the browser's, and makes each link the node's daemons write to one another by the node's name a link to that interface's own host under the same secret, in text answers and Location headers; an answer too large to hold goes on unchanged. A request's body streams on as it arrives, an interface that sends nothing for a minute has the request given up, and a link of a cluster that has ended opens nothing, the node's port it found asked for again every ten seconds while the cluster runs. A link asked for before the primary node runs, as on a cluster no step has run on yet, starts the node as a step would, through runOnCluster, running nothing, and is not PresignedURLReady until the node is; its host answers 503 meanwhile. With an ApplicationId each interface lands on the application's page. The link lasts an hour, as Floci's page links do. An interface Floci does not run (the Spark History Server, the YARN timeline server, the Tez UI), and any link in the immediate mode, still opens Floci's own page. Floci's TLS certificate names *.emrappui.localhost and *.emrappui.localhost.floci.io. Lambda's CreateFunction and UpdateFunctionCode now refuse a direct ZipFile upload over 50 MB from its Base64 length, before decoding it, so a request already over the limit takes no more memory than it came in; its RequestEntityTooLargeException is as before, and the test of it builds its oversized upload without the bytes behind it. EmrAppUiNightlyIntegrationTest runs it for real on an emr-7.5.0 cluster: the ResourceManager's link starts the primary node and opens the ResourceManager, and after a MapReduce step its REST answer's links open the application master's logs on the NodeManager's host and, through the web proxy's redirect, the job on the JobHistory server's host, as the JobHistory server's own link does. The nightly job's timeout and image prefetch take the new check. |
||
|
|
9821a919b6 |
feat(emr): run a notebook execution's notebook on its cluster in the docker runner mode (#8764)
With runner-mode docker, StartNotebookExecution now runs the notebook on its cluster as a step's command runs: a spark-submit there, a YARN application with the cluster's Spark settings, as the execution's ExecutionRoleArn, else the cluster's instance profile, with its EnvironmentVariables (KERNEL_EXTRA_SPARK_OPTS, as AWS's example passes, going to spark-submit as its options). No source names AWS's kernel, so a program of Floci's own runs it, needing only Python and PySpark, which every release's image has, not Jupyter: it reads the notebook through the cluster's S3A, puts NotebookParams in papermill's way (a cell tagged injected-parameters after the one tagged parameters, else first, in place of any an earlier run left; a name that is not a Python variable's fails the run), clears every earlier output, runs the code cells in one namespace holding spark and sc, keeping each one's output, its last expression's value and any error, stops at the first cell that raises, and writes the notebook as run as <name>.ipynb and <name>.html, then exits 3. A %%sql cell runs its body with spark.sql, a %%local or %%spark one as Python, and other cell magics are not run; % and ! lines are dropped only from a cell that is not Python as it stands. The notebook is the execution's NotebookS3Location; Floci keeps no EMR Notebook's own S3 location, so an execution named by EditorId alone fails at once. No source gives where AWS writes the notebook as run, so Floci writes it under the OutputNotebookS3Location prefix, else beside the notebook, in a folder named for the execution, and reports the one OutputNotebookFormat names, the HTML one, else the notebook, as OutputNotebookURI. The execution is START_PENDING until its container runs, then RUNNING, and FINISHED, FAILED at the first raising cell (any other failure giving the run's exit code), or STOPPED, StopNotebookExecution going through STOPPING; its cluster's end stops it, and one a restart left behind fails as interrupted. EmrService.runOnCluster runs such a command on a cluster through the cluster preparation steps and sessions share, its cluster's storage held while it runs and its end stopping it. As a step's, its thread starts nothing once its cluster has shut down or a reset's or a shutdown's teardown has begun; one that cannot be handed to its thread ends at once. EmrNotebookExecutionNightlyIntegrationTest runs it for real on an emr-7.5.0 cluster: a parameterized notebook's run, an earlier run's parameters in it, written to S3 with its outputs, its %%sql cell's among them, and HTML; a failing notebook's FAILED with its error kept and an earlier run's later outputs gone; and a misnamed parameter's run failed with its exit code. The nightly job's timeout and image prefetch take the new check. |
||
|
|
2517edb471 |
feat(emr): run a session's Spark Connect server on its cluster in the docker runner mode (#8751)
With runner-mode docker, StartSession now runs the session's Spark Connect server on its cluster, as "Amazon EMR launches a Spark Connect Server as a YARN application on your cluster": a container on the cluster as a step's is, in the image its steps run in, its HDFS and YARN started first where they are not running, the server's driver in that container and its executors on the cluster's YARN. Its spark-defaults are the cluster's, then the session's EngineConfigurations, with the server's port; it runs as the session's ExecutionRoleArn, else the cluster's instance profile. A client reaches it through Floci as an EMR Serverless session's server is reached (#8731): GetSessionEndpoint answers Floci's address and a token, and a client connects with sc://<host>:<port>/;x-aws-proxy-auth=<token>;authorization=<session id>, AWS's string with Floci's port. The proxy drops the authorization parameter, which AWS's own proxy reads, before the call reaches the server. The session is SUBMITTED until its container runs, STARTING until the server answers, then IDLE, BUSY while a call runs on its server and IDLE again once none does. TerminateSession goes through TERMINATING until the server has stopped; the idle timeout stops it too, and the cluster's end ends its sessions and stops their servers on its own, its storage released only once the last of them has gone. A server that exits on its own, or does not answer within 10 minutes, fails the session; one a restart left behind fails as interrupted, its container removed. What EMR Serverless's sessions and these share moves into emrserverless.SparkConnectServers: running each server, asking it whether it answers, the tokens, the calls a session takes, and one check for its next deadline; and SparkConnectSessionOwner, the states a session goes through as its server starts, answers, takes calls and stops, each service giving only how it stores, ends and checks its sessions (both models implement SparkConnectSession). A server being stopped takes no new call, a call's busy and idle reach the owner in order under the server's own lock, and a server's entry goes even where its owner fails to hear it stopped. A step's setup on its cluster (its image, storage, metadata address, added nodes and HDFS) moves into a preparation that steps and sessions' servers share. EmrSessionServerNightlyIntegrationTest runs it for real on an emr-spark-8.1.0 cluster with Spark 4's JVM client from that image: a wrong token refused, queries run, a missing table's Spark error back, TerminateSession removing the server. The nightly job's timeout and image prefetch take the new check. |
||
|
|
6618ae3de6 |
fix(emr): scope Studio list markers to their account, Region and filters (#8740)
ListStudios used one constant namespace for its markers, and ListStudioSessionMappings its Studio and identity type joined with String.valueOf. A marker from another account or Region therefore resumed this one's listing at its cursor, and an absent filter could not be told apart from the text "null". Both now scope their markers as ListNotebookExecutions does (#8705): a JSON list of the operation, the account, the Region and each filter, so any other marker is refused with InvalidRequestException "Invalid Marker.". The JSON list moves from EmrNotebookExecutionService to EmrService.listingNamespace, which all three listings use. |
||
|
|
e078bb7b00 |
feat(emr): answer GetClusterSessionCredentials for runtime role clusters (#8714)
GetClusterSessionCredentials, "temporary, HTTP basic credentials that are associated with a given runtime IAM role and used by a cluster with fine-grained access control activated", was not served. Floci now answers it with a random username and password that expire in an hour, for a RUNNING or WAITING cluster on emr-6.11.0 or later whose security configuration turns on runtime roles (EnableApplicationScopedIAMRole); any other cluster is refused. Floci runs no endpoint that checks them, and keeps none. A request without an ExecutionRoleArn is refused, as the credentials are "associated with a given runtime IAM role". Whether a cluster is a runtime role enabled one is now recorded as it is created, so a security configuration deleted or reused later changes nothing; CreatePersistentAppUI's RuntimeRoleEnabledCluster reads the same. |
||
|
|
751c97dde6 |
feat(emr): keep persistent application UIs and answer their presigned URLs (#8711)
EMR's application UI operations, CreatePersistentAppUI, DescribePersistentAppUI, GetPersistentAppUIPresignedURL and GetOnClusterAppUIPresignedURL, were not served. Floci now keeps a cluster's persistent application UIs, with the types its release and applications give it (the Spark History Server from 5.25.0, the Tez UI and YARN timeline server from 5.30.1), refusing a cluster with more than one primary node and an account past 200, and reports whether the cluster's security configuration turns on runtime roles. It serves none of those UIs: a presigned URL, persistent or on-cluster, opens a signed one-hour page of Floci's about the cluster and the interface asked for. The link signing of EMR Serverless's dashboards and these pages is one helper, core.common.LinkSigner, and their HTML page and table rows come from core.common.Html. |
||
|
|
e0ef191767 |
feat(emr): keep notebook executions on a cluster (#8705)
EMR's notebook execution operations, StartNotebookExecution, DescribeNotebookExecution, StopNotebookExecution and ListNotebookExecutions, were not served. Floci now keeps notebook executions and their lifecycle, without running a notebook. An execution needs a RUNNING or WAITING cluster that meets the EMR Notebooks cluster requirements (release 5.18.0 or later, with Hadoop, Spark and Livy, and Jupyter Enterprise Gateway from 5.32.0 or 6.2.0), and an account runs at most 100 at once in a Region. It is RUNNING from its start and FINISHED once the cluster's step duration has passed, with AWS's "Execution is finished for cluster ..."; it stops at once as STOPPED, and FAILS when its cluster shuts down first or after 30 days. ListNotebookExecutions gives the newest first, within its From and To window (by default the last 30 days), 50 to a page. Executions are stored apart from their clusters, and IAM's resource-tag conditions read their tags. EMR's release comparison, its enum check, the time a cluster began to shut down, and reading an ARN's id and a resource's tags for IAM are now shared helpers, which CancelSteps, sessions, Studios and clusters use too. |
||
|
|
bd6c5810c3 |
feat(emr): keep EMR Studios and their session mappings (#8701)
EMR's Studio operations, CreateStudio, DescribeStudio, ListStudios, UpdateStudio and DeleteStudio, and its Studio session mappings, Create, Get, List, Update and DeleteStudioSessionMapping, were not served. Floci now keeps Studios, checked against its own EC2 and IAM Identity Center: a Studio's VPC, at most 5 subnets and its two security groups must exist, the subnets and groups in the VPC; an SSO Studio needs a UserRole and an IAM one may not have one, and the IdP members are for IAM Studios only; an SSO Studio needs the account's IAM Identity Center instance, or the one it names. UpdateStudio keeps every earlier subnet. A session mapping is for an SSO Studio, names its user or group by id or by name but not both, and that identity must be in the instance's identity store, and is found again by the id or name it was made with. Studios and mappings list in the order they were made, by a sequence no deletion frees. AddTags and RemoveTags take a Studio's id, and IAM's resource-tag conditions read a Studio's tags. Floci serves no Studio: its URL is on Floci's own address. Identity Store gains typed lookups of a user by name and a group by id or display name, and EMR's random id helper is shared. |
||
|
|
bb57e63b8e |
feat(emr): keep Spark Connect sessions on a cluster (#8699)
EMR's session operations, StartSession, GetSession, ListSessions, TerminateSession and GetSessionEndpoint, were not served, and RunJobFlow dropped SessionEnabled. Floci now keeps a cluster's sessions and their lifecycle, without starting a Spark Connect server for them. RunJobFlow keeps SessionEnabled and DescribeCluster reports it. StartSession needs a cluster with sessions enabled, on emr-spark-8.0.0 or later, with Spark, RUNNING or WAITING, with one primary node and fewer than 1000 sessions that have not ended, as the Management Guide's "Interactive sessions" gives them; a request needs a Name and an idle timeout within 24 hours. It answers SUBMITTED, and the session is IDLE from then on until its idle timeout (60 minutes by default), TerminateSession, or its cluster shutting down ends it. A retry with the same client request token that asks for the same session answers as the first call did. Sessions are kept apart from their clusters, so ended ones weigh on no cluster read or write. GetSessionEndpoint gives an endpoint on Floci's address and a token valid for an hour. ListSessions gives the newest first, by state, a page at a time. A request member of the wrong JSON type is refused with SerializationException. The cluster's installed applications are read by one helper, which the Hive and Pig checks now share with the Spark one. GetSessionEndpoint's endpoint and token come from core.common.SparkConnectEndpoint, which EMR Serverless's GetSessionEndpoint now uses too. |
||
|
|
6e30baf46c |
feat(emr): run a MapReduce JobHistory server on a cluster's primary node (#8662)
EMR's primary node runs one (a release's mapred-site classification "Restarts Hadoop MapReduce-HistoryServer"); Floci's did not, so a client asking about a MapReduce job whose application master had ended, for its counters or task reports, waited about 30 seconds a call on 0.0.0.0:10020 and got nothing. Pig asks after each of its MapReduce jobs, so #8636 turned its task reports off and gave its client one try. A cluster that runs YARN now starts `mapred historyserver` beside the ResourceManager, on Hadoop's own ports and where HDFS listens, from the jobs' history in the cluster's HDFS, and its primary node is ready once the server answers. A step's MapReduce settings name it, and so do a Hive step's, for a query run on MapReduce; an emr-spark-* node runs it from the Hadoop it keeps apart. The node scripts' readiness waits share one helper. Pig's workaround goes: its MapReduce jobs' counters come from the server, as on EMR. |
||
|
|
30f8a9985e |
feat(emr): run Pig steps on Apache Pig, an opt-in download added to the cluster's image (#8636)
No AWS image carries Pig, so a Pig step failed without running. With floci.services.emr.pig.enabled on (off by default), a docker cluster whose Applications name Pig gets Apache Pig 0.18.0 in its image: downloaded to a temporary file from the first of floci.services.emr.pig.urls that gives it whole with the checksum floci.services.emr.pig.sha256 names (a URL that fails, stalls for a minute or gives another checksum passes to the next), then streamed into /usr/lib/pig as EmrReleaseImages makes the image, with Tez from the release's Hive image and a /usr/bin/pig that EMR's own pig-script runs. Pig runs on the image's Tez, its bundled Tez and protobuf 3 left out, on the cluster's YARN or in local mode, with exectype=tez, a working directory without a scheme, which S3A takes, and no task reports and one try for counters from the MapReduce JobHistory server the cluster does not run, then the cluster's tez-site and pig-properties, in a pig.properties of the step's own; pig-log4j and pig-env reach Pig too. A command step's new tez-site.xml shares Hive's Tez-on-YARN settings. Without the setting, a Pig step on a cluster that installs Pig still fails without running, its message naming the setting; on one that does not, EMR's pig-script says "Pig isn't installed." as on EMR. |
||
|
|
f15c14979e |
fix(emr): give a cluster's instance groups and fleets its states (#8526)
A cluster's instance groups and fleets reported RUNNING, with all their capacity, from its creation until it was TERMINATED, whatever state the cluster itself was in. InstanceGroupState and InstanceFleetState have PROVISIONING, BOOTSTRAPPING and TERMINATING too, and the Management Guide's events end an instance fleet's provisioning with "Provisioning for instance fleet ... is complete ... The instance fleet now has On-Demand capacity of Num". No source says when each applies, so they now follow the cluster's state, Floci's reading: PROVISIONING while it is STARTING, with nothing running or provisioned yet, BOOTSTRAPPING with every instance up for its bootstrap actions, RUNNING while it runs or waits, and TERMINATING as it ends, the instances still running. One added later takes the state its cluster's others are in. ListInstances gives each instance its group's or fleet's state, lists those being provisioned, and filters by InstanceStates per instance. A cluster terminated while it is STARTING keeps listing the instances it was provisioning, still PROVISIONING and none of them running, until it is TERMINATED, so the same instances are listed throughout. |
||
|
|
73f2c348b6 |
fix(emr): check the step limits the API reference and the guide give (#8519)
EMR's documentation sets four limits on steps that Floci did not check: StepConcurrencyLevel "a minimum of 1 step and a maximum of 256 steps" (ModifyCluster; "The maximum value is 256" for RunJobFlow); "only 256 steps can be RUNNING or PENDING at any given time"; an ActionOnFailure other than CONTINUE added while the level is above 1, where "The step is not submitted and the action fails with a message that the ActionOnFailure setting is not valid"; and CancelSteps, "Available only in Amazon EMR versions 4.8.0 and later, excluding version 5.0.0", with "A maximum of 256 steps ... in each CancelSteps request". Each is now refused in the error code its operation's model points at: ValidationException from RunJobFlow and AddJobFlowSteps, which declare no InvalidRequestException, as Floci's other refusals of theirs, and InvalidRequestException from ModifyCluster and CancelSteps. No source gives AWS's messages, so they are Floci's. |
||
|
|
ec9c19ff62 |
feat(emr): run a cluster's bootstrap actions on its core and task nodes (#8502)
Bootstrap actions "run on cluster after Amazon EMR launches the instance", on every node, and "If you add nodes to a running cluster, bootstrap actions also run on those nodes in the same way". Floci ran them once, as on the primary node, and every node ran from the image they left, so an action's branch for the core or task nodes never ran. Where a cluster's core and task nodes run in containers of their own, each now runs the actions too, in a bootstrap container of its own beside the primary node's, as that node: its node files say CORE or TASK, the cluster's relay answers its instance metadata as that node, its output goes under its own instance id, and the container is kept as the image the node runs from, so it holds what its own actions installed. A node a resize adds runs them before it starts, and one that leaves takes its image with it, so one added again runs them again. AWS terminates a node whose action fails and says only that "If too many instances fail their bootstrap actions, then Amazon EMR terminates the cluster. If just a few instances fail, Amazon EMR attempts to reallocate the failed instances and continue". Floci runs a node's actions again once, in a fresh container, and a second failure ends the cluster with BOOTSTRAP_FAILURE and a message of Floci's after the primary node's, as no source gives AWS's words or an error code for a core or task node. |
||
|
|
f71476037a |
feat(emr): write the node files AWS documents on a cluster's nodes (#8473)
An EMR node keeps files about itself that bootstrap actions read to tell which node they run on. AWS documents two fields of them: the EMR Management Guide's bootstrap action reads isMaster from /mnt/var/lib/info/instance.json, and AWS's Knowledge Center reads instanceRole from /mnt/var/lib/instance-controller/extraInstanceData.json with jq, comparing it, lowercased, with master, core and task. Floci now writes those two fields, and nothing else: isMaster true and instanceRole MASTER in the bootstrap actions' container and each step's, which run as on the primary node, and in the primary node's own, and false with CORE or TASK in each core or task node's, the roles as the API's InstanceRoleType names them. They are written as the image's hadoop user, whose /mnt is, so Hive's metastore can still write under /mnt/var/lib, and moved into place whole, as steps share /mnt. The bootstrap container's copies go before it is kept as the cluster's image. Files that cannot be written fail the bootstrap, the step or the node. |
||
|
|
c1a8a3b3ac |
feat(emr): serve a cluster's nodes their instance metadata (#8449)
Every node of an EMR cluster is an EC2 instance, so any process on it, a bootstrap action, a step or a Spark executor, reads its instance metadata at 169.254.169.254. In the docker runner mode nothing answered there: a bootstrap script reading its availability zone got nothing. A relay container on the cluster's own Docker network now holds that address as a link-local one, as ECS's credentials endpoint is held, and each of the cluster's containers gets a link-local address of its own there, so none needs privileges. The relay forwards to Floci's EC2 metadata server, naming its caller in X-Forwarded-For, which the server reads only from the relays it trusts; the server answers each container as the instance it is: the bootstrap actions and each step as the primary node, each core or task node's container as that node, with the instance id, type, private address and name ListInstances gives, the cluster's availability zone and its JobFlowRole instance profile. The metadata server now starts for the docker runner mode too. DescribeCluster's Ec2InstanceAttributes now gives Ec2AvailabilityZone, the one RunJobFlow's Instances.Placement names, else the Region's first, so the metadata and the cluster agree. |
||
|
|
0ae7f8bf89 |
fix(emr): put a cluster's nodes on the network Floci's containers share (#8429)
A cluster's primary, core and task nodes ran on the cluster's own Docker network alone, so a cluster-mode Spark driver or an executor on them could not reach an MSK cluster's brokers, an RDS instance or any other container Floci starts: reading a topic timed out waiting for a node assignment. The nodes did not use Floci's DNS either, so Iceberg's S3FileIO, which addresses buckets as virtual hosts, failed on UnknownHostException for <bucket>.<host>. Each node now joins the network its cluster's steps run on, the one those containers are on, before it starts, with Floci's DNS, as a cluster's nodes reach what is in their VPC; executors reach Floci's S3 as the steps do. A node an earlier Floci left on the cluster's network alone starts again on its data. Where the steps share a namespace or have no network of Floci's, nothing changes. A node's HDFS and YARN listen on its address on the cluster's own network alone, found in that network's subnet as the node starts, so another cluster's step on the shared network reaches neither, nor submits work to the nodes. Hive 3's metastore has no setting for the address it listens on, so the primary node of a cluster with Hive or HCatalog, which runs it, stays on the cluster's network alone, and so does every node where Docker does not say that network's subnet. ContainerBuilder.withJoinedNetwork names a further network a container joins between its creation and its start, and ContainerLifecycleManager connects it there, removing the container when it cannot. |
||
|
|
8ba3f00443 |
fix(emr): give back a cluster's security configuration and refuse an unknown one (#8422)
RunJobFlow kept the SecurityConfiguration it was given, but DescribeCluster never wrote it out, so the cluster came back with none, although the model's Cluster has the member. It is given back now. RunJobFlow also took a security configuration that was never created. A cluster names one CreateSecurityConfiguration made, so one that does not exist is now refused with ValidationException "Security configuration does not exist: <name>". No source gives AWS's answer, so the code is the one RunJobFlow refuses its other input with in Floci, and the wording that of DescribeSecurityConfiguration and DeleteSecurityConfiguration; emr.md says so. |
||
|
|
6971626d82 |
fix(emr): give a step's command the sudo bootstrap actions have (#8415)
A step's script that ran sudo -u hadoop spark-submit ..., as a step does on EMR, failed with exit code 127, as the image steps run in has no sudo. The Release Guide's "Using HBase snapshots" runs a command-runner.jar step of sudo -u hbase, and the Management Guide's Kerberos users page a script-runner.jar script running sudo kadmin.local. Only bootstrap actions had Floci's sudo, which went before the image was kept. Each step on a cluster now finds that same sudo first on its PATH, written next to the hdfs and hadoop-streaming stand-ins the cluster's Hadoop setup already writes there, and a Hive step's shell commands find it too, written while its container is still root. It drops its options, a long one's value given apart included, and runs the command as the step's own hadoop user, so sudo -u hadoop runs as on EMR, while a command that needs root fails as it would for hadoop. The script moves to EmrServerlessSparkRunner, where the setup is, and the bootstrap actions write it from there. |
||
|
|
be6488b7ea |
fix(emr): remove the release images a newer pull replaces (#8395)
A cluster's release image is named after the ids of the two images it is made of, so a newer pull of either makes another, and the older one stayed on the Docker daemon for good. Each release image is now labelled with its kind: its release, the names of the two images and what is copied. Once Floci makes a newer image of a kind, it removes the others of that kind, without force, so one a container still uses stays until the next newer one. Another kind (with or without Hive, or other image names) is never touched, and an image made before the label is left as it is. Images of one kind are made one at a time, the two names resolved to ids under that kind's lock, so one made of the older images never comes after the newer one to remove it. A step or a bootstrap holds the image it was given until it ends, as it may have no container of it yet, and a held image is not removed either. A failure to remove one is logged with its exception; the new image is there, so it fails nothing. |
||
|
|
c99d8ee5ea |
fix(emr): list each instance fleet's InstanceTypeSpecifications (#8354)
ListInstanceFleets wrote no InstanceTypeSpecifications: the fleet kept only the names of the instance types it was created with. The Terraform AWS provider reads instance_type_configs back from that member, a ForceNew set in both aws_emr_cluster and aws_emr_instance_fleet, so a fleet cluster read back empty after apply and every later plan replaced it. A fleet keeps the InstanceTypeConfigs it was given, from RunJobFlow and AddInstanceFleet, and ListInstanceFleets returns each as the InstanceTypeSpecification it describes: its type, bid price, custom AMI, priority and configurations as given, a WeightedCapacity of 1 where it sets none and a BidPriceAsPercentageOfOnDemandPrice of 100 where it sets neither bid price, the defaults the API reference gives for both, and its EbsConfiguration as one EbsBlockDevice per volume. The reference names no devices, so they are /dev/sdb, /dev/sdc and on. A fleet stored before this has its instance types alone, with the same defaults. |
||
|
|
7981cadc7c |
fix(emr): keep a cancelled running step's place until its driver is gone (#8351)
CancelSteps on a RUNNING step stopped its driver and started the next
PENDING step at once, but stopping a driver only asks for it: with a
step concurrency level of 1 the next step's driver could start beside
the cancelled one's. The Management Guide's "Cancel steps": "Canceling
a running step does not allow a pending step to start running, assuming
no change to stepConcurrencyLevel", and CancelSteps "is idempotent but
asynchronous".
In the docker runner mode a cancelled RUNNING step is now CANCEL_PENDING
while its driver stops, with the guide's step event for that state ("was
cancelled at Time and is pending cancellation", WARN), and keeps its
place among the running steps. Once its driver is gone, however it
ended, the step is CANCELLED, takes no ActionOnFailure, and the next
PENDING step starts. A second cancel answers SUBMITTED. A driver Floci's
own teardown stops leaves the step CANCEL_PENDING, as it leaves a
RUNNING one, and a restart cancels it, in either runner mode;
TerminateJobFlows cancels it at once. Until it is gone it also counts as
running for a failed step's CANCEL_AND_WAIT. In the immediate mode
nothing runs, so a cancelled step is still CANCELLED at once.
|
||
|
|
16ff5a2c74 |
feat(emr): give a cluster a bootstrap failure ended its ErrorDetails (#8267)
A cluster whose bootstrap action failed in the docker runner mode ended with BOOTSTRAP_FAILURE and AWS's message, but DescribeCluster and ListClusters gave no Status.ErrorDetails, which the Management Guide's error code pages point to for the failed action, its return code and its script. - An action that exits with another code than 0 gives BOOTSTRAP_FAILURE_PRIMARY_WITH_NON_ZERO_CODE, with the ErrorData keys its page lists: primary-instance-id, bootstrap-action, return-code, amazon-s3-path and public-doc. A script that cannot be read gives BOOTSTRAP_FAILURE_BA_DOWNLOAD_FAILED_PRIMARY, with the same keys but return-code. ErrorData is a list of maps and no source shows how AWS spreads the keys over them: Floci gives one map holding them all. ErrorMessage is the reason's message and the error code's page, in Floci's words. - A bootstrap that cannot run at all, or that Floci stopped, ends with INTERNAL_ERROR as before and has no ErrorDetails: no documented code fits. - The details are stored with the cluster, so they survive a restart with persistent storage, and emr.md says what Floci gives. |
||
|
|
f5fd41a6ac |
fix(emr): list an instance fleet's instances (#8183)
ListInstances listed only instance groups' instances, so a cluster made of instance fleets listed none, though its core and task nodes run as containers named by the private DNS names its instances would have. - A fleet has an instance for each unit of its capacity, as its nodes do, its on-demand ones first, each of the first instance type in its InstanceTypeConfigs, which Floci now keeps, and with its InstanceFleetId. - The primary fleet's instance is numbered first, i-00000000000000001 at 10.0.0.1, as MasterPublicDnsName names it, and every other fleet's are at 10.<fleet>.0.<n>, the names its nodes run under, kept while another fleet resizes. One helper numbers groups and fleets for both. - An ended fleet's instances stay listed as TERMINATED for 30 days, as an ended group's do, from its target capacities, which it can no longer change. - InstanceGroupId, InstanceGroupTypes, InstanceFleetId and InstanceFleetType now narrow the listing, all given ones together; they were ignored. A call lists at most 2,000 instances, building only that page, with a Marker for the rest, so a fleet of any capacity costs one page, counted in longs, as a fleet's two capacities add up past an int. A cluster has instance groups or instance fleets, never both, as they "cannot coexist in a cluster": RunJobFlow with both, AddInstanceGroups on a cluster with fleets and AddInstanceFleet on one with groups are refused, and so is a fleet without its required InstanceFleetType or an InstanceTypeConfigs member without its required InstanceType. |
||
|
|
54ea160aa6 |
feat(emr): run a step's MapReduce and Hive's Tez on the cluster's YARN (#8151)
Where a docker cluster runs YARN its Spark ran on it, while MapReduce and
Hive's Tez stayed in local mode, in the step's container, and a job's own
-D mapreduce.framework.name=yarn failed.
- A step's mapred-site names YARN and the layout of the cluster's nodes,
which yarn.application.classpath's default does not, S3A's AWS SDK, and
the step's AWS environment for the application master and tasks, sized
for a NodeManager; the cluster's mapred-site replaces them.
- A step's hadoop, hadoop-streaming and hdfs dfs run from the nodes'
Hadoop, /usr/lib or an emr-spark-* release's /opt, set for that command
alone, so a spark-submit in the same step keeps the release's own.
- The images hold EMR Serverless's build of Tez, whose tez-site.xml names
its own plugins. On YARN a Hive step names the stock classes from the
same jars, real ports and bind addresses, ${env.NM_HOST} left for the
application master's node to fill in, Tez's jars from the node's own
disk, and one virtual core a task, as YARN's default scheduler grants
one and Tez gives back a container that does not match what it asked.
Intermediate compression is off, as the image's codec needs a native
library it lacks.
Where a cluster runs no YARN, MapReduce and Tez stay in local mode.
Two Docker cases check that a streaming job's tasks and a Hive query's
Tez tasks run in YARN's containers on the cluster's nodes. With them the
two EMR Docker classes take 651s and 402s on CI's runners, so the shard
partitioner weighs them at that, as at 280s and 260s their shard ran into
Surefire's 25 minutes.
With that split, PipesStreamEnrichmentDockerIntegrationTest ran in a JVM
where no class before it had told RestAssured how to send and read
DynamoDB's application/x-amz-json-1.0, which it relied on; it now does so
itself, as other tests do.
|
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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.
|
||
|
|
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. |
||
|
|
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.
|
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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). |
||
|
|
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). |