Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The spark hook resolve_kerberos_principal function code update when airflow version 2.8.0 and above #42777

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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