kacpermuda opened a new pull request, #70760:
URL: https://github.com/apache/airflow/pull/70760

    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull 
request.
   Write a good git commit message following this guide: 
https://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the 
documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a 
short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for 
a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we 
sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   In multi-team deployments the scheduler fires `on_dag_run_running / success 
/ failed` listener hooks from several code paths. Before this change, 
`DagRun._team_name` was 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_name` is a private, non-mapped instance attribute — it is not part of 
any public API and is not guaranteed to be present on every `DagRun` object a 
listener receives (e.g. on a worker, or on a DagRun loaded outside the 
scheduler loop). Since the value is already cached in 
`self._dag_id_to_team_name` for 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_name` is stamped on every ORM `DagRun` object before 
`notify_dagrun_state_changed()` is called, covering all five listener code 
paths. The stamping is cheap: `_get_team_names_for_dag_ids` caches results in 
`self._dag_id_to_team_name` for 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?
   
   - [X] Yes — Claude Code (Sonnet 4.6)
   
   Generated-by: Claude Code (Sonnet 4.6) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


-- 
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]

Reply via email to