Skip to content

Commit

Permalink
The function resolve_kerberos_principal updated when airflow version …
Browse files Browse the repository at this point in the history
…2.8 and above (apache#42777)
  • Loading branch information
dirrao authored Oct 7, 2024
1 parent 9ba45b6 commit 49e7926
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions airflow/providers/apache/spark/hooks/spark_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,25 +517,10 @@ def _build_track_driver_status_command(self) -> list[str]:
return connection_cmd

def _resolve_kerberos_principal(self, principal: str | None) -> str:
"""
Resolve kerberos principal if airflow > 2.8.
TODO: delete when min airflow version >= 2.8 and import directly from airflow.security.kerberos
"""
from packaging.version import Version

from airflow.version import version

if Version(version) < Version("2.8"):
from airflow.utils.net import get_hostname

return principal or airflow_conf.get_mandatory_value("kerberos", "principal").replace(
"_HOST", get_hostname()
)
else:
from airflow.security.kerberos import get_kerberos_principle
"""Resolve kerberos principal."""
from airflow.security.kerberos import get_kerberos_principle

return get_kerberos_principle(principal)
return get_kerberos_principle(principal)

def submit(self, application: str = "", **kwargs: Any) -> None:
"""
Expand Down

0 comments on commit 49e7926

Please sign in to comment.