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

fix: scheduler and triggerer probe performance for airflow <2.6.0 #853

Merged
Show file tree
Hide file tree
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
16 changes: 2 additions & 14 deletions charts/airflow/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,9 @@ spec:
from airflow.utils.db import create_session
from airflow.utils.net import get_hostname

# heartbeat check imports
try:
from airflow.jobs.scheduler_job_runner import SchedulerJobRunner
except ImportError:
# `SchedulerJob` is wrapped by `SchedulerJobRunner` since airflow 2.6.0
from airflow.jobs.scheduler_job import SchedulerJob as SchedulerJobRunner

{{- if .Values.scheduler.livenessProbe.taskCreationCheck.enabled }}
{{ "" }}
# task creation check imports
try:
from airflow.jobs.local_task_job_runner import LocalTaskJobRunner
except ImportError:
# `LocalTaskJob` is wrapped by `LocalTaskJobRunner` since airflow 2.6.0
from airflow.jobs.local_task_job import LocalTaskJob as LocalTaskJobRunner
from airflow.utils import timezone
{{- end }}

Expand All @@ -175,7 +163,7 @@ spec:
hostname = get_hostname()
scheduler_job = session \
.query(Job) \
.filter_by(job_type=SchedulerJobRunner.job_type) \
.filter_by(job_type="SchedulerJob") \
.filter_by(hostname=hostname) \
.order_by(Job.latest_heartbeat.desc()) \
.limit(1) \
Expand Down Expand Up @@ -204,7 +192,7 @@ spec:
task_job_threshold = {{ $task_job_threshold }}
task_job = session \
.query(Job) \
.filter_by(job_type=LocalTaskJobRunner.job_type) \
.filter_by(job_type="LocalTaskJob") \
.order_by(Job.id.desc()) \
.limit(1) \
.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,12 @@ spec:
from airflow.utils.db import create_session
from airflow.utils.net import get_hostname

# heartbeat check imports
try:
from airflow.jobs.triggerer_job_runner import TriggererJobRunner
except ImportError:
# `TriggererJob` is wrapped by `TriggererJobRunner` since airflow 2.6.0
from airflow.jobs.triggerer_job import TriggererJob as TriggererJobRunner

with create_session() as session:
# ensure the TriggererJob with most recent heartbeat for this `hostname` is alive
hostname = get_hostname()
triggerer_job = session \
.query(Job) \
.filter_by(job_type=TriggererJobRunner.job_type) \
.filter_by(job_type="TriggererJob") \
.filter_by(hostname=hostname) \
.order_by(Job.latest_heartbeat.desc()) \
.limit(1) \
Expand Down
Loading