mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 23:00:59 -05:00
A Task can now use the six optimized EMR Serverless integrations the
Step Functions guide lists: createApplication, startApplication,
stopApplication, deleteApplication, startJobRun and cancelJobRun, each
request-response and .sync. Each calls Floci's EMR Serverless in the
state machine's Region. They failed with "Unsupported resource" before.
A Task names the API's members in PascalCase where the API writes them
in camelCase, so a request and a response are mapped against botocore's
EMR Serverless model, now vendored as aws/emr-serverless-shapes.json by
tools/aws/regen_emr_serverless_shapes.py: a structure's members are
renamed, a map keeps the keys the state machine wrote (tags,
InitialCapacity's DRIVER, a configuration's Properties such as
spark.executor.memory), and a member the model does not have is
dropped. A member, ApplicationId and JobRunId included, may be written
in either case. One the model has and Floci's request class lacks is
refused rather than dropped, and a test holds the classes to the model.
request_shapes.py can now keep output shapes for it. A request
without ClientToken gets a random one, as the SDK fills an idempotency
token in; the guide's examples leave it out.
The result is the API's response in PascalCase, or {"ApplicationId"}
where the API answers nothing, as the guide's table says. The guide
finds no difference between a .sync response and the API's, so a .sync
result is the starting call's own: state machines read a
createApplication.sync result's ApplicationId and a startJobRun.sync
result's JobRunId. A .sync Task records TaskSubmitted and polls
GetApplication or GetJobRun until the state the guide names, as the
elasticmapreduce ones do; a run that ends FAILED or CANCELLED, or an
application that can no longer get there, fails the Task with
States.TaskFailed and the describe response as the cause. A wait that
ends early cancels the run of a startJobRun.sync, stops the application
of a startApplication.sync and deletes the one a createApplication.sync
made, the call each integration's IAM policy grants beyond its own and
its read. EMR Serverless answering that the application or run is gone
or past undoing is logged and leaves the Task ending as it was; any
other failure is raised.
An EMR Serverless error keeps its code under EmrServerless., the
exception prefix the guide gives the service; no record shows the
optimized integration's. A Task without the ApplicationId, or a
cancelJobRun without the JobRunId, it acts on fails with
States.TaskFailed before EMR Serverless sees it.
CreateApplication now stores the configurations UpdateApplication
already did (runtime, monitoring, scheduler, disk encryption,
interactive, Identity Center and job-level cost allocation), and
ImageConfiguration keeps applicationLevelDigestResolution. Both were
dropped, from a Task and from the API alike. A runtime configuration
kept only its properties, lifted out of their member: Jackson bound the
properties member to the field of that name holding every member read.
It keeps its classification and properties now, on update as well.
GetApplication no longer returns the application's clientToken, which
its Application has no member for and which the .sync waits read. The
token stays with the stored application, which CreateApplication's
retries are matched on.
The .sync wait loop the elasticmapreduce integrations had is now shared
by both, as are their request and failure helpers, and the two EMR
Step Functions tests share their state machine helpers.
Part of #6046 (part 11).
104 lines
7.6 KiB
Markdown
104 lines
7.6 KiB
Markdown
# EMR Serverless
|
|
|
|
EMR Serverless is an AWS service that provides serverless data analytics environments. Floci provides an emulator for the management-plane API (REST JSON) which covers the lifecycle of an Application and of the job runs submitted to it.
|
|
|
|
## Configuration
|
|
|
|
| Key | Description | Default |
|
|
|-----|-------------|---------|
|
|
| `floci.emrserverless.enabled` | Whether the EMR Serverless API is enabled | `true` |
|
|
| `floci.emrserverless.port` | The port the service is exposed on | `4566` |
|
|
| `floci.services.emrserverless.job-run-duration-seconds` | How long a `BATCH` job run stays `RUNNING` before it succeeds; `0` makes it `SUCCESS` as soon as it starts | `0` |
|
|
|
|
## Endpoints
|
|
|
|
The emulator implements the standard AWS `emr-serverless` service endpoints:
|
|
|
|
* `POST /applications` (CreateApplication)
|
|
* `GET /applications` (ListApplications)
|
|
* `GET /applications/{applicationId}` (GetApplication)
|
|
* `PATCH /applications/{applicationId}` (UpdateApplication)
|
|
* `DELETE /applications/{applicationId}` (DeleteApplication)
|
|
* `POST /applications/{applicationId}/start` (StartApplication)
|
|
* `POST /applications/{applicationId}/stop` (StopApplication)
|
|
* `POST /applications/{applicationId}/jobruns` (StartJobRun)
|
|
* `GET /applications/{applicationId}/jobruns` (ListJobRuns)
|
|
* `GET /applications/{applicationId}/jobruns/{jobRunId}` (GetJobRun)
|
|
* `DELETE /applications/{applicationId}/jobruns/{jobRunId}` (CancelJobRun)
|
|
* `GET /applications/{applicationId}/jobruns/{jobRunId}/attempts` (ListJobRunAttempts)
|
|
* `POST /tags/{resourceArn}` (TagResource)
|
|
* `DELETE /tags/{resourceArn}?tagKeys=...` (UntagResource)
|
|
* `GET /tags/{resourceArn}` (ListTagsForResource)
|
|
|
|
The tagging operations work on application and job run ARNs, as `CreateApplication` and `StartJobRun`
|
|
return them (`arn:aws:emr-serverless:<region>:<account>:/applications/<id>` and
|
|
`.../applications/<id>/jobruns/<id>`). They share the tags those calls store, so `GetApplication` and
|
|
`GetJobRun` always report the current set. Following the EMR Serverless user guide, a resource holds
|
|
at most 50 tags, and `aws:` in any case is reserved as the prefix of a tag key or value. A session ARN
|
|
(`.../sessions/<id>`) answers `ResourceNotFoundException`, as sessions are not emulated. Once an
|
|
application is deleted, its ARN and its runs' ARNs answer `ResourceNotFoundException` too, while
|
|
`GetApplication` and `GetJobRun` still report them.
|
|
|
|
Applications, job runs, creation client tokens, and tags are scoped to the request's AWS Region. An
|
|
application or run created in one Region is not returned by list, get, or tag requests signed for
|
|
another.
|
|
|
|
`ListApplications` refuses a `states` filter naming a state that does not exist, or more than 7, and a
|
|
`maxResults` outside 1 to 50, with the `ValidationException` AWS's validation layer answers.
|
|
|
|
`CreateApplication` stores every configuration `UpdateApplication` does, `runtimeConfiguration`,
|
|
`monitoringConfiguration`, `schedulerConfiguration`, `diskEncryptionConfiguration`,
|
|
`interactiveConfiguration`, `identityCenterConfiguration` and `jobLevelCostAllocationConfiguration`
|
|
among them, and `GetApplication` returns each as it was written.
|
|
|
|
`DeleteApplication` leaves the application in `TERMINATED` state. `GetApplication` continues to
|
|
report that state so lifecycle waiters can observe it, while an unfiltered `ListApplications`
|
|
omits the terminated application. A terminated application cannot be started or stopped again.
|
|
|
|
## Job runs
|
|
|
|
Job runs are metadata only: nothing executes. A run follows the job run states and `GetJobRun`'s
|
|
response shape, and settles when it is read.
|
|
|
|
* **Lifecycle**: a run is `RUNNING` from the moment it is submitted. With the default
|
|
`job-run-duration-seconds` of `0`, a `BATCH` run is `SUCCESS` as soon as it starts; a positive
|
|
duration keeps it `RUNNING` that long. A run whose duration would pass its
|
|
`executionTimeoutMinutes` (720 when not given, as AWS reports it) is `CANCELLED` at the timeout.
|
|
A `STREAMING` run stays `RUNNING` until it is cancelled.
|
|
* **Auto-start**: a run submitted to a `CREATED` or `STOPPED` application starts the application,
|
|
as `autoStartConfiguration.enabled` defaults to `true`. With auto-start turned off, the run is
|
|
refused with `ValidationException` until the application is started. A run on a terminated
|
|
application is refused.
|
|
* **Idempotency**: `clientToken` is the idempotency token. Repeating a request with the same token
|
|
returns the original run; reusing the token with a different request answers `ConflictException`
|
|
(HTTP 409) "Request did not match the original".
|
|
* **Execution timeout**: `executionTimeoutMinutes` is 0 to 1,000,000, 0 meaning no timeout. From
|
|
release `emr-7.11.0`, a `BATCH` run's timeout must be 1 to 10080 minutes (7 days), as the model and
|
|
the 7.11.0 release notes say; a run outside that is refused with `ValidationException`.
|
|
* **CancelJobRun** moves a run that has not finished to `CANCELLED`. A finished run answers
|
|
`ValidationException` "Job run is not in a cancellable state".
|
|
* **ListJobRuns** returns the newest runs first, filtered by `states`, `createdAtAfter`,
|
|
`createdAtBefore` and `mode`, at most 50 per page. With several `states`, the runs are grouped by
|
|
state in the order the filter names them. A state or mode that does not exist, or more than 8
|
|
states, is refused with `ValidationException`. An unknown application has no runs. A `nextToken`
|
|
resumes only the listing it came from, with the same application and filters.
|
|
* **Attempts**: nothing runs, so no run fails and none is retried: every run is a single attempt,
|
|
number 1. `GetJobRun`, `ListJobRuns` and `ListJobRunAttempts` report it, with the run's own
|
|
creation and update times. `GetJobRun` with `attempt` 1, or without one, returns the run; an
|
|
`attempt` of 2 or more answers `ResourceNotFoundException`, and one below 1 or not an integer
|
|
`ValidationException`.
|
|
* `createdBy` is the caller's ARN, as `GetCallerIdentity` reports it. `releaseLabel` and
|
|
`networkConfiguration` come from the application.
|
|
|
|
A state machine drives applications and job runs through the `emr-serverless:` integrations, `.sync`
|
|
included; see [Step Functions: Amazon EMR Serverless tasks](step-functions.md#amazon-emr-serverless-tasks).
|
|
|
|
## Limitations and Differences from AWS
|
|
|
|
* **Jobs do not execute**: `StartJobRun` records a job run and moves it through its states, but no Spark or Hive job runs.
|
|
* **Unsourced errors**: AWS documents neither the error for a run submitted to an application whose auto-start is off nor the one for a run on a terminated application; Floci answers both with `ValidationException`. The same holds for a `BATCH` timeout outside 1 to 10080 minutes on `emr-7.11.0` or later (`ValidationException`) and for `GetJobRun` naming an attempt a run never made (`ResourceNotFoundException`), both in Floci's own wording. A run needs a `jobDriver`, as every `JobRun` carries one, and `jobDriver` is a union, so a run without a driver, or with one that sets both `sparkSubmit` and `hive` or neither, is refused with `ValidationException` too, in Floci's own wording.
|
|
* **StopApplication with running jobs**: AWS requires running jobs to finish or be cancelled before an application stops. Floci does not enforce it; with the default duration of `0` no `BATCH` run is ever running.
|
|
* **Not emulated**: retries (`retryPolicy` is stored and returned, but no run fails, so none is retried), queuing (`QUEUED`), `totalResourceUtilization` and `billedResourceUtilization`, and `shutdownGracePeriodInSeconds` (accepted and ignored).
|
|
* **Instant Start/Stop**: Floci marks the application `STARTED` or `STOPPED` immediately without provisioning actual compute capacity in the background.
|
|
* **Data Plane**: Floci does not implement the data-plane API or any execution environments.
|