feat(emr-containers): run a managed endpoint's overridden kernels in containers of their own (#9293)

An endpoint's jupyter-kernel-overrides gives a kernel its own
container-image ("Custom kernel image with interactive endpoint"), and
on EMR on EKS each kernel is a pod of its image. A Floci endpoint ran
every kernel in its gateway's container, whatever image the overrides
named.

- The gateway job tells the gateway program which kernels the
  overrides give an image (python3 and spark-python-kubernetes, the
  kernels the guide's example names, as "You can't add new kernel image
  types"), where it asks Floci for their containers, and a secret Floci
  gives that gateway alone.
- EmrContainersKernelContainersRoute takes the gateway's POST and
  DELETE on /_aws/emr-containers/kernel-containers/<endpoint>/<kernel>.
  The service checks the secret, that the endpoint is ACTIVE and its
  overrides give the kernel an image, and the kernel id, response
  address and public key, then EmrContainersKernelContainers runs the
  kernel's container: the override image, with the gateway's settings
  and environment and the kernel's KERNEL_ variables, running the
  image's Jupyter Enterprise Gateway launcher (launch_ipykernel.py),
  under spark-submit with the %%configure magic for a PySpark kernel.
  A launch is admitted under the lock the gateway's end takes, so an
  endpoint's kernel containers all stop with its gateway, and a reset
  or Floci's shutdown stops every one.
- The gateway program gives such a kernel a jupyter_client provisioner
  that speaks the launcher's protocol: it asks Floci for the container
  with an RSA public key and a response address, decrypts the
  connection the launcher sends back (an AES key, under RSA, over
  AES-GCM), and polls, signals and stops the kernel through the
  launcher's comm port and Floci. It waits KERNEL_LAUNCH_TIMEOUT
  seconds, at most the guide's 400, or 400, and a launch that fails
  once the container was asked for stops it.
- Such a kernel's %%configure magic posts to its ENDPOINT_IP, the
  gateway, on port 9547 over TLS, with a certificate the image's openssl
  makes; the program checks it with the launcher's AES key, which each
  launch refreshes. Every restart, the kernels API's, the
  auto-restarter's or %%configure's, gives the kernel a new container
  with new ports and a new key, and the program moves the kernel's
  clients and its activity watch onto them.
- The nightly check gains a method: an endpoint that overrides both
  kernels with the release's own image runs each in its own container,
  the PySpark one counting an S3 file's lines and taking %%configure.
  The docker-runner group's budget grows by its eighteen minutes.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-23 15:32:02 -04:00
1 parent 8724146f3f
commit 0dd02aed44
10 files changed
+1143 -32

No files matched your search

@@ -59,7 +59,7 @@ import static org.junit.jupiter.api.Assertions.fail;
* JupyterLab notebook" does through {@code JUPYTER_GATEWAY_URL}, then changes its Spark session's settings with
* {@code %%configure}, as "Modifying PySpark session parameters" does, and runs code on Floci's S3 in the "Apache
* Spark with Scala" kernel too. An endpoint whose {@code jeg-config} sets a short idle timeout culls a kernel left
* idle.
* idle, and one whose {@code jupyter-kernel-overrides} gives its kernels an image runs each in a container of its own.
*
* <p>A nightly check: the release's notebook image is about 6 GB.
*/
@@ -234,6 +234,58 @@ class EmrContainersGatewayNightlyIntegrationTest {
.DELETE().build(), HttpResponse.BodyHandlers.discarding()).statusCode(), url);
}
// The endpoint's gateway answers within its five minutes; each kernel's container starts, and its WebSocket
// opens, within its two, and each of the four cells answers within its two: seventeen minutes, and one for the
// requests between. The Nightly checks' docker-runner group counts it.
@Test
@Timeout(value = 18, unit = TimeUnit.MINUTES)
void kernelsTheOverridesGiveAnImageRunInContainersOfTheirOwn() throws Exception {
S3Client s3 = AwsTestClients.create(S3Client.builder().forcePathStyle(true), ACCOUNT, Region.US_EAST_1);
cleanup.register(s3::close);
String bucket = "emr-eks-kernel-" + UUID.randomUUID().toString().substring(0, 8);
s3.createBucket(request -> request.bucket(bucket));
cleanup.register(() -> S3TestClients.deleteBucket(s3, bucket));
s3.putObject(request -> request.bucket(bucket).key("lines.txt"), RequestBody.fromString("a\nb\nc\n"));
String virtualClusterId = virtualCluster();
// As "Custom kernel image with interactive endpoint" overrides them, with the release's own image.
String endpointId = endpoint(virtualClusterId, """
{"applicationConfiguration": [{"classification": "jupyter-kernel-overrides", "configurations": [
{"classification": "python3", "properties": {"container-image": "%s"}},
{"classification": "spark-python-kubernetes", "properties": {"container-image": "%s"}}]}]}"""
.formatted(NOTEBOOK_IMAGE, NOTEBOOK_IMAGE));
String gateway = gateway(virtualClusterId, endpointId);
String token = sessionToken(virtualClusterId, endpointId);
HttpClient http = HttpClient.newHttpClient();
String session = UUID.randomUUID().toString();
String python = startKernel(http, gateway, token, "{\"name\": \"python3\"}");
assertEquals(1, docker.listContainersCmd().withNameFilter(List.of(python)).exec().size(),
"the kernel's own container");
Messages pythonMessages = new Messages();
WebSocket pythonSocket = connect(http, gateway, token, python, pythonMessages);
// Jupyter Enterprise Gateway's launcher gives the kernel its gateway's address.
assertEquals("True", execute(pythonSocket, pythonMessages, session,
"import os; os.environ.get('ENDPOINT_IP') is not None"));
pythonSocket.sendClose(WebSocket.NORMAL_CLOSURE, "done").get(10, TimeUnit.SECONDS);
delete(http, gateway + "/api/kernels/" + python, token);
await("the kernel's container gone").atMost(Duration.ofMinutes(1)).pollInterval(Duration.ofSeconds(1))
.until(() -> docker.listContainersCmd().withNameFilter(List.of(python)).exec().isEmpty());
String pyspark = startKernel(http, gateway, token, "{\"name\": \"spark-python-kubernetes\"}");
Messages messages = new Messages();
WebSocket socket = connect(http, gateway, token, pyspark, messages);
assertEquals("3", execute(socket, messages, session,
"spark.read.text(\"s3://" + bucket + "/lines.txt\").count()"));
// Its %%configure restarts it in a new container, under the same id, the client staying connected.
assertEquals("ok", run(socket, messages, session, """
%%configure -f
{"conf": {"spark.app.name": "from-configure"}}""", "execute_reply", "/content/status"));
assertEquals("'from-configure'", execute(socket, messages, session, "spark.conf.get(\"spark.app.name\")"));
assertEquals(List.of(pyspark), ids(http, gateway + "/api/kernels", token));
socket.sendClose(WebSocket.NORMAL_CLOSURE, "done").get(10, TimeUnit.SECONDS);
delete(http, gateway + "/api/kernels/" + pyspark, token);
}
// An endpoint of the virtual cluster with configurationOverrides, once it is ACTIVE.
private String endpoint(String virtualClusterId, String configurationOverrides) {
String endpointId = emr().body("""
@@ -245,9 +297,12 @@ class EmrContainersGatewayNightlyIntegrationTest {
.extract().path("id");
cleanup.register(() -> emr().delete("/virtualclusters/" + virtualClusterId + "/endpoints/" + endpointId)
.then().statusCode(200));
await().atMost(ACTIVE_TIMEOUT).pollInterval(Duration.ofSeconds(1)).until(() -> "ACTIVE".equals(
emr().get("/virtualclusters/" + virtualClusterId + "/endpoints/" + endpointId)
.then().statusCode(200).extract().path("endpoint.state")));
// ACTIVE once its gateway answers, or ended with errors where it cannot start, which stateDetails says.
JsonNode endpoint = await().atMost(ACTIVE_TIMEOUT).pollInterval(Duration.ofSeconds(1))
.until(() -> JSON.readTree(emr().get("/virtualclusters/" + virtualClusterId + "/endpoints/"
+ endpointId).then().statusCode(200).extract().asString()).path("endpoint"),
settled -> !"CREATING".equals(settled.path("state").textValue()));
assertEquals("ACTIVE", endpoint.path("state").textValue(), endpoint.toString());
return endpointId;
}
@@ -0,0 +1,124 @@
package io.floci.aws.services.emrcontainers;
import com.fasterxml.jackson.databind.JsonNode;
import io.floci.aws.core.common.ServiceConfigAccess;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.RequestOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Router;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Calls to {@link EmrContainersKernelContainersRoute}, as an endpoint's gateway makes them for its kernels' containers:
* a mock of the service stands behind it.
*/
class EmrContainersKernelContainersRouteTest {
private static final String ENDPOINT = "ep0123456789a";
private static final String KERNEL = "0b9e3c4e-6a1f-4c2d-9b8e-1f2a3b4c5d6e";
private static final String PATH = EmrContainersKernelContainersRoute.PATH + ENDPOINT + "/" + KERNEL;
private Vertx vertx;
private HttpServer floci;
private HttpClient client;
private EmrContainersService service;
@BeforeEach
void setUp() throws Exception {
vertx = Vertx.vertx();
service = mock(EmrContainersService.class);
ServiceConfigAccess serviceConfigAccess = mock(ServiceConfigAccess.class);
when(serviceConfigAccess.isEnabled(eq(EmrContainersService.SERVICE))).thenReturn(true);
Router router = Router.router(vertx);
// As Quarkus hands a route the request: paused.
router.route().handler(context -> {
context.request().pause();
context.next();
});
new EmrContainersKernelContainersRoute(service, serviceConfigAccess, vertx).register(router);
floci = await(vertx.createHttpServer().requestHandler(router).listen(0, "127.0.0.1"));
client = vertx.createHttpClient();
}
@AfterEach
void tearDown() throws Exception {
await(vertx.close());
}
@Test
void startGoesToTheServiceWithItsSecretAndBody() throws Exception {
Answer started = request(HttpMethod.POST, "a-secret", "{\"kernel\": \"python3\"}");
assertEquals(201, started.status);
ArgumentCaptor<JsonNode> body = ArgumentCaptor.forClass(JsonNode.class);
verify(service).startKernelContainer(eq(ENDPOINT), eq(KERNEL), eq("a-secret"), body.capture());
assertEquals("python3", body.getValue().path("kernel").textValue());
}
@Test
void refusalGivesItsStatusAndMessage() throws Exception {
when(service.startKernelContainer(anyString(), anyString(), any(), any())).thenReturn(
new EmrContainersService.KernelContainerRefusal(403, "not signed"));
when(service.stopKernelContainer(anyString(), anyString(), any())).thenReturn(
new EmrContainersService.KernelContainerRefusal(403, "not signed"));
Answer start = request(HttpMethod.POST, null, "{}");
Answer stop = request(HttpMethod.DELETE, null, null);
assertEquals(403, start.status);
assertEquals("not signed", new JsonObject(start.body).getString("message"));
assertEquals(403, stop.status);
}
@Test
void stopGoesToTheService() throws Exception {
Answer stopped = request(HttpMethod.DELETE, "a-secret", null);
assertEquals(204, stopped.status);
verify(service).stopKernelContainer(ENDPOINT, KERNEL, "a-secret");
}
@Test
void startWithoutAJsonObjectOrWithAnotherMethodIsRefused() throws Exception {
assertEquals(400, request(HttpMethod.POST, "a-secret", "not json").status);
assertEquals(400, request(HttpMethod.POST, "a-secret", "[]").status);
assertEquals(405, request(HttpMethod.GET, "a-secret", null).status);
}
private Answer request(HttpMethod method, String secret, String body) throws Exception {
RequestOptions options = new RequestOptions().setMethod(method).setHost("127.0.0.1")
.setPort(floci.actualPort()).setURI(PATH);
if (secret != null) {
options.addHeader(EmrContainersGateways.SECRET_HEADER, secret);
}
return await(client.request(options)
.compose(request -> body == null ? request.send() : request.send(Buffer.buffer(body)))
.compose(response -> response.body()
.map(read -> new Answer(response.statusCode(), read.toString()))));
}
private static <T> T await(Future<T> future) throws Exception {
return future.toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
}
private record Answer(int status, String body) {
}
}
@@ -0,0 +1,123 @@
package io.floci.aws.services.emrcontainers;
import io.floci.aws.services.emrserverless.SparkJobRunner;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/** The kernels' containers {@link EmrContainersKernelContainers} runs, read from its runner's side. */
class EmrContainersKernelContainersTest {
private static final String ENDPOINT = "ep0123456789a";
private static final String KERNEL = "0b9e3c4e-6a1f-4c2d-9b8e-1f2a3b4c5d6e";
private final Runner runner = new Runner();
private final EmrContainersKernelContainers kernels = new EmrContainersKernelContainers(runner,
task -> Thread.ofPlatform().daemon().start(task));
@Test
void secretIsTheGatewaysAlone() {
String secret = kernels.secretFor(ENDPOINT, "000000000000", "us-east-1");
assertNotNull(kernels.gateway(ENDPOINT, secret));
assertNull(kernels.gateway(ENDPOINT, secret + "0"));
assertNull(kernels.gateway(ENDPOINT, null));
assertNull(kernels.gateway("ep0000000000000", secret));
}
@Test
void launchOnceTheGatewayHasEndedRunsNothing() {
kernels.secretFor(ENDPOINT, "000000000000", "us-east-1");
kernels.stopAll(ENDPOINT);
// As a call whose secret was checked before the gateway ended reaches it after.
assertFalse(kernels.launch(ENDPOINT, KERNEL, job(kernels.runId(ENDPOINT, KERNEL))));
assertEquals(List.of(), runner.started);
}
@Test
void launchAgainStopsTheKernelsEarlierContainer() {
kernels.secretFor(ENDPOINT, "000000000000", "us-east-1");
String first = kernels.runId(ENDPOINT, KERNEL);
assertTrue(kernels.launch(ENDPOINT, KERNEL, job(first)));
awaitStarted(first);
assertTrue(kernels.launch(ENDPOINT, KERNEL, job(kernels.runId(ENDPOINT, KERNEL))));
assertEquals(Set.of(first), runner.stopped);
}
@Test
void resetStopsEveryKernelsContainerAndForgetsTheSecrets() {
String secret = kernels.secretFor(ENDPOINT, "000000000000", "us-east-1");
String runId = kernels.runId(ENDPOINT, KERNEL);
assertTrue(kernels.launch(ENDPOINT, KERNEL, job(runId)));
awaitStarted(runId);
kernels.reset();
assertEquals(Set.of(runId), runner.stopped);
assertNull(kernels.gateway(ENDPOINT, secret));
}
private void awaitStarted(String runId) {
await("run " + runId + " started").atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(10))
.until(() -> runner.started.contains(runId));
}
private static SparkJobRunner.Job job(String runId) {
return new SparkJobRunner.Job(EmrContainersService.SERVICE, runId, "000000000000", "us-east-1",
"emr-7.5.0-latest", SparkJobRunner.Engine.SPARK, null, null, null, null, Map.of(), List.of(),
List.of(), Duration.ZERO, null, null, Map.of(), List.of(), null, Map.of(), Map.of(), Map.of(),
Map.of(), Map.of(), null);
}
/** A runner that records the runs it starts, each running until it is stopped, and the runs it stops. */
private static final class Runner implements SparkJobRunner {
final List<String> started = new CopyOnWriteArrayList<>();
final Set<String> stopped = ConcurrentHashMap.newKeySet();
private final Map<String, CountDownLatch> ends = new ConcurrentHashMap<>();
@Override
public Outcome run(Job job, Progress progress) {
if (progress.cancelled()) {
return Outcome.halted();
}
started.add(job.runId());
try {
end(job.runId()).await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return Outcome.halted();
}
@Override
public void stop(String runId) {
stopped.add(runId);
end(runId).countDown();
}
private CountDownLatch end(String runId) {
return ends.computeIfAbsent(runId, id -> new CountDownLatch(1));
}
@Override
public void removeLeftoverDrivers(String service) {
}
}
}
@@ -42,6 +42,7 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
@@ -1297,6 +1298,7 @@ class EmrContainersServiceTest {
return new EmrContainersService(stores.get(0), stores.get(1), stores.get(2), stores.get(3), stores.get(4),
mapper, new RegionResolver(REGION, ACCOUNT_ID), eks, iam, null, clock, 0, runner, Runnable::run,
null, "floci-net", delays, new EmrContainersService.EndpointGateways(servers,
new EmrContainersKernelContainers(runner, task -> Thread.ofPlatform().daemon().start(task)),
"registry.internal/emr-on-eks/notebook-spark/%s", "http://floci.test:4566/"));
}
@@ -1419,6 +1421,117 @@ class EmrContainersServiceTest {
runner.stop(endpointId);
}
private static final String KERNEL = "0b9e3c4e-6a1f-4c2d-9b8e-1f2a3b4c5d6e";
// An endpoint whose jupyter-kernel-overrides gives both kernels the guide's example names an image, and the
// Scala kernel one, which it cannot override.
private String overriddenEndpoint(EmrContainersService service, String clusterId) {
return service.createManagedEndpoint(clusterId, json("""
{"name": "custom", "type": "JUPYTER_ENTERPRISE_GATEWAY", "releaseLabel": "%s",
"executionRoleArn": "%s", "clientToken": "%s",
"configurationOverrides": {"applicationConfiguration": [{
"classification": "jupyter-kernel-overrides", "configurations": [
{"classification": "python3",
"properties": {"container-image": "registry.internal/custom-notebook-python:latest"}},
{"classification": "spark-python-kubernetes",
"properties": {"container-image": "registry.internal/custom-notebook-spark:latest"}},
{"classification": "spark-scala-kubernetes",
"properties": {"container-image": "registry.internal/custom-notebook-scala:latest"}}]}]}}
""".formatted(RELEASE, ROLE, UUID.randomUUID()))).get("id").textValue();
}
// What the gateway sends to start a kernel's container.
private ObjectNode kernelStart(String kernel, String responseAddress) {
return json("""
{"kernel": "%s", "responseAddress": "%s", "publicKey": "cHVibGljLWtleQ==",
"env": {"KERNEL_EXTRA_SPARK_OPTS": "--conf spark.app.name=custom", "PATH": "/opt/elsewhere"}}
""".formatted(kernel, responseAddress));
}
@Test
void kernelTheOverridesGiveAnImageRunsInAContainerOfItAsItsGatewayAsks() {
GatewayRunner runner = new GatewayRunner();
EmrContainersService service = gatewayService(runner, stores());
String clusterId = virtualCluster(service, EKS_CLUSTER);
String endpointId = overriddenEndpoint(service, clusterId);
awaitEndpoint(service, clusterId, endpointId, "ACTIVE");
Map<String, String> gateway = runner.awaitJob(endpointId).environment();
// "You can't add new kernel image types": the Scala kernel's goes unnamed.
assertEquals("python3,spark-python-kubernetes", gateway.get(EmrContainersGateways.OVERRIDES_VARIABLE));
assertEquals(EmrContainersKernelContainersRoute.PATH + endpointId + "/",
gateway.get(EmrContainersGateways.KERNEL_CONTAINERS_VARIABLE));
String secret = gateway.get(EmrContainersGateways.SECRET_VARIABLE);
assertNull(service.startKernelContainer(endpointId, KERNEL, secret,
kernelStart("spark-python-kubernetes", "10.0.0.5:40000")));
SparkJobRunner.Job pyspark = runner.awaitJob(endpointId + "-" + KERNEL + "-1");
assertEquals("registry.internal/custom-notebook-spark:latest", pyspark.customImage());
assertTrue(pyspark.command().get(2).startsWith("exec \"$SPARK_HOME/bin/spark-submit\" $KERNEL_EXTRA_SPARK_OPTS "
+ EmrContainersGateways.LAUNCHER), pyspark.command().get(2));
assertEquals(List.of("kernel", KERNEL, "10.0.0.5:40000", "cHVibGljLWtleQ==",
"eyJjb25maWd1cmVfbWFnaWNfZW5hYmxlZCI6ICJ0cnVlIn0="),
pyspark.command().subList(3, pyspark.command().size()), "its launcher loads the %%configure magic");
assertEquals("--conf spark.app.name=custom", pyspark.environment().get("KERNEL_EXTRA_SPARK_OPTS"));
assertFalse(pyspark.environment().containsKey("PATH"), "a kernel's KERNEL_ variables alone");
assertFalse(pyspark.environment().containsKey(EmrContainersGateways.SECRET_VARIABLE));
assertEquals("false", pyspark.sparkDefaults().get(EmrContainersGateways.PYSPARK_VIRTUALENV));
assertEquals(ROLE, pyspark.executionRole());
assertEquals("floci-net", pyspark.dockerNetwork());
String python = "1b9e3c4e-6a1f-4c2d-9b8e-1f2a3b4c5d6e";
assertNull(service.startKernelContainer(endpointId, python, secret, kernelStart("python3", "10.0.0.5:40001")));
SparkJobRunner.Job python3 = runner.awaitJob(endpointId + "-" + python + "-2");
assertEquals("registry.internal/custom-notebook-python:latest", python3.customImage());
assertTrue(python3.command().get(2).startsWith("exec python3 " + EmrContainersGateways.LAUNCHER),
python3.command().get(2));
assertNull(service.stopKernelContainer(endpointId, KERNEL, secret));
assertTrue(runner.stopped.contains(pyspark.runId()));
runner.stop(endpointId);
// A kernel's container goes with its gateway, and the gateway's secret too.
await("the kernel's container stopped").atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(10))
.until(() -> runner.stopped.contains(python3.runId()));
assertEquals(403, service.startKernelContainer(endpointId, python, secret,
kernelStart("python3", "10.0.0.5:40001")).status());
}
@Test
void kernelContainerIsRefusedWithoutItsGatewaysSecretOrAKernelTheOverridesGiveAnImage() {
GatewayRunner runner = new GatewayRunner();
EmrContainersService service = gatewayService(runner, stores());
String clusterId = virtualCluster(service, EKS_CLUSTER);
String endpointId = overriddenEndpoint(service, clusterId);
awaitEndpoint(service, clusterId, endpointId, "ACTIVE");
String secret = runner.awaitJob(endpointId).environment().get(EmrContainersGateways.SECRET_VARIABLE);
ObjectNode start = kernelStart("python3", "10.0.0.5:40000");
assertEquals(403, service.startKernelContainer(endpointId, KERNEL, "not-the-secret", start).status());
assertEquals(403, service.startKernelContainer(endpointId, KERNEL, null, start).status());
assertEquals(403, service.stopKernelContainer(endpointId, KERNEL, "not-the-secret").status());
assertEquals(400, service.startKernelContainer(endpointId, KERNEL, secret,
kernelStart("spark-scala-kubernetes", "10.0.0.5:40000")).status(), "no image for it");
assertEquals(400, service.startKernelContainer(endpointId, KERNEL, secret,
kernelStart("python3", "10.0.0.5:40000 --kernel-id other")).status());
assertEquals(400, service.startKernelContainer(endpointId, "not-a-kernel", secret, start).status());
assertEquals(List.of(endpointId), runner.jobs.stream().map(SparkJobRunner.Job::runId).toList(),
"the gateway's alone");
runner.stop(endpointId);
}
@Test
void endpointWithoutOverridesGivesItsGatewayNoSecret() {
GatewayRunner runner = new GatewayRunner();
EmrContainersService service = gatewayService(runner, stores());
String clusterId = virtualCluster(service, EKS_CLUSTER);
String endpointId = gatewayEndpoint(service, clusterId);
awaitEndpoint(service, clusterId, endpointId, "ACTIVE");
Map<String, String> gateway = runner.awaitJob(endpointId).environment();
assertFalse(gateway.containsKey(EmrContainersGateways.OVERRIDES_VARIABLE));
assertFalse(gateway.containsKey(EmrContainersGateways.SECRET_VARIABLE));
runner.stop(endpointId);
}
@Test
void deletedDockerEndpointStopsItsGatewayAndItsTokensGo() {
GatewayRunner runner = new GatewayRunner();