Skip to content

Commit 48644d0

Browse files
spark: ship UnitestKMS via slim repackaged jar (full -tests.jar shadowed hadoop-aws S3ABlockOutputStream)
1 parent 807a963 commit 48644d0

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

dev/spark/Dockerfile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ RUN set -e && \
5050
for jar_path in \
5151
"org/apache/iceberg/iceberg-spark-runtime-${ICEBERG_SPARK_RUNTIME_VERSION}/${ICEBERG_VERSION}/iceberg-spark-runtime-${ICEBERG_SPARK_RUNTIME_VERSION}-${ICEBERG_VERSION}.jar" \
5252
"org/apache/iceberg/iceberg-aws-bundle/${ICEBERG_VERSION}/iceberg-aws-bundle-${ICEBERG_VERSION}.jar" \
53-
"org/apache/iceberg/iceberg-core/${ICEBERG_VERSION}/iceberg-core-${ICEBERG_VERSION}-tests.jar" \
5453
"org/apache/hadoop/hadoop-aws/${HADOOP_VERSION}/hadoop-aws-${HADOOP_VERSION}.jar" \
5554
"org/apache/hadoop/hadoop-client-api/${HADOOP_VERSION}/hadoop-client-api-${HADOOP_VERSION}.jar" \
5655
"org/apache/hadoop/hadoop-client-runtime/${HADOOP_VERSION}/hadoop-client-runtime-${HADOOP_VERSION}.jar" \
@@ -63,6 +62,24 @@ RUN set -e && \
6362
chown spark:spark "${jar_name}"; \
6463
done
6564

65+
# Pull UnitestKMS + MemoryMockKMS out of iceberg-core's -tests.jar into a slim jar that only
66+
# ships those two classes. The full -tests.jar contains testing stubs for unrelated classes
67+
# (e.g. a stub S3ABlockOutputStream that lacks builder()) which would shadow the real ones in
68+
# hadoop-aws and break Spark's S3A writes; this avoids that classpath collision.
69+
RUN set -e && \
70+
tmp="$(mktemp -d)" && cd "${tmp}" && \
71+
curl -fsSL --retry 3 --retry-delay 5 \
72+
-o iceberg-core-tests.jar \
73+
"${MAVEN_MIRROR}/org/apache/iceberg/iceberg-core/${ICEBERG_VERSION}/iceberg-core-${ICEBERG_VERSION}-tests.jar" && \
74+
/opt/java/openjdk/bin/jar xf iceberg-core-tests.jar \
75+
org/apache/iceberg/encryption/UnitestKMS.class \
76+
org/apache/iceberg/encryption/MemoryMockKMS.class && \
77+
/opt/java/openjdk/bin/jar cf "${SPARK_HOME}/jars/iceberg-core-${ICEBERG_VERSION}-tests-kms-only.jar" \
78+
org/apache/iceberg/encryption/UnitestKMS.class \
79+
org/apache/iceberg/encryption/MemoryMockKMS.class && \
80+
chown spark:spark "${SPARK_HOME}/jars/iceberg-core-${ICEBERG_VERSION}-tests-kms-only.jar" && \
81+
rm -rf "${tmp}"
82+
6683
# Copy configuration last (changes more frequently than JARs)
6784
COPY --chown=spark:spark spark-defaults.conf ${SPARK_HOME}/conf/
6885

0 commit comments

Comments
 (0)