feat(emr-serverless): open the live Spark UI from dashboard links (#8890)

With runner-mode docker, GetDashboardForJobRun's link for a Spark run's
attempt that has not ended now opens its driver's Spark UI for real, and
GetResourceDashboard's link does the same for a session's Spark Connect
server, as "For jobs in a running state, the application UI is a live
user interface such as the Spark or Tez web UI" and "While a session is
active, the URL opens the live Apache Spark UI".

Each link opens on a host of its own,
<secret>-4040.emr-serverless-ui.<Floci's host>, through the application
UI proxy EMR's on-cluster UIs use. That proxy moves to core.common
(AppUiProxy, AppUiRoutes, AppUiRoute, AppUiHost), and each service
registers the label its hosts are under. The runner turns the driver's
UI on for every EMR Serverless Spark run, as the release's image turns
it off, publishes port 4040 on the Docker host's loopback interface, and
keeps where Floci reaches it while the container runs.

A run whose logs are not kept in managed storage gets no live UI, as
with logs in S3 alone the application UI is "Not supported". A Hive
run, a run or session that has ended, and every link in the immediate
mode still open Floci's own page, which now says whether the attempt's
logs are in managed storage.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-18 15:41:25 -04:00
1 parent 3ebd1bc38c
commit 3ffec01a76
26 files changed
+1226 -152

No files matched your search

@@ -79,6 +79,7 @@ public class TlsConfigSource implements ConfigSource {
"*.execute-api.localhost.localstack.cloud",
"*.cloudfront.localhost.floci.io", "*.cloudfront.localhost",
"*.emrappui.localhost.floci.io", "*.emrappui.localhost",
"*.emr-serverless-ui.localhost.floci.io", "*.emr-serverless-ui.localhost",
"host.docker.internal"));
for (String region : AwsRegions.KNOWN_IDS.stream().sorted().toList()) {
sans.add("*.dkr.ecr." + region + ".localhost.floci.io");
@@ -0,0 +1,58 @@
package io.floci.aws.core.common;
import java.net.URI;
import java.security.SecureRandom;
import java.util.Locale;
/**
* The host of an application UI Floci opens through {@link AppUiProxy}, {@code <secret>-<port>.<label>.<Floci's host>}:
* the secret of the link, which is its authority, as no request to the interface carries AWS credentials; the port of
* the interface; and, after the label of the service whose interface it is ({@link AppUiRoutes#hostLabel}), Floci's
* own host and port, which {@code rest} holds from the dot before the label.
*/
public record AppUiHost(String secret, int port, String rest) {
/** A secret's length: 26 characters of base32, 130 random bits. */
public static final int SECRET_LENGTH = 26;
// In lower case, as a host name is read without case.
private static final String BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
/** The host {@code hostHeader} names, or null where it is not an interface's host under {@code label}. */
public static AppUiHost parse(String hostHeader, String label) {
String host = hostHeader.toLowerCase(Locale.ROOT);
int dot = host.indexOf('.');
int dash = dot > 0 ? host.lastIndexOf('-', dot) : -1;
if (dash != SECRET_LENGTH || !host.startsWith(label + ".", dot + 1)) {
return null;
}
try {
return new AppUiHost(host.substring(0, dash), Integer.parseInt(host.substring(dash + 1, dot)),
host.substring(dot));
} catch (NumberFormatException e) {
return null;
}
}
/** A new link's secret, drawn from {@code random}. */
public static String newSecret(SecureRandom random) {
StringBuilder secret = new StringBuilder(SECRET_LENGTH);
for (int i = 0; i < SECRET_LENGTH; i++) {
secret.append(BASE32.charAt(random.nextInt(BASE32.length())));
}
return secret.toString();
}
/**
* The URL of {@code path} on the interface on {@code port} of the link {@code secret}, under {@code label} on
* Floci's {@code baseUrl}.
*/
public static String url(String baseUrl, String secret, int port, String label, String path) {
URI base = URI.create(baseUrl);
return base.getScheme() + "://" + secret + "-" + port + "." + label + "." + base.getRawAuthority() + path;
}
/** The origin of the link's interface on {@code otherPort}, as a browser reaches it over {@code scheme}. */
public String origin(String scheme, int otherPort) {
return scheme + "://" + secret + "-" + otherPort + rest;
}
}
@@ -1,7 +1,5 @@
package io.floci.aws.services.emr;
package io.floci.aws.core.common;
import io.floci.aws.core.common.Html;
import io.floci.aws.core.common.ServiceConfigAccess;
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
@@ -17,9 +15,12 @@ import io.vertx.core.net.SocketAddress;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Priority;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import jakarta.interceptor.Interceptor;
import org.jboss.logging.Logger;
import java.net.URI;
@@ -31,16 +32,17 @@ import java.util.Map;
import java.util.Set;
/**
* The on-cluster application UIs Floci opens for real ({@link EmrAppUiService}): a request to an interface's own host,
* {@code <secret>-<port>.emrappui.<Floci's host>}, goes on to that port of the cluster's primary node, and its answer
* comes back with each link to one of the node's interfaces, which its daemons write by the node's name, made a link
* to that interface's own host. The secret in the host is the link's authority, as no request to the interface carries
* AWS credentials; one that is not this process's, or whose hour has passed, is answered with a page saying so.
* The application UIs Floci opens for real, those of an EMR cluster's primary node and of an EMR Serverless run's
* driver among them: a request to an interface's own host, {@link AppUiHost}, goes on to where the service whose label
* the host holds finds that interface ({@link AppUiRoutes}), and its answer comes back with each link to one of its
* sibling interfaces, which their daemons write by their own address, made a link to that interface's own host. The
* secret in the host is the link's authority, as no request to the interface carries AWS credentials; one that is not
* this process's, or whose hour has passed, is answered with a page saying so.
*/
@ApplicationScoped
public class EmrAppUiProxy {
public class AppUiProxy {
private static final Logger LOG = Logger.getLogger(EmrAppUiProxy.class);
private static final Logger LOG = Logger.getLogger(AppUiProxy.class);
// What does not go on: the connection's own headers, the host, which the interface is asked for under the
// browser's, and the encodings the browser takes, as only an answer that is not compressed can have its links made
@@ -56,20 +58,19 @@ public class EmrAppUiProxy {
// How long the interface may send nothing, its answer or the rest of it, before the request is given up.
private static final Duration IDLE_TIMEOUT = Duration.ofMinutes(1);
private final EmrAppUiService appUis;
private final List<AppUiRoutes> services;
private final ServiceConfigAccess serviceConfigAccess;
private final Vertx vertx;
private final HttpClient client;
private final Duration idleTimeout;
@Inject
public EmrAppUiProxy(EmrAppUiService appUis, ServiceConfigAccess serviceConfigAccess, Vertx vertx) {
this(appUis, serviceConfigAccess, vertx, IDLE_TIMEOUT);
public AppUiProxy(Instance<AppUiRoutes> services, ServiceConfigAccess serviceConfigAccess, Vertx vertx) {
this(services.stream().toList(), serviceConfigAccess, vertx, IDLE_TIMEOUT);
}
EmrAppUiProxy(EmrAppUiService appUis, ServiceConfigAccess serviceConfigAccess, Vertx vertx,
Duration idleTimeout) {
this.appUis = appUis;
AppUiProxy(List<AppUiRoutes> services, ServiceConfigAccess serviceConfigAccess, Vertx vertx, Duration idleTimeout) {
this.services = services;
this.serviceConfigAccess = serviceConfigAccess;
this.vertx = vertx;
this.idleTimeout = idleTimeout;
@@ -81,26 +82,28 @@ public class EmrAppUiProxy {
client.close();
}
void register(@Observes Router router) {
// Ahead of the routes the other observers add, whose paths an interface's own may be: the ResourceManager's REST
// answers are under /ws/, where API Gateway's WebSocket route takes every request. A request to any other host goes
// on to them.
void register(@Observes @Priority(Interceptor.Priority.APPLICATION) Router router) {
router.route().handler(this::handle);
}
void handle(RoutingContext context) {
HttpServerRequest request = context.request();
String hostHeader = request.getHeader("host");
AppUiRoutes service = hostHeader != null ? serviceOf(hostHeader) : null;
// This route runs ahead of the filter that refuses a disabled service, so it checks for itself.
if (hostHeader == null || !hostHeader.toLowerCase(Locale.ROOT).contains("." + EmrAppUiService.UI_HOST + ".")
|| !serviceConfigAccess.isEnabled("emr")) {
if (service == null || !serviceConfigAccess.isEnabled(service.service())) {
context.next();
return;
}
request.pause();
// Finding the interface may ask Docker where it is, so off the event loop.
vertx.<EmrAppUiService.UiRoute>executeBlocking(() -> appUis.route(hostHeader, request.scheme()), false)
vertx.<AppUiRoute>executeBlocking(() -> service.route(hostHeader, request.scheme()), false)
.onComplete(routed -> {
if (routed.failed()) {
LOG.warnv(routed.cause(), "EMR application UI request to {0} could not be routed",
hostHeader);
LOG.warnv(routed.cause(), "Application UI request to {0} could not be routed", hostHeader);
refuse(request, 502, "The interface could not be reached.");
} else if (routed.result() == null) {
request.resume();
@@ -113,7 +116,18 @@ public class EmrAppUiProxy {
});
}
private void forward(HttpServerRequest request, String hostHeader, EmrAppUiService.UiRoute route) {
// The service whose label the host holds, or null where it holds none.
private AppUiRoutes serviceOf(String hostHeader) {
String host = hostHeader.toLowerCase(Locale.ROOT);
for (AppUiRoutes service : services) {
if (host.contains("." + service.hostLabel() + ".")) {
return service;
}
}
return null;
}
private void forward(HttpServerRequest request, String hostHeader, AppUiRoute route) {
URI authority = URI.create("http://" + hostHeader);
RequestOptions options = new RequestOptions().setMethod(request.method())
.setServer(SocketAddress.inetSocketAddress(route.port(), route.host()))
@@ -131,7 +145,8 @@ public class EmrAppUiProxy {
client.request(options).onComplete(opened -> {
if (opened.failed()) {
route.unreachable().run();
refuse(request, 502, "The cluster's interface did not answer: " + opened.cause().getMessage());
refuse(request, route.unansweredStatus(), route.unanswered() != null ? route.unanswered()
: "The interface did not answer: " + opened.cause().getMessage());
return;
}
HttpClientRequest upstream = opened.result();
@@ -148,7 +163,7 @@ public class EmrAppUiProxy {
if (response.headWritten()) {
response.reset();
} else {
refuse(request, 502, "The cluster's interface did not answer: "
refuse(request, 502, "The interface did not answer: "
+ answered.cause().getMessage());
}
return;
@@ -0,0 +1,33 @@
package io.floci.aws.core.common;
import java.util.Map;
/**
* Where a request to an application UI's host goes ({@link AppUiProxy}): the interface's address; each link to one of
* its sibling interfaces its pages hold, as their daemons write it, and as the browser reaches that interface; what
* to do when the address does not answer, and how such a request is answered, {@code unansweredStatus} with a page
* saying {@code unanswered}, or, where that is null, a {@code 502} saying why; else why the request is refused, with
* its HTTP status.
*/
public record AppUiRoute(String host, int port, Map<String, String> rewrites, Runnable unreachable, int status,
String refusal, int unansweredStatus, String unanswered) {
/** A route whose interface, when it does not answer, is a {@code 502}. */
public AppUiRoute(String host, int port, Map<String, String> rewrites, Runnable unreachable, int status,
String refusal) {
this(host, port, rewrites, unreachable, status, refusal, 502, null);
}
/** A request refused with {@code status}, its page saying {@code refusal}. */
public static AppUiRoute refused(int status, String refusal) {
return new AppUiRoute(null, 0, Map.of(), () -> { }, status, refusal);
}
/**
* A request to the interface at {@code host} and {@code port}, whose pages link to no sibling, answered with
* {@code unansweredStatus} and a page saying {@code unanswered} while the interface does not answer.
*/
public static AppUiRoute to(String host, int port, int unansweredStatus, String unanswered) {
return new AppUiRoute(host, port, Map.of(), () -> { }, 0, null, unansweredStatus, unanswered);
}
}
@@ -0,0 +1,20 @@
package io.floci.aws.core.common;
/**
* A service's application UIs that Floci opens for real, each on a host of its own, {@link AppUiHost}, which
* {@link AppUiProxy} sends on to the interface.
*/
public interface AppUiRoutes {
/** The label under Floci's host the hosts of the service's interfaces are in. */
String hostLabel();
/** The service whose interfaces these are, which must be enabled for a request to one to go on. */
String service();
/**
* The route of a request whose {@code Host} is {@code hostHeader}, over {@code scheme}; null where the host is none
* of the service's links. Called off the event loop, as finding an interface may ask Docker.
*/
AppUiRoute route(String hostHeader, String scheme);
}
@@ -2,6 +2,9 @@ package io.floci.aws.services.emr;
import com.fasterxml.jackson.core.type.TypeReference;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AppUiHost;
import io.floci.aws.core.common.AppUiRoute;
import io.floci.aws.core.common.AppUiRoutes;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.LinkSigner;
import io.floci.aws.core.common.RegionResolver;
@@ -18,7 +21,6 @@ import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
@@ -29,7 +31,6 @@ import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -46,15 +47,15 @@ import java.util.regex.Pattern;
* In the docker runner mode, an on-cluster UI that runs on the cluster's primary node, its ResourceManager, an
* application master through it, its MapReduce JobHistory server, the NodeManager of a primary node that works, the
* Spark History Server of a cluster with Spark, or the YARN timeline server and the Tez UI of one with Hadoop and Tez,
* opens for real through {@link EmrAppUiProxy}, on a host of its own under {@link #UI_HOST}, as AWS's are under
* "emrappui-prod.us-east-1.amazonaws.com" (Management Guide, "View Amazon EMR application history"). A persistent
* application UI opens the same interfaces while its cluster runs, and, for the 30 days after it ends, its kept
* history's, served by a container of its own. Any other link opens a page of Floci's own about the cluster
* ({@link EmrAppUiController}). Either link is valid for {@link #VALIDITY}: the page's is signed with a key of this
* process, and a proxied interface's host holds a secret this process gave it.
* opens for real through Floci's application UI proxy ({@link AppUiRoutes}), on a host of its own under
* {@link #UI_HOST}, as AWS's are under "emrappui-prod.us-east-1.amazonaws.com" (Management Guide, "View Amazon EMR
* application history"). A persistent application UI opens the same interfaces while its cluster runs, and, for the
* 30 days after it ends, its kept history's, served by a container of its own. Any other link opens a page of
* Floci's own about the cluster ({@link EmrAppUiController}). Either link is valid for {@link #VALIDITY}: the page's
* is signed with a key of this process, and a proxied interface's host holds a secret this process gave it.
*/
@ApplicationScoped
public class EmrAppUiService {
public class EmrAppUiService implements AppUiRoutes {
/** Where Floci serves the page a presigned URL opens. */
static final String PATH = "/_aws/emr/app-ui";
@@ -72,9 +73,6 @@ public class EmrAppUiService {
static final String ACTIVE = "ACTIVE";
/** The label under Floci's host name an on-cluster UI's own host is in. */
static final String UI_HOST = "emrappui";
// A link's secret: 26 characters of base32, 130 random bits, in lower case, as a host name is read without case.
private static final int SECRET_LENGTH = 26;
private static final String BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
static final String RESOURCE_MANAGER = "ResourceManager";
static final String APPLICATION_MASTER = "ApplicationMaster";
static final String JOB_HISTORY_SERVER = "JobHistoryServer";
@@ -323,9 +321,7 @@ public class EmrAppUiService {
clusters.startPrimaryNode(cluster.getId());
}
}
URI base = URI.create(baseUrl);
return new Presigned(base.getScheme() + "://" + secret + "-" + port + "." + UI_HOST + "."
+ base.getRawAuthority() + landing, ready);
return new Presigned(AppUiHost.url(baseUrl, secret, port, UI_HOST, landing), ready);
}
// Checks, once the link has expired, whether the container serving the cluster's kept history may stop.
@@ -403,11 +399,7 @@ public class EmrAppUiService {
}
private String secret() {
StringBuilder secret = new StringBuilder(SECRET_LENGTH);
for (int i = 0; i < SECRET_LENGTH; i++) {
secret.append(BASE32.charAt(random.nextInt(BASE32.length())));
}
return secret.toString();
return AppUiHost.newSecret(random);
}
/**
@@ -423,43 +415,35 @@ public class EmrAppUiService {
private record Found(ContainerLifecycleManager.EndpointInfo endpoint, Instant at) {
}
/**
* Where a request to a proxied interface's host goes: the interface's address on the primary node, and each link
* to one of the node's interfaces its pages hold, by the node's name, as the browser reaches that interface; else
* why it is refused, with its HTTP status.
*/
public record UiRoute(String host, int port, Map<String, String> rewrites, Runnable unreachable, int status,
String refusal) {
@Override
public String hostLabel() {
return UI_HOST;
}
static UiRoute refused(int status, String refusal) {
return new UiRoute(null, 0, Map.of(), () -> { }, status, refusal);
}
@Override
public String service() {
return "emr";
}
/**
* The route of a request whose {@code Host} is {@code hostHeader}, over {@code scheme}; null where the host is not
* a proxied interface's, {@code <secret>-<port>.}{@value #UI_HOST}{@code .<Floci's host>}.
* The route of a request whose {@code Host} is {@code hostHeader}, over {@code scheme}: to the interface's address
* on the primary node, with each link to one of the node's interfaces its pages hold, by the node's name, made the
* browser's; null where the host is not a proxied interface's, {@code <secret>-<port>.}{@value #UI_HOST}{@code
* .<Floci's host>}.
*/
public UiRoute route(String hostHeader, String scheme) {
String host = hostHeader.toLowerCase(Locale.ROOT);
int dot = host.indexOf('.');
int dash = dot > 0 ? host.lastIndexOf('-', dot) : -1;
if (dash != SECRET_LENGTH || !host.startsWith(UI_HOST + ".", dot + 1)) {
@Override
public AppUiRoute route(String hostHeader, String scheme) {
AppUiHost host = AppUiHost.parse(hostHeader, UI_HOST);
if (host == null) {
return null;
}
String secret = host.substring(0, dash);
int port;
try {
port = Integer.parseInt(host.substring(dash + 1, dot));
} catch (NumberFormatException e) {
return null;
}
Grant grant = grants.get(secret);
int port = host.port();
Grant grant = grants.get(host.secret());
if (grant == null || !clock.instant().isBefore(grant.expires())) {
return UiRoute.refused(403, EmrAppUiController.INVALID);
return AppUiRoute.refused(403, EmrAppUiController.INVALID);
}
if (!grant.ports().contains(port)) {
return UiRoute.refused(404, NO_SUCH_INTERFACE);
return AppUiRoute.refused(404, NO_SUCH_INTERFACE);
}
// A live interface is there only while its cluster runs or waits, and its kept history only once it has ended,
// for its 30 days: outside them, the port found for it is no longer the cluster's own.
@@ -469,11 +453,11 @@ public class EmrAppUiService {
boolean up = cluster != null && (EmrClusterLifecycle.RUNNING.equals(cluster.getState())
|| EmrClusterLifecycle.WAITING.equals(cluster.getState()));
if (!grant.history() && !up) {
return UiRoute.refused(404, String.format(CLUSTER_ENDED, grant.clusterId()));
return AppUiRoute.refused(404, String.format(CLUSTER_ENDED, grant.clusterId()));
}
if (grant.history() && (cluster == null || up || cluster.getEndDateTime() == null
|| !now.isBefore(cluster.getEndDateTime().plus(EmrService.HISTORY_KEPT)))) {
return UiRoute.refused(404, String.format(HISTORY_GONE, grant.clusterId()));
return AppUiRoute.refused(404, String.format(HISTORY_GONE, grant.clusterId()));
}
Found found = grant.endpoints().get(port);
if (found == null || !now.isBefore(found.at().plus(ENDPOINT_RECHECK))) {
@@ -482,20 +466,19 @@ public class EmrAppUiService {
: clusters.webInterface(grant.clusterId(), port)).orElse(null);
if (endpoint == null) {
grant.endpoints().remove(port);
return UiRoute.refused(503, grant.history() ? HISTORY_NOT_READY : NOT_READY);
return AppUiRoute.refused(503, grant.history() ? HISTORY_NOT_READY : NOT_READY);
}
found = new Found(endpoint, now);
grant.endpoints().put(port, found);
}
// The node's daemons write links to one another by the node's name, which the browser reaches as each
// interface's own host, under this one's Floci host and port.
String rest = host.substring(dot);
Map<String, String> rewrites = new LinkedHashMap<>();
for (int other : grant.ports()) {
rewrites.put("http://" + grant.primaryHost() + ":" + other, scheme + "://" + secret + "-" + other + rest);
rewrites.put("http://" + grant.primaryHost() + ":" + other, host.origin(scheme, other));
}
Found routed = found;
return new UiRoute(found.endpoint().host(), found.endpoint().port(), rewrites,
return new AppUiRoute(found.endpoint().host(), found.endpoint().port(), rewrites,
() -> grant.endpoints().remove(port, routed), 0, null);
}
@@ -0,0 +1,192 @@
package io.floci.aws.services.emrserverless;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AppUiHost;
import io.floci.aws.core.common.AppUiRoute;
import io.floci.aws.core.common.AppUiRoutes;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.common.RequestScopes;
import io.floci.aws.core.common.docker.ContainerLifecycleManager;
import io.floci.aws.services.emrserverless.model.JobRun;
import io.floci.aws.services.emrserverless.model.Session;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.security.SecureRandom;
import java.time.Clock;
import java.time.Instant;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* The application UIs a {@code GetDashboardForJobRun} or {@code GetResourceDashboard} link opens. "For jobs in a
* running state, the application UI is a live user interface such as the Spark or Tez web UI", and "While a session is
* active, the URL opens the live Apache Spark UI". In the docker runner mode, where Floci runs a Spark run's driver, or
* a session's Spark Connect server, in a container, a link given before it has ended opens that driver's Spark UI for
* real, on a host of its own under {@link #UI_HOST} ({@link AppUiHost}), which Floci's application UI proxy sends on
* to the driver's container while it runs, on a network where that container has an address of its own. The secret in
* the host is the link's authority, as no request to the UI carries AWS credentials, and is valid for
* {@link EmrServerlessDashboards#VALIDITY}, as "The URL is valid for one hour after you generate it". Any other link, a
* Hive run's, that of a run whose logs are not in managed storage, one given once the run or session has ended, or any
* in the immediate runner mode, opens a page of Floci's own about it ({@link EmrServerlessDashboards}).
*/
@ApplicationScoped
public class EmrServerlessAppUis implements AppUiRoutes {
/** The label under Floci's host name a driver's UI's own host is in. */
static final String UI_HOST = "emr-serverless-ui";
// No source gives AWS's wording for these; they are Floci's.
static final String NO_SUCH_INTERFACE = "This link opens none of the driver's interfaces on that port.";
static final String NOT_RUNNING = "The driver is not running yet. Try again in a moment.";
static final String NOT_ANSWERING = "The driver's Spark UI is not answering yet: it starts with the driver's Spark,"
+ " unless the run turns it off (spark.ui.enabled). Try again in a moment.";
static final String RUN_ENDED = "Attempt %d of job run %s is no longer running, and its live Spark UI is there only"
+ " while it runs.";
static final String SESSION_ENDED = "Session %s has ended, and its live Spark UI is there only while it is active.";
private static final Set<String> SESSION_ENDING = Set.of(EmrServerlessSessionService.STATE_TERMINATING,
EmrServerlessSessionService.STATE_TERMINATED, EmrServerlessSessionService.STATE_FAILED);
private final EmrServerlessDashboards dashboards;
private final EmrServerlessJobRunService jobRuns;
private final EmrServerlessSessionService sessions;
private final RegionResolver regionResolver;
private final Clock clock;
private final String baseUrl;
// The links to drivers' UIs this process has given, by their secret, until they expire.
private final Map<String, EmrServerlessDashboards.Link> grants = new ConcurrentHashMap<>();
private final SecureRandom random = new SecureRandom();
@Inject
public EmrServerlessAppUis(EmrServerlessDashboards dashboards, EmrServerlessJobRunService jobRuns,
EmrServerlessSessionService sessions, RegionResolver regionResolver,
EmulatorConfig config, Clock clock) {
this(dashboards, jobRuns, sessions, regionResolver, config.effectiveBaseUrl(), clock);
}
EmrServerlessAppUis(EmrServerlessDashboards dashboards, EmrServerlessJobRunService jobRuns,
EmrServerlessSessionService sessions, RegionResolver regionResolver, String baseUrl,
Clock clock) {
this.dashboards = dashboards;
this.jobRuns = jobRuns;
this.sessions = sessions;
this.regionResolver = regionResolver;
this.clock = clock;
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
}
/**
* The link GetDashboardForJobRun gives for a run's attempt, which must be there: its driver's live Spark UI, for a
* Spark run in the docker runner mode whose attempt has not ended and whose logs are in managed storage; else
* Floci's page about the attempt.
*/
public String jobRunUrl(String applicationId, String jobRunId, int attempt) {
EmrServerlessJobRunService.DashboardView view = jobRuns.dashboard(applicationId, jobRunId, attempt);
JobRun run = view.run();
String accountId = regionResolver.getAccountId();
String region = regionResolver.getRegion();
boolean live = jobRuns.servesDriverUis() && run.getJobDriver() != null
&& run.getJobDriver().getSparkSubmit() != null && !EmrServerlessJobRunService.isTerminal(run)
&& view.logs().inManagedStorage();
if (!live) {
return dashboards.url(accountId, region, applicationId, jobRunId, attempt);
}
return driverUiUrl(new EmrServerlessDashboards.Link(accountId, region, applicationId, jobRunId, null, attempt,
expiry()));
}
/**
* The link GetResourceDashboard gives for a session: its Spark Connect server's live Spark UI, in the docker runner
* mode while the session has not ended or begun to; else Floci's page about the session.
*/
public String sessionUrl(String applicationId, Session session) {
String accountId = regionResolver.getAccountId();
String region = regionResolver.getRegion();
if (!jobRuns.servesDriverUis() || SESSION_ENDING.contains(session.getState())) {
return dashboards.sessionUrl(accountId, region, applicationId, session.getSessionId());
}
return driverUiUrl(new EmrServerlessDashboards.Link(accountId, region, applicationId, null,
session.getSessionId(), 0, expiry()));
}
private String driverUiUrl(EmrServerlessDashboards.Link link) {
long now = clock.instant().getEpochSecond();
grants.values().removeIf(grant -> now >= grant.expires());
String secret = AppUiHost.newSecret(random);
grants.put(secret, link);
return AppUiHost.url(baseUrl, secret, SparkExecutors.DRIVER_UI_PORT, UI_HOST, "/");
}
private long expiry() {
return clock.instant().plus(EmrServerlessDashboards.VALIDITY).getEpochSecond();
}
@Override
public String hostLabel() {
return UI_HOST;
}
@Override
public String service() {
return EmrServerlessJobRunService.SERVICE;
}
/**
* The route of a request whose {@code Host} is {@code hostHeader}: to the driver's Spark UI while the run's
* attempt, or the session, has it running; null where the host is not a driver's UI's, {@code
* <secret>-<port>.}{@value #UI_HOST}{@code .<Floci's host>}.
*/
@Override
public AppUiRoute route(String hostHeader, String scheme) {
AppUiHost host = AppUiHost.parse(hostHeader, UI_HOST);
if (host == null) {
return null;
}
EmrServerlessDashboards.Link link = grants.get(host.secret());
if (link == null || clock.instant().getEpochSecond() >= link.expires()) {
return AppUiRoute.refused(403, EmrServerlessDashboardController.INVALID);
}
if (host.port() != SparkExecutors.DRIVER_UI_PORT) {
return AppUiRoute.refused(404, NO_SUCH_INTERFACE);
}
try {
return RequestScopes.callAs(link.accountId(), link.region(),
() -> link.jobRunId() != null ? runRoute(link) : sessionRoute(link));
} catch (AwsException e) {
// The run, its application or the session has gone.
return AppUiRoute.refused(404, e.getMessage());
}
}
private AppUiRoute runRoute(EmrServerlessDashboards.Link link) {
JobRun run = jobRuns.dashboard(link.applicationId(), link.jobRunId(), link.attempt()).run();
if (EmrServerlessJobRunService.isTerminal(run)) {
return AppUiRoute.refused(404, String.format(RUN_ENDED, link.attempt(), link.jobRunId()));
}
return driverUi(link.jobRunId()).orElseGet(() -> AppUiRoute.refused(503, NOT_RUNNING));
}
// A session that is ending may still have its server running: its UI goes with the server.
private AppUiRoute sessionRoute(EmrServerlessDashboards.Link link) {
Session session = sessions.getSession(link.applicationId(), link.sessionId());
boolean ended = !EmrServerlessSessionService.STATE_TERMINATING.equals(session.getState())
&& SESSION_ENDING.contains(session.getState());
Optional<AppUiRoute> driver = ended ? Optional.empty() : driverUi(link.sessionId());
if (driver.isPresent()) {
return driver.get();
}
return SESSION_ENDING.contains(session.getState())
? AppUiRoute.refused(404, String.format(SESSION_ENDED, link.sessionId()))
: AppUiRoute.refused(503, NOT_RUNNING);
}
private Optional<AppUiRoute> driverUi(String runId) {
SparkJobRunner runner = jobRuns.containerRunner();
Optional<ContainerLifecycleManager.EndpointInfo> endpoint = runner != null ? runner.driverUi(runId)
: Optional.empty();
// Its container runs before its Spark has started its UI.
return endpoint.map(found -> AppUiRoute.to(found.host(), found.port(), 503, NOT_ANSWERING));
}
}
@@ -2,7 +2,6 @@ package io.floci.aws.services.emrserverless;
import io.floci.aws.core.common.PaginatedResult;
import io.floci.aws.core.common.Pagination;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.common.SparkConnectEndpoint;
import io.floci.aws.services.emrserverless.model.Application;
import io.floci.aws.services.emrserverless.model.ApplicationSummary;
@@ -59,18 +58,15 @@ public class EmrServerlessController {
private final EmrServerlessService service;
private final EmrServerlessJobRunService jobRuns;
private final EmrServerlessSessionService sessions;
private final EmrServerlessDashboards dashboards;
private final RegionResolver regionResolver;
private final EmrServerlessAppUis appUis;
@Inject
public EmrServerlessController(EmrServerlessService service, EmrServerlessJobRunService jobRuns,
EmrServerlessSessionService sessions, EmrServerlessDashboards dashboards,
RegionResolver regionResolver) {
EmrServerlessSessionService sessions, EmrServerlessAppUis appUis) {
this.service = service;
this.jobRuns = jobRuns;
this.sessions = sessions;
this.dashboards = dashboards;
this.regionResolver = regionResolver;
this.appUis = appUis;
}
@POST
@@ -189,7 +185,7 @@ public class EmrServerlessController {
/**
* The link to a run's application UI, for the attempt asked for or else the latest, the run and attempt checked as
* GetJobRun checks them ({@link EmrServerlessDashboards}). {@code accessSystemProfileLogs} is for jobs on Lake
* GetJobRun checks them ({@link EmrServerlessAppUis}). {@code accessSystemProfileLogs} is for jobs on Lake
* Formation, which Floci runs none of, so it changes nothing.
*/
@GET
@@ -199,8 +195,7 @@ public class EmrServerlessController {
@QueryParam("attempt") String attempt) {
JobRun run = jobRuns.getJobRun(applicationId, jobRunId, EmrServerlessJobRunService.parseAttempt(attempt));
GetDashboardForJobRunResponse response = new GetDashboardForJobRunResponse();
response.setUrl(dashboards.url(regionResolver.getAccountId(), regionResolver.getRegion(), applicationId,
jobRunId, run.getAttempt() != null ? run.getAttempt() : 1));
response.setUrl(appUis.jobRunUrl(applicationId, jobRunId, run.getAttempt() != null ? run.getAttempt() : 1));
return response;
}
@@ -294,7 +289,7 @@ public class EmrServerlessController {
}
/**
* The link to a session's application UI ({@link EmrServerlessDashboards}). {@code accessSystemProfileLogs} is for
* The link to a session's application UI ({@link EmrServerlessAppUis}). {@code accessSystemProfileLogs} is for
* sessions on Lake Formation, which Floci runs none of, so it changes nothing.
*/
@GET
@@ -304,8 +299,7 @@ public class EmrServerlessController {
@QueryParam("resourceType") String resourceType) {
Session session = sessions.dashboardResource(applicationId, resourceId, resourceType);
GetResourceDashboardResponse response = new GetResourceDashboardResponse();
response.setUrl(dashboards.sessionUrl(regionResolver.getAccountId(), regionResolver.getRegion(),
applicationId, session.getSessionId()));
response.setUrl(appUis.sessionUrl(applicationId, session));
return response;
}
}
@@ -18,11 +18,12 @@ import java.util.ArrayList;
import java.util.List;
/**
* The page a {@code GetDashboardForJobRun} or {@code GetResourceDashboard} link opens
* ({@link EmrServerlessDashboards}). EMR Serverless opens the run's live Spark or Tez UI while it runs and its Spark
* History Server or persistent Tez UI once it has ended, and a session's live Spark UI or Spark History Server
* likewise; Floci keeps neither, so the page shows the attempt as GetJobRun gives it and where its driver's logs go, as
* it was admitted, or the session as GetSession gives it. A link that is not one of this process's, or whose hour has
* The page a {@code GetDashboardForJobRun} or {@code GetResourceDashboard} link opens where it opens no live Spark UI
* ({@link EmrServerlessAppUis}, {@link EmrServerlessDashboards}). EMR Serverless opens the run's live Spark or Tez UI
* while it runs and its Spark History Server or persistent Tez UI once it has ended, and a session's live Spark UI or
* Spark History Server likewise; Floci opens a live Spark UI only in the docker runner mode, so elsewhere the page
* shows the attempt as GetJobRun gives it and where its driver's logs go, as it was admitted, or the session as
* GetSession gives it. A link that is not one of this process's, or whose hour has
* passed, opens a refusal instead, and so does one whose run or session has gone. Like the rest of Floci the page takes
* no AWS credentials: the link is all it asks for.
*/
@@ -32,10 +33,12 @@ public class EmrServerlessDashboardController {
// No source gives AWS's wording for these; they are Floci's.
static final String INVALID = "This dashboard link is not valid, or its hour has passed. Call"
+ " GetDashboardForJobRun or GetResourceDashboard for a new one.";
static final String NO_UI = "Floci keeps no Spark UI, Tez UI or Spark History Server for a job run, so this page"
static final String NO_UI = "Floci opens a job run's live Spark UI only while a Spark run runs in the docker"
+ " runner mode with its logs in managed storage, and keeps no Tez UI or Spark History Server, so this page"
+ " stands in for the application UI EMR Serverless opens. The driver's output is in its logs.";
static final String NO_SESSION_UI = "Floci keeps no Spark UI or Spark History Server for a session, and runs no"
+ " Spark driver for one, so this page stands in for the application UI EMR Serverless opens.";
static final String NO_SESSION_UI = "Floci opens a session's live Spark UI only while its Spark Connect server runs"
+ " in the docker runner mode, and keeps no Spark History Server, so this page stands in for the"
+ " application UI EMR Serverless opens.";
private final EmrServerlessDashboards dashboards;
private final EmrServerlessJobRunService jobRuns;
@@ -99,6 +102,7 @@ public class EmrServerlessDashboardController {
Html.row(lines, "Driver logs in CloudWatch Logs", view.logs().logGroup());
Html.row(lines, "Driver stdout stream", view.logs().stdoutStream());
Html.row(lines, "Driver stderr stream", view.logs().stderrStream());
Html.row(lines, "Logs in managed storage", view.logs().inManagedStorage() ? "Yes" : "No");
lines.add("</table>");
lines.add("<p>" + Html.escape(NO_UI) + "</p>");
return lines;
@@ -12,9 +12,9 @@ import java.time.Duration;
/**
* The links {@code GetDashboardForJobRun} gives, "a URL that you can use to access the application UIs for a job run",
* and {@code GetResourceDashboard} gives for a session. Each "is valid for one hour after you generate it. To access
* the application UI after that hour elapses, you must invoke the API again to generate a new URL." Floci keeps no
* Spark UI or Spark History Server for a run or a session, so a link opens a page of Floci's own about it
* and {@code GetResourceDashboard} gives for a session, where they open no live Spark UI ({@link EmrServerlessAppUis}).
* Each "is valid for one hour after you generate it. To access the application UI after that hour elapses, you must
* invoke the API again to generate a new URL." Such a link opens a page of Floci's own about the run or the session
* ({@link EmrServerlessDashboardController}). It names the account, Region, application, the run and its attempt or
* the session, and when it expires, signed with a key this process makes: a link changed, or past its hour, opens
* nothing, and the links given before a restart open nothing after it.
@@ -99,6 +99,7 @@ public class EmrServerlessJobRunService implements Resettable {
private static final String SPARK_CONNECT_ADDRESS = "spark.connect.grpc.binding.address";
private static final String S3_MONITORING = "s3MonitoringConfiguration";
private static final String CLOUD_WATCH_LOGGING = "cloudWatchLoggingConfiguration";
private static final String MANAGED_PERSISTENCE = "managedPersistenceMonitoringConfiguration";
// "If you don't specify the optional values, then CloudWatch publishes the logs to a default log group".
private static final String DEFAULT_LOG_GROUP = "/aws/emr-serverless";
private static final String SPARK_DRIVER = "SPARK_DRIVER";
@@ -347,6 +348,11 @@ public class EmrServerlessJobRunService implements Resettable {
if (logs == null) {
// A run stored before Floci kept its attempts' destinations: where its application now sends them.
logs = driverLogDestinations(applications.getApplication(applicationId), run);
} else if (logs.managedStorage() == null) {
// An attempt stored before Floci kept whether its logs were in managed storage: as the run's own
// configuration says, or else as its application's now does.
logs = new DriverLogDestinations(logs.s3Folder(), logs.logGroup(), logs.stdoutStream(),
logs.stderrStream(), managedStorage(applications.getApplication(applicationId), run));
}
return new DashboardView(run, logs);
}
@@ -614,7 +620,19 @@ public class EmrServerlessJobRunService implements Resettable {
SparkJobRunner.CloudWatchLogs cloudWatch = driverCloudWatchLogs(app, run);
return new DriverLogDestinations(driverLogFolder(app, run), cloudWatch != null ? cloudWatch.logGroup() : null,
cloudWatch != null ? cloudWatch.stdoutStream() : null,
cloudWatch != null ? cloudWatch.stderrStream() : null);
cloudWatch != null ? cloudWatch.stderrStream() : null, managedStorage(app, run));
}
/**
* Whether a run's logs are kept in EMR Serverless's managed storage: its {@code
* managedPersistenceMonitoringConfiguration}, or else its application's, "Enables managed logging and defaults to
* true. If set to false, managed logging will be turned off." Its application UIs need it: with logs in an S3
* bucket alone, the application UI is "Not supported", and "Otherwise, you can't use the built-in application UIs"
* (EMR Serverless user guide, "Storing logs").
*/
static boolean managedStorage(Application app, JobRun run) {
return !(monitoring(app, run, MANAGED_PERSISTENCE) instanceof Map<?, ?> configuration
&& Boolean.FALSE.equals(configuration.get("enabled")));
}
// Where the run's latest attempt sends its driver's logs, as it was admitted.
@@ -680,6 +698,14 @@ public class EmrServerlessJobRunService implements Resettable {
return sparkRunner;
}
/**
* Whether the drivers of its Spark runs and sessions serve their Spark UI for Floci to open: in the docker runner
* mode, on a network where a container has an address of its own.
*/
boolean servesDriverUis() {
return sparkRunner != null && sparkRunner.servesDriverUis(dockerNetwork);
}
/**
* What runs a session's Spark Connect server in a container, as a run's driver runs: in the application's image,
* on its network, with the session's execution role and its executors as a run's are, for {@code limit} at most.
@@ -1357,7 +1383,7 @@ public class EmrServerlessJobRunService implements Resettable {
return regionResolver.getRegion().equals(AwsArnUtils.parse(run.getArn()).region());
}
private static boolean isTerminal(JobRun run) {
static boolean isTerminal(JobRun run) {
return TERMINAL_STATES.contains(run.getState());
}
@@ -480,6 +480,8 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
private final ContainerLaunches launches = new ContainerLaunches();
// What the workers of each application's runs with executors of their own hold, by application, while any runs.
private final Map<String, SparkExecutors.Capacity> capacities = new ConcurrentHashMap<>();
// Where Floci reaches the Spark UI of each EMR Serverless Spark run's driver, by run, while its container runs.
private final Map<String, ContainerLifecycleManager.EndpointInfo> driverUis = new ConcurrentHashMap<>();
private final ContainerBuilder containerBuilder;
private final ContainerLifecycleManager lifecycleManager;
@@ -521,7 +523,8 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
@Override
public Outcome run(Job given, Progress progress) {
String network = containerBuilder.resolveDockerNetwork(Optional.ofNullable(given.dockerNetwork())).orElse(null);
Job job = executorsApart(given, network) ? given : given.withExecutors(null);
// On the network it resolves to, which tells whether its executors run apart and its driver serves its UI.
Job job = (executorsApart(given, network) ? given : given.withExecutors(null)).onNetwork(network);
ContainerLaunches.Launch launch = launches.begin(job.runId());
Optional<SessionCreds> credentials = Optional.empty();
Closeable logHandle = null;
@@ -630,6 +633,9 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
// Reached through Floci alone, so published on the host's loopback interface only.
container.withLoopbackPortBinding(job.listenPort(), 0);
}
if (servesDriverUi(job)) {
container.withLoopbackPortBinding(SparkExecutors.DRIVER_UI_PORT, 0);
}
ContainerSpec spec = container
.withDockerNetwork(Optional.ofNullable(job.dockerNetwork()))
.withHostDockerInternalOnLinux()
@@ -662,6 +668,12 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
}
ContainerLifecycleManager.ContainerInfo info = lifecycleManager.startCreated(containerId, spec);
logHandle = attachLog(containerId, job);
// Found before the run is told it runs, so that a link to its UI then finds it.
ContainerLifecycleManager.EndpointInfo driverUi = servesDriverUi(job)
? info.getEndpoint(SparkExecutors.DRIVER_UI_PORT) : null;
if (driverUi != null) {
driverUis.put(job.runId(), driverUi);
}
progress.started();
if (job.listenPort() > 0) {
ContainerLifecycleManager.EndpointInfo listening = info.getEndpoint(job.listenPort());
@@ -690,6 +702,7 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
LOG.warnv(e, "Spark run {0} of {1} could not run", job.runId(), job.service());
return Outcome.couldNotStart(e.getMessage());
} finally {
driverUis.remove(job.runId());
// The executors go with their driver, however the run ended, and their workers' share of the
// application's capacity with them.
if (executors != null) {
@@ -709,6 +722,28 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
}
}
@Override
public Optional<ContainerLifecycleManager.EndpointInfo> driverUi(String runId) {
return Optional.ofNullable(driverUis.get(runId));
}
@Override
public boolean servesDriverUis(String dockerNetwork) {
return ownNetwork(containerBuilder.resolveDockerNetwork(Optional.ofNullable(dockerNetwork)).orElse(null));
}
/**
* Whether a job's driver serves its Spark UI for Floci to open: an EMR Serverless Spark run's or session's, which
* GetDashboardForJobRun and GetResourceDashboard link to while it runs, on a network where its container has an
* address of its own, as on the host's network every driver's UI would be on the host's port. The release's image
* turns the UI off ({@code spark.ui.enabled false} in its {@code spark-defaults}); a run's own settings may still
* do so.
*/
static boolean servesDriverUi(Job job) {
return EmrServerlessJobRunService.SERVICE.equals(job.service()) && job.engine() == Engine.SPARK
&& ownNetwork(job.dockerNetwork());
}
@Override
public void stop(String runId) {
ContainerLaunches.Launch launch = launches.get(runId);
@@ -918,8 +953,12 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
*/
static boolean executorsApart(Job job, String network) {
return job.executors() != null && job.engine() == Engine.SPARK && job.command() == null
&& job.storage() == null && !"host".equals(network)
&& (network == null || !network.startsWith("container:"));
&& job.storage() == null && ownNetwork(network);
}
// Whether a container on the network has an address of its own, rather than the host's or another container's.
private static boolean ownNetwork(String network) {
return !"host".equals(network) && (network == null || !network.startsWith("container:"));
}
private static String newSecret() {
@@ -1616,10 +1655,15 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
if (onYarn(job)) {
settings.addAll(yarnSettings(job, executorEnvironment));
}
// The driver's UI, which Floci follows the driver through; its kill links, which any container on the network
// reaches, are turned off after the run's own settings (SparkExecutors.DRIVER_WRAPPER).
if (job.executors() != null) {
// The driver's UI, which a dashboard link opens, and which Floci follows a driver with executors of its own
// through. Its kill links, which any container on the network reaches, are off: for a driver with executors of
// its own, after the run's own settings (SparkExecutors.DRIVER_WRAPPER); for any other, unless the run turns
// them on.
if (servesDriverUi(job)) {
settings.add(new SparkSetting("spark.ui.enabled", "true"));
if (job.executors() == null) {
settings.add(new SparkSetting("spark.ui.killEnabled", "false"));
}
}
job.sparkDefaults().forEach((key, value) -> settings.add(new SparkSetting(key, value)));
return settings;
@@ -1,8 +1,11 @@
package io.floci.aws.services.emrserverless;
import io.floci.aws.core.common.docker.ContainerLifecycleManager;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* Runs a Spark application, or a Hive query, to its end, in the EMR services' {@code docker} runner mode: an
@@ -25,6 +28,22 @@ public interface SparkJobRunner {
*/
void stop(String runId);
/**
* Where Floci reaches the Spark UI of run {@code runId}'s driver while its container runs, for an EMR Serverless
* Spark run or session; empty for any other run, and before or after its container runs.
*/
default Optional<ContainerLifecycleManager.EndpointInfo> driverUi(String runId) {
return Optional.empty();
}
/**
* Whether the drivers of EMR Serverless Spark runs and sessions on {@code dockerNetwork} (null for the default)
* serve their Spark UI for Floci to open ({@link #driverUi}).
*/
default boolean servesDriverUis(String dockerNetwork) {
return false;
}
/**
* Removes the drivers of {@code service}'s runs an earlier Floci process left running, which no thread
* follows any more. The service calls it before any run of its own can start.
@@ -184,6 +203,14 @@ public interface SparkJobRunner {
hadoopEnvironment, executors, platform, port);
}
/** This job, its containers on {@code network} (null for the global default). */
public Job onNetwork(String network) {
return new Job(service, runId, accountId, region, releaseLabel, engine, imageTemplate, customImage,
network, executionRole, sparkDefaults, application, command, timeout, logFolder, cloudWatchLogs,
environment, archives, storage, coreSite, sparkLog4j2, mapredSite, hadoopLog4j, hadoopEnvironment,
executors, platform, listenPort);
}
/** This job, its containers run for {@code platform} (null for the Docker host's own). */
public Job withPlatform(String platform) {
return new Job(service, runId, accountId, region, releaseLabel, engine, imageTemplate, customImage,
@@ -4,8 +4,16 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* Where one attempt of a run sends its driver's logs, as the attempt was admitted: an S3 folder, and a CloudWatch Logs
* group with the driver's two streams, each null where it sends none.
* group with the driver's two streams, each null where it sends none; and whether EMR Serverless keeps them in its
* managed storage, which its application UIs need, null for an attempt stored before Floci kept it, which its run's
* configuration then tells.
*/
@RegisterForReflection
public record DriverLogDestinations(String s3Folder, String logGroup, String stdoutStream, String stderrStream) {
public record DriverLogDestinations(String s3Folder, String logGroup, String stdoutStream, String stderrStream,
Boolean managedStorage) {
/** Whether the attempt's logs are kept in managed storage. */
public boolean inManagedStorage() {
return !Boolean.FALSE.equals(managedStorage);
}
}