Skip to content

Commit 3cc3ee4

Browse files
committed
[DOP-25451] Fix Hive and HDFS connector ignoring user & password
1 parent 59ad3c6 commit 3cc3ee4

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

docker/Dockerfile.worker

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,13 @@ RUN --mount=type=cache,target=/root/.cache/pypoetry \
6666
--without docs,dev \
6767
&& python -m compileall -j 4 .venv
6868

69-
RUN sed -i 's/python -m/coverage run -m/g' /app/entrypoint.sh
7069
ENV SYNCMASTER__WORKER__CREATE_SPARK_SESSION_FUNCTION=tests.spark.get_worker_spark_session
70+
71+
# Collect coverage from worker
72+
RUN sed -i 's/python -m/coverage run -m/g' /app/entrypoint.sh
73+
74+
# Replace kinit binary with dummy, to skip Kerberos interaction in tests
75+
RUN mkdir -p /app/.local/bin && \
76+
echo "#!/bin/bash" > /app/.local/bin/kinit \
77+
&& chmod +x /app/.local/bin/kinit
78+
ENV PATH="/app/.local/bin:$PATH"

docs/changelog/0.2.2.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
0.2.2 (2025-04-11)
2+
==================
3+
4+
Bug fixes
5+
---------
6+
7+
- Call ``kinit`` before starting Spark session conecting to ``Hive`` cluster.
8+
- Fix ``HDFS`` connection was trying to use anonymous auth instead of user/password.

docs/changelog/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
:caption: Changelog
44

55
DRAFT
6+
0.2.2
67
0.2.1
78
0.2.0
89
0.1.5

syncmaster/worker/handlers/file/hdfs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ def connect(self, spark: SparkSession):
2525

2626
self.file_connection = HDFS(
2727
cluster=self.connection_dto.cluster,
28+
user=self.connection_dto.user,
29+
password=self.connection_dto.password,
2830
).check()

syncmaster/worker/spark.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
import math
77
from typing import TYPE_CHECKING
88

9+
from onetl.connection.kerberos_helpers import kinit_password
10+
911
from syncmaster.db.models import Run
10-
from syncmaster.dto.connections import ConnectionDTO
12+
from syncmaster.dto.connections import (
13+
ConnectionDTO,
14+
HDFSConnectionDTO,
15+
HiveConnectionDTO,
16+
)
1117

1218
if TYPE_CHECKING:
1319
from pyspark.sql import SparkSession
@@ -33,6 +39,10 @@ def get_worker_spark_session(
3339
log.debug("Enabling Hive support")
3440
spark_builder = spark_builder.enableHiveSupport()
3541

42+
for entity in source, target: # type: ignore
43+
if isinstance(entity, (HiveConnectionDTO, HDFSConnectionDTO)) and entity.user and entity.password: # type: ignore
44+
kinit_password(entity.user, entity.password)
45+
3646
return spark_builder.getOrCreate()
3747

3848

0 commit comments

Comments
 (0)