DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Status
| Status | Under Discussion |
|---|---|
| Discussion thread | https://lists.apache.org/thread/qsqxkn8kclzqjwrqly1hm5tv9thxtcmd |
| Vote thread | |
| Jira | |
| Release |
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
A more detailed proposal that includes examples for use cases and more implementation detail can be found at FLIP-613 : Remote Artifact Fetch for Session-Mode Job Submission - detailed
Motivation
Flink can already fetch a job's jar from a remote URI using the cluster's own credentials. Given a URI, ArtifactFetchManagerselects a fetcher by scheme (http(s), s3, hdfs, gs, abfs, local) and retrieves the artifact. Today this is wired into Application Mode cluster start-up only.
Session mode has no equivalent. The REST submission path is built around a client that already holds the jar's bytes and uploads them, so every client must obtain the artifact itself before it can submit.
The Flink Kubernetes Operator has to download each session job's jar into its own pod and upload it to the Job Manager. This means every artifact crosses the network twice, the Operator needs credentials for every artifact store its tenants use, and its pod must be sized for the largest jar any tenant submits. If the Job Manager could fetch its own jar, we'd avoid all of that.
A second motivation for this is an opportunity for greater control. A session cluster today runs whatever jar is uploaded to it. If a cluster ran only fetched artifacts, and fetched artifacts only from locations its owner has approved, then the cluster owner (instead of job submitters) would get to decide where the code it runs comes from. We can't do that in Flink today.
Making fetching available to session mode changes some assumptions in ArtifactFetchManager. It was written for cluster start-up, before a cluster is serving anything, with a URI supplied by whoever started the cluster. In session mode it would run inside a live, shared Job Manager, repeatedly, for the lifetime of the cluster, with URIs chosen by whoever can reach the submission endpoint. Fetching therefore needs some extra controls to make it safe to expose.
Public Interfaces
Configuration
Cluster configuration
Option | Type | Default | Purpose |
|---|---|---|---|
| list of |
| which sources of job jar the |
| list | empty list | default-deny allowlist of locations a fetch may use |
| MemorySize | no limit | maximum size of a fetched artifact |
| Duration | 6 minutes | maximum time a fetch may take |
| Integer | 2 | fetches in flight at once, across all endpoints |
| boolean |
| reject HTTP(S) fetches to non-public addresses |
Job submission configuration
Option | Type | Default | Purpose |
|---|---|---|---|
| string | unset | the URI of the artifact to fetch for this submission |
| string | unset | expected |
user.artifacts.job-jar and user.artifacts.job-jar-digest are read from the flinkConfiguration map in the /jars request bodies.
No new REST endpoint is introduced and no new field is added to any request body.
Behaviour
When user.artifacts.job-jar is set, the handler fetches that artifact and uses it as the job jar in place of whatever the {jarid} path segment resolved to. A "real" jarid is therefore not required. Clients may pass any string, or upload a placeholder first. (This will let the Flink Kubernetes Operator work with this unchanged.)
When FETCH is excluded from web.submit.jar-sources, a submission naming a URI is rejected with 400 Bad Request. When UPLOAD is excluded, uploaded jars are stored but never run, and GET /jars no longer instantiates entry classes.
A submission by URI may not set options that load code (pipeline.classpaths, pipeline.jars, pipeline.cached-files, python.files and similar), and may not name a Python entry class. Both are rejected with 400 Bad Request naming the option, before any fetch is attempted. The point of fetching from an approved location is lost if the submission can also load code from elsewhere.
The allowlist
user.artifacts.allowed-uri-prefixes is default-deny: with the default empty list, no URI may be fetched. A cluster owner enabling FETCH must say where from.
Matching is by URI component, not string prefix. The scheme must match exactly. The whole authority (userinfo, host and port together) must match, the host case-insensitively. The path must equal the prefix's path or continue it at a /boundary, compared without decoding or normalising. Query and fragment are ignored.
https://artifacts.example.com/jobs does not match https://artifacts.example.com.evil.net/… nor https://artifacts.example.com/jobs-other/…
A prefix may be as coarse as a whole scheme (s3://) or as narrow as a single folder.
Naming a host in a prefix also permits the configured user.artifacts.http-headers to be sent to it, and exempts it from the restricted-host check.
Proposed Changes
ArtifactFetchManager and its fetchers will gain a fetch policy: that specifies which URIs may be fetched, whether each redirect hop is validated, what size and time limits apply, and the expected digest.
Application Mode uses a permissive policy that is behaviourally identical to today.
Session-mode submissions use a strict policy built from the cluster's configuration.
This keeps one fetching implementation rather than forking one for session mode, and lets Application Mode adopt any of these controls later by changing its default policy.
The /jars handlers gain the ability to resolve a job jar by URI instead of by {jarid}. Each submission fetches into its own fresh directory, so no submission can be given a jar left behind by another, and the whole directory is deleted when it is no longer needed: on every failure path, and for /run and /plan once the request is answered. A jar fetched for /run-applicationbelongs to the application and is deleted when the application reaches a terminal state.
To limit the impact of a fetch on a running session cluster:
A fetch never occupies a thread that the rest of the Job Manager's REST API depends on. A slow fetch delays its own submission and nothing else.
A fetch never holds a slot beyond
user.artifacts.fetch-timeout, so a fetch that stalls cannot permanently consume the cluster's fetch capacity. A fetch that completes after its deadline is discarded rather than used.At most
user.artifacts.max-concurrent-fetchesfetches run at once, across all endpoints. Submissions arriving above that limit are rejected with503 Service Unavailableand may be retried; uploads and the rest of the REST API are unaffected.
Validation happens before any fetch: the allowlist, the digest's format, the code-loading options and the Python entry class are all checked first, so a submission that can never be permitted never consumes a fetch slot.
If the fetch options are invalid, the cluster still starts. The error is logged and every submission by URI is rejected naming the offending option, which matches how other optional Job Manager subsystems behave when they cannot be configured, and avoids a configuration mistake preventing a cluster from starting at all.
Compatibility, Deprecation, and Migration Plan
No impact on existing users. With web.submit.jar-sources at its default of UPLOAD, the REST API's behaviour, request and response shapes and endpoints are unchanged, and none of the other new options have any effect.
Application Mode start-up fetching is unchanged, and is pinned by tests asserting it uses the permissive policy, so this FLIP will not cause this to drift.
Nothing is deprecated and there is no migration. Uploading and running a jar remains a first-class, permanently supported way to submit to a session cluster.
Test Plan
Unit and integration tests will cover: each value of web.submit.jar-sources accepting and rejecting the right submissions on every affected endpoint; allowlist matching, including the near-miss authority and path cases above; the size, time and concurrency limits, and the rejection messages naming which limit was exceeded; rejection of code-loading options and Python entry classes before any fetch; digest verification and mismatch; redirect handling under both policies; and that each Delivery Phase rejects the capabilities it has not yet reached.
Existing REST submission tests pass unchanged on a default configuration, and tests assert that Application Mode start-up fetching uses the permissive policy and that a fetch never runs on a thread the rest of the REST API depends on.
End-to-end tests on a MiniCluster cover a full submission by URI, and that the REST API stays responsive while a slow fetch is in progress.
Known limitations
The allowlist is the only control for filesystem-plugin schemes. user.artifacts.disallow-restricted-hosts applies to http and httpsonly; fetches over s3, hdfs, gs or abfs are made by the plugin, and Flink does not control how those plugins resolve hosts or open connections. Cluster owners needing an equivalent restriction should use the plugin's own configuration or network-level egress controls.
A filesystem-plugin fetch can block in a call Flink cannot bound or interrupt. Flink's FileSystem API accepts no timeout. The fetch always releases its slot at the deadline, so the cluster keeps accepting submissions, but the thread and its partial jar remain until the plugin's own timeouts fire. In the worst case a fetch blocked while creating a FileSysteminstance holds a static lock that also guards the instance cache, stalling other filesystem access in the Job Manager. This is existing Flink behaviour, but this FLIP makes it reachable with a scheme and authority chosen by a submitter. The allowlist gives a way to restrict this to only filesystems trusted by the cluster owner.
Only the entry artifact's source is controlled. A fetched jar's own contents are trusted. Allowing a location means trusting what it serves, including where it redirects.
Python programs cannot be submitted by URI, because the Python entry classes load code from paths the submission supplies.
In-progress submissions are tracked per Job Manager. With high availability, a retry reaching a different Job Manager is handled as a new submission.
POST /jobs is out of scope, as it is out of scope for web.submit.jar-sources's existing sibling web.submit.enable. Cluster owners needing the restriction across the whole REST API can block that endpoint separately.
Rejected Alternatives
Leave artifact resolution to the client, as today. This is the status quo, and it works, but it puts the artifact on the network twice, requires every orchestrator to hold credentials for every artifact store its tenants use, and offers a cluster owner no way to constrain what code their cluster runs. (The last of these cannot be solved client-side).
Use pipeline.jars to name the remote job jar. It already accepts URIs, so no new key would be needed. But it is a list with existing meaning on both the client and the cluster, it is one of the options this FLIP must restrict for submissions by URI, and overloading it would make "which jar is the entry jar" ambiguous. A single-valued key with one job is clearer to reason about and to secure.
A typed jarUri field on JarRunRequestBody, with a companion POST /jars/run. Cleaner as an API, but it changes REST message classes and adds an endpoint, which every client (including the Operator) would need to learn. Putting the key in the flinkConfiguration map the request already carries means existing clients work unchanged, which is what makes the Operator scenario work with no Operator release.
Include FETCH in the default web.submit.jar-sources. Fetching would then be available without any explicit action. Rejected because enabling it without also setting an allowlist would let anyone who can reach the submission endpoint make the Job Manager fetch arbitrary URIs with the cluster's credentials. Default-deny, opted into deliberately, is the right shape for a capability of that kind.
Disable POST /jars/upload when UPLOAD is excluded, rather than accepting uploads and refusing to run them.Refusing uploads outright would break clients that always upload before calling /run (including the Operator) which uploads a placeholder jar when a session job has no jarURI. Refusing to run uploaded jars gives the same guarantee while leaving those clients working.
Respond to submissions immediately and fetch asynchronously. A submit-then-poll interface would remove the long-held connection entirely. It is a larger change to the submission contract than this FLIP needs, and every existing client already waits on /run today; the fetch simply makes the wait longer.