fix(emr): give a step Trino's address only where Trino runs (#9551)

A step's trino-cli got FLOCI_TRINO_SERVER whenever the cluster had a Trino
image, including with docker-network host, container:<id> or none, where
the primary node runs no metastore and so no Trino. It now gets it only
where Floci's Trino runs, the same check the cluster's background start
and the outside host use.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-26 16:03:44 -04:00
1 parent c0a7bede5e
commit fae9d34ed8
2 files changed
+20 -1

No files matched your search

@@ -3199,7 +3199,7 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear
application != null ? application : List.of(), command, Duration.ZERO,
EmrSparkSteps.logFolder(cluster, step), null,
stepEnvironment(step, cluster, command != null && pig,
trinoImage(cluster) != null ? EmrTrino.server(masterPrivateDnsName(cluster),
runsTrino(cluster) ? EmrTrino.server(masterPrivateDnsName(cluster),
EmrTrino.port(EmrSparkSteps.trinoConfig(cluster.getConfigurations(),
SNAPSHOT_MAPPER))) : null),
List.of(),
@@ -1101,6 +1101,7 @@ class EmrServiceContainerStepsTest {
@Test
void aClusterWithFlocisTrinoRunsItBesideTheMetastoreWhereItsStepsTrinoCliReachesIt() {
fixture.clusterStorage.ownNetwork = true;
EmrService withTrino = fixture.withTrino();
EmrStep query = sparkStep("query", "CONTINUE");
List<String> args = List.of("trino-cli", "--execute", "SHOW CATALOGS");
@@ -1188,6 +1189,24 @@ class EmrServiceContainerStepsTest {
assertEquals(Optional.empty(), withTrino.trinoCluster(trinoId));
}
@Test
void onANetworkItsStepsShareTheirTrinoCliIsGivenNoCoordinatorAsNoneRunsThere() {
// docker-network host, container:<id> or none: the primary node runs no metastore, so no Trino.
fixture.clusterStorage.ownNetwork = false;
EmrService withTrino = fixture.withTrino();
EmrStep query = sparkStep("query", "CONTINUE");
query.setArgs(List.of("trino-cli", "--execute", "SHOW CATALOGS"));
EmrCluster requested = cluster("trino", true, query);
requested.setApplications(TRINO);
withTrino.runJobFlow(requested, REGION);
fixture.runStepThread();
assertFalse(runner.jobs.get(0).environment().containsKey("FLOCI_TRINO_SERVER"));
// Nor does the cluster start one as it becomes ready.
assertEquals(0, fixture.stepThreadsWaiting());
}
@Test
void aClusterWithTrinoRunsNoneWhileFlocisTrinoIsOff() {
EmrStep query = sparkStep("query", "CONTINUE");