uranusjr commented on code in PR #71214:
URL: https://github.com/apache/airflow/pull/71214#discussion_r3744887964
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -1268,24 +1269,11 @@ def _enqueue_executor_callbacks(self, session: Session)
-> None:
# Can't happen since we queried ExecutorCallback, but
satisfies mypy.
continue
- # TODO: Add dagrun_id as a proper ORM foreign key on the
callback table instead of storing in data dict.
- # This would eliminate this reconstruction step. For
now, all ExecutorCallbacks
- # are expected to have dag_run_id set in their data dict
(e.g., by Deadline.handle_miss).
- if not isinstance(callback.data, dict) or "dag_run_id" not in
callback.data:
- self.log.error(
- "ExecutorCallback %s is missing required 'dag_run_id'
in data dict. "
- "This indicates a bug in callback creation. Skipping
callback.",
- callback.id,
- )
- continue
-
- dag_run_id = callback.data["dag_run_id"]
- dag_run = session.get(DagRun, dag_run_id)
-
+ dag_run = callback.dag_run
if dag_run is None:
self.log.warning(
"Could not find DagRun with id=%s for callback %s.
DagRun may have been deleted.",
- dag_run_id,
+ callback.dagrun_id,
callback.id,
)
Review Comment:
This collapses two previously distinct failure modes (missing `dagrun_id`
due to a callback-creation bug vs. a DagRun deleted after enqueue) into one
warning path. Only one production call site sets `dagrun_id` today, so it's not
reachable now, but it'd be easy for a future ExecutorCallback creation path to
forget to set it and silently emits "DagRun may have been deleted."
Maybe add different checks to `callback.dagrun_id is None` and `dag_run is
None` with dagrun_id set?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]