From cf1278c9ca6390fbafe7db94c2d89e6bec172a02 Mon Sep 17 00:00:00 2001 From: Niko Oliveira Date: Wed, 10 Jul 2024 13:35:08 -0700 Subject: [PATCH] Use correct unknown executor exception in scheduler job (#40700) 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 --- airflow/jobs/scheduler_job_runner.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/airflow/jobs/scheduler_job_runner.py b/airflow/jobs/scheduler_job_runner.py index 27076d8e0d96a..1d49f412b0d7f 100644 --- a/airflow/jobs/scheduler_job_runner.py +++ b/airflow/jobs/scheduler_job_runner.py @@ -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 @@ -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