Skip to content

Commit

Permalink
Use correct unknown executor exception in scheduler job (apache#40700)
Browse files Browse the repository at this point in the history
A new exception for unknown executors was in the backfill changes for
hybrid executors that was not present in the scheduler changes. Now that
they're both merged, update the scheduler job to use the new exception
  • Loading branch information
o-nikolas authored Jul 10, 2024
1 parent 23b9add commit cf1278c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions airflow/jobs/scheduler_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from airflow.callbacks.callback_requests import DagCallbackRequest, SlaCallbackRequest, TaskCallbackRequest
from airflow.callbacks.pipe_callback_sink import PipeCallbackSink
from airflow.configuration import conf
from airflow.exceptions import RemovedInAirflow3Warning
from airflow.exceptions import RemovedInAirflow3Warning, UnknownExecutorException
from airflow.executors.executor_loader import ExecutorLoader
from airflow.jobs.base_job_runner import BaseJobRunner
from airflow.jobs.job import Job, perform_heartbeat
Expand Down Expand Up @@ -1930,17 +1930,11 @@ def _try_to_load_executor(self, executor_name: str | None) -> BaseExecutor | Non
"""
try:
return ExecutorLoader.load_executor(executor_name)
except ValueError as e:
except UnknownExecutorException:
# This case should not happen unless some (as of now unknown) edge case occurs or direct DB
# modification, since the DAG parser will validate the tasks in the DAG and ensure the executor
# they request is available and if not, disallow the DAG to be scheduled.
# Keeping this exception handling because this is a critical issue if we do somehow find
# ourselves here and the user should get some feedback about that.
if "Unknown executor" in str(e):
self.log.warning(
"Executor, %s, was not found but a Task was configured to use it", executor_name
)
return None
else:
# Re-raise any other Exception not related to unknown executors.
raise
self.log.warning("Executor, %s, was not found but a Task was configured to use it", executor_name)
return None

0 comments on commit cf1278c

Please sign in to comment.