Fix missing _team_name on DagRun before some listener calls - #70760
Conversation
|
cc @ferruzzi , FYI as I see that you worked on adding this before |
a0393d4 to
45cf7c3
Compare
45cf7c3 to
e83184a
Compare
|
I would introduce a helper (say |
e83184a to
9fe1f70
Compare
@uranusjr Extracted the logic to a separate helper, ptal |
|
@kacpermuda can you resolve comments? |
9fdc186 to
21524ac
Compare
|
@vatsrahul1001 addressed all the comments |
|
LGTM!, can be merged after code owners review |
21524ac to
560334c
Compare
|
Moving to 3.3.2 as this is still pending code owner review and do not want to rush on merging this as it not critical |
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…ls (apache#70760) (cherry picked from commit 86e86bd) Co-authored-by: Kacper Muda <mudakacper@gmail.com>
…ls (apache#70760) (cherry picked from commit 86e86bd) Co-authored-by: Kacper Muda <mudakacper@gmail.com>
In multi-team deployments the scheduler fires
on_dag_run_running / success / failedlistener hooks from several code paths. Before this change,DagRun._team_namewas not guaranteed to be set when those hooks fired, so OpenLineage (and any other plugin reading_team_name) would miss the team on some events._team_nameis a private attribute — it is not part of any public API and is not guaranteed to be present on everyDagRunobject a listener receives. Since the value is already cached inself._dag_id_to_team_namefor metrics purposes, setting it consistently before each hook fires adds no cost. Listeners that wish to use it should treat it as best-effort and guard accordingly.This PR ensures
_team_nameis stamped on every ORMDagRunobject beforenotify_dagrun_state_changed()is called, covering all five listener code paths. The stamping is cheap:_get_team_names_for_dag_idscaches results inself._dag_id_to_team_namefor the lifetime of a scheduler loop, so most calls are a dict read with no DB query. I've also added comments to the existing stamping paths, just to make sure it's clear why it's done before listener call.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Sonnet 4.6) following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.