@@ -140,11 +140,30 @@ spec:
140
140
os.environ["AIRFLOW__LOGGING__LOGGING_LEVEL"] = "ERROR"
141
141
{{- end }}
142
142
143
- from airflow.jobs.scheduler_job import SchedulerJob
143
+ # shared imports
144
+ try:
145
+ from airflow.jobs.job import Job
146
+ except ImportError:
147
+ # `BaseJob` was renamed to `Job` in airflow 2.6.0
148
+ from airflow.jobs.base_job import BaseJob as Job
144
149
from airflow.utils.db import create_session
145
150
from airflow.utils.net import get_hostname
151
+
152
+ # heartbeat check imports
153
+ try:
154
+ from airflow.jobs.scheduler_job_runner import SchedulerJobRunner
155
+ except ImportError:
156
+ # `SchedulerJob` is wrapped by `SchedulerJobRunner` since airflow 2.6.0
157
+ from airflow.jobs.scheduler_job import SchedulerJob as SchedulerJobRunner
158
+
146
159
{{- if .Values.scheduler.livenessProbe.taskCreationCheck.enabled }}
147
- from airflow.jobs.local_task_job import LocalTaskJob
160
+ {{ "" }}
161
+ # task creation check imports
162
+ try:
163
+ from airflow.jobs.local_task_job_runner import LocalTaskJobRunner
164
+ except ImportError:
165
+ # `LocalTaskJob` is wrapped by `LocalTaskJobRunner` since airflow 2.6.0
166
+ from airflow.jobs.local_task_job import LocalTaskJob as LocalTaskJobRunner
148
167
from airflow.utils import timezone
149
168
{{- end }}
150
169
@@ -155,9 +174,10 @@ spec:
155
174
# ensure the SchedulerJob with most recent heartbeat for this `hostname` is alive
156
175
hostname = get_hostname()
157
176
scheduler_job = session \
158
- .query(SchedulerJob) \
177
+ .query(Job) \
178
+ .filter_by(job_type=SchedulerJobRunner.job_type) \
159
179
.filter_by(hostname=hostname) \
160
- .order_by(SchedulerJob .latest_heartbeat.desc()) \
180
+ .order_by(Job .latest_heartbeat.desc()) \
161
181
.limit(1) \
162
182
.first()
163
183
if (scheduler_job is not None) and scheduler_job.is_alive():
@@ -183,8 +203,9 @@ spec:
183
203
# ensure the most recent LocalTaskJob had a start_date in the last `task_job_threshold` seconds
184
204
task_job_threshold = {{ $task_job_threshold }}
185
205
task_job = session \
186
- .query(LocalTaskJob) \
187
- .order_by(LocalTaskJob.id.desc()) \
206
+ .query(Job) \
207
+ .filter_by(job_type=LocalTaskJobRunner.job_type) \
208
+ .order_by(Job.id.desc()) \
188
209
.limit(1) \
189
210
.first()
190
211
if task_job is not None:
0 commit comments