mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(emr): give Hive one AWS SDK on emr-6.x images (#7921)
A Hive step or an EMR Serverless Hive run on a table in S3 failed on emr-6.15.0 with NoSuchFieldError: AWS_S3_DISABLE_EXPRESS_SESSION_AUTH as soon as S3A built its client. Those images' Hive lib folder has the stock AWS SDK v2 modules, and the S3 client is only in Tez's plug-in, EMR's own build of the SDK, later on the class path, so that client ran on the stock sdk-core. The modules the plug-in also holds now go, by name, before Hive starts, while the container is still root: in a Hive run's wrapper, and in the primary node's script, as the metastore service opens a table's S3 location with S3A too. An image with no loose sdk-core, as emr-7.5.0 and emr-7.10.0 have, or without the plug-in keeps every jar.
This commit is contained in:
1 parent
9eb3ba38ed
commit
173141c5f2
4 files changed
+74
No files matched your search
@@ -28,6 +28,7 @@ import io.floci.aws.core.common.docker.ContainerSpec;
|
||||
import io.floci.aws.core.common.docker.ContainerStorageHelper;
|
||||
import io.floci.aws.core.common.docker.CurrentContainerNetworkResolver;
|
||||
import io.floci.aws.core.common.docker.LaunchedContainerAwsEnv;
|
||||
import io.floci.aws.services.emrserverless.EmrServerlessSparkRunner;
|
||||
import io.floci.aws.services.emrserverless.SparkJobRunner;
|
||||
import io.floci.aws.services.iam.model.SessionCreds;
|
||||
import io.floci.aws.services.lambda.launcher.ImageCacheService;
|
||||
@@ -546,6 +547,11 @@ class EmrClusterStorageTest {
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "fi; if [ -n \"$FLOCI_YARN_MEMORY_MB\" ]; then")));
|
||||
|
||||
// A table's location in S3 is the metastore's to look at, with S3A, so it too leaves Hive one SDK first, as
|
||||
// root, which owns Hive's lib folder.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(
|
||||
"chown hadoop:hadoop /mnt || exit\n" + EmrServerlessSparkRunner.HIVE_ONE_SDK + "\n")));
|
||||
|
||||
// The session goes with the container.
|
||||
storage.remove("j-1");
|
||||
verify(roleCredentials).unregister("123456789012", "ASIAMETASTORE");
|
||||
|
||||
@@ -49,6 +49,7 @@ import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -215,6 +216,8 @@ class EmrServerlessSparkRunnerTest {
|
||||
verify(spec).withEntrypoint(argThat((List<String> entrypoint) -> entrypoint.size() == 5
|
||||
&& List.of("/bin/bash", "-c").equals(entrypoint.subList(0, 2))
|
||||
&& entrypoint.get(2).contains("setpriv --reuid=hadoop --regid=hadoop --clear-groups \"$@\"")
|
||||
// While it is still root, which owns Hive's lib folder.
|
||||
&& entrypoint.get(2).contains(EmrServerlessSparkRunner.HIVE_ONE_SDK + "\nexport HOME=~hadoop\n")
|
||||
&& List.of("floci", "/usr/bin/hive").equals(entrypoint.subList(3, 5))));
|
||||
verify(spec).withCmd(argThat((List<String> cmd) -> "--hiveconf".equals(cmd.getFirst())
|
||||
&& List.of("-f", "s3://bucket/queries/report.sql").equals(cmd.subList(cmd.size() - 2, cmd.size()))));
|
||||
@@ -1062,6 +1065,56 @@ class EmrServerlessSparkRunnerTest {
|
||||
assertFalse(Files.exists(folder.resolve("ran")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEmr6HiveImageKeepsOneSdkWithCloudWatchsModulesAndWhatIsNotTheSdk(@TempDir Path folder) throws Exception {
|
||||
List<String> kept = List.of("auth-2.19.0.jar", "cloudwatch-2.20.160.jar",
|
||||
"cloudwatch-metric-publisher-2.20.160.jar", "guava-31.1-jre.jar", "hive-exec-3.1.3-amzn-8.jar",
|
||||
"my-library-2.20.160.jar");
|
||||
List<String> jars = new ArrayList<>(kept);
|
||||
for (String module : List.of("annotations", "apache-client", "auth", "aws-core", "aws-json-protocol",
|
||||
"aws-query-protocol", "endpoints-spi", "http-client-spi", "json-utils", "metrics-spi",
|
||||
"netty-nio-client", "profiles", "protocol-core", "regions", "sdk-core", "third-party-jackson-core",
|
||||
"utils")) {
|
||||
jars.add(module + "-2.20.160.jar");
|
||||
}
|
||||
|
||||
assertEquals(kept, hiveLibAfterOneSdk(folder, true, jars.toArray(String[]::new)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anImageWithoutStockSdkModulesKeepsEveryJar(@TempDir Path folder) throws Exception {
|
||||
List<String> jars = List.of("commons-math-2.2.jar", "guava-31.1-jre.jar", "hive-exec-3.1.3-amzn-14.jar");
|
||||
|
||||
assertEquals(jars, hiveLibAfterOneSdk(folder, true, jars.toArray(String[]::new)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anImageWithoutTezsPluginKeepsItsOnlySdk(@TempDir Path folder) throws Exception {
|
||||
List<String> jars = List.of("aws-core-2.20.160.jar", "sdk-core-2.20.160.jar");
|
||||
|
||||
assertEquals(jars, hiveLibAfterOneSdk(folder, false, jars.toArray(String[]::new)));
|
||||
}
|
||||
|
||||
/** What is left of a Hive lib folder holding {@code jars} once the shell has run, by name. */
|
||||
private static List<String> hiveLibAfterOneSdk(Path folder, boolean plugin, String... jars) throws Exception {
|
||||
Path lib = Files.createDirectories(folder.resolve("hive/lib"));
|
||||
Path tez = Files.createDirectories(folder.resolve("tez"));
|
||||
for (String jar : jars) {
|
||||
Files.createFile(lib.resolve(jar));
|
||||
}
|
||||
if (plugin) {
|
||||
Files.createFile(tez.resolve("tez-emr-serverless.jar"));
|
||||
}
|
||||
String script = EmrServerlessSparkRunner.HIVE_ONE_SDK.replace("/usr/lib/hive/lib", lib.toString())
|
||||
.replace("/usr/lib/tez", tez.toString());
|
||||
|
||||
BootstrapProcess.run(new ProcessBuilder("bash", "-c", script).directory(folder.toFile()));
|
||||
|
||||
try (Stream<Path> left = Files.list(lib)) {
|
||||
return left.map(path -> path.getFileName().toString()).sorted().toList();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void log4j2LinesReachLog4jAsTheClusterGaveThem() throws IOException {
|
||||
Map<String, String> sparkLog4j2 = new LinkedHashMap<>();
|
||||
|
||||
Reference in new issue
Block a user