o-nikolas commented on code in PR #77546:
URL: https://github.com/apache/airflow/pull/77546#discussion_r4686531666
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -1338,17 +1352,39 @@ def _get_sentry_integration(executor: BaseExecutor) ->
str:
return ""
return sentry_integration
- log_contexts = prepare_task_log_contexts(
- [
- ti
- for ti in task_instances
- if ti.dag_version_id and ti.dag_run.state not in
State.finished_dr_states
- ],
- session=session,
- dag_bag=self.scheduler_dag_bag,
- filename_template=conf.get("logging", "log_filename_template"),
- )
+ log_tis = [
+ ti
+ for ti in task_instances
+ if ti.dag_version_id and ti.dag_run.state not in
State.finished_dr_states
+ ]
+ while True:
+ try:
+ log_contexts = prepare_task_log_contexts(
+ log_tis,
+ session=session,
+ dag_bag=self.scheduler_dag_bag,
+ filename_template=conf.get("logging",
"log_filename_template"),
+ )
+ break
+ except KeyError:
Review Comment:
+1 that an explicit signal from `prepare_task_log_contexts` (skip or name
the task instances it can't resolve) would read more clearly than working back
from a `KeyError`. One small correction though: a `KeyError` that isn't caused
by a deletion still surfaces in the same call, because the loop retries right
away and re-raises once nothing is missing. So it isn't hidden, it just takes
one extra `SELECT`. Fine with me as a follow-up.
--
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]