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

Refactor: Extract and reuse get_kerberos_principle func from get_kerberos_principle #34936

Merged
merged 6 commits into from
Oct 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions airflow/security/kerberos.py
Expand Up @@ -47,6 +47,10 @@
log = logging.getLogger(__name__)


def get_kerberos_principle(principal: str | None) -> str:
return principal or conf.get_mandatory_value("kerberos", "principal").replace("_HOST", get_hostname())
uranusjr marked this conversation as resolved.
Show resolved Hide resolved


def renew_from_kt(principal: str | None, keytab: str, exit_on_fail: bool = True):
"""
Renew kerberos token from keytab.
Expand All @@ -59,10 +63,7 @@ def renew_from_kt(principal: str | None, keytab: str, exit_on_fail: bool = True)
# minutes to give ourselves a large renewal buffer.
renewal_lifetime = f"{conf.getint('kerberos', 'reinit_frequency')}m"

cmd_principal = principal or conf.get_mandatory_value("kerberos", "principal").replace(
"_HOST", get_hostname()
)

cmd_principal = get_kerberos_principle(principal)
if conf.getboolean("kerberos", "forwardable"):
forwardable = "-f"
else:
Expand Down