Skip to content

Conversation

@ramitkataria
Copy link
Contributor

@ramitkataria ramitkataria commented Aug 21, 2025

Introduce a generic Callback model that can be used for Deadline callbacks for now and hopefully the on_*_callbacks for Dags and Tasks in the future.

Introduce a generic Callback model to run callbacks on executor workers. To be used for Deadline callbacks and the on_*_callbacks for Dags and Tasks that run on the Dag Processor. Implementation of some of the functions will be added in another PR so that this PR can be focused on the DB model and the Workload definition.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

Introduce a generic Callback model that can be used for Deadline
callbacks for now and hopefully the on_*_callbacks for Dags and Tasks
in the future.
@boring-cyborg boring-cyborg bot added area:dev-tools area:Executors-core LocalExecutor & SequentialExecutor area:Scheduler including HA (high availability) scheduler area:Triggerer backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch labels Aug 21, 2025
@ramitkataria
Copy link
Contributor Author

ramitkataria commented Aug 21, 2025

Relevant email thread

I've been working on making Deadline callbacks work on the executor in addition to the Triggerer. That means introducing a new Workload type for the executor. I didn't want to tie it specifically to Deadlines and realized it would be a good idea to introduce generic Callbacks that the new workload can reference.

This is an initial PR for adding a new Callback table and refactoring existing Deadline callbacks that run on the Triggerer to use these instead: Ideally, once AIP-92 is in progress, these callbacks can be used or all the on_*_callbacks as well. I want to ensure that these are generic enough for additional subclasses that would implement them. So I'm looking for feedback/comments to align on a common definition for the new Workload type and the Callback model definition.

Copy link
Contributor Author

@ramitkataria ramitkataria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've highlighted the areas of this PR I want to focus on and get everyone working on AIP-92 to agree on. Everything else is just refactoring to make existing functionality work. I'll work on unit tests once we agree on how these should work

@vikramkoka
Copy link
Contributor

Relevant email thread

I've been working on making Deadline callbacks work on the executor in addition to the Triggerer. That means introducing a new Workload type for the executor. I didn't want to tie it specifically to Deadlines and realized it would be a good idea to introduce generic Callbacks that the new workload can reference.

This is an initial PR for adding a new Callback table and refactoring existing Deadline callbacks that run on the Triggerer to use these instead: Ideally, once AIP-92 is in progress, these callbacks can be used or all the on_*_callbacks as well. I want to ensure that these are generic enough for additional subclasses that would implement them. So I'm looking for feedback/comments to align on a common definition for the new Workload type and the Callback model definition.

I am quite surprised by this and I guess my core question here is almost "why?"
There seems to be a very large overlap between a sync callback and a task here.

For now, keeping it focused on "sync deadline alert callbacks", this seems be a lot of code replication for unclear benefit.

@o-nikolas
Copy link
Contributor

o-nikolas commented Aug 27, 2025

Relevant email thread
I've been working on making Deadline callbacks work on the executor in addition to the Triggerer. That means introducing a new Workload type for the executor. I didn't want to tie it specifically to Deadlines and realized it would be a good idea to introduce generic Callbacks that the new workload can reference.
This is an initial PR for adding a new Callback table and refactoring existing Deadline callbacks that run on the Triggerer to use these instead: Ideally, once AIP-92 is in progress, these callbacks can be used or all the on_*_callbacks as well. I want to ensure that these are generic enough for additional subclasses that would implement them. So I'm looking for feedback/comments to align on a common definition for the new Workload type and the Callback model definition.

I am quite surprised by this and I guess my core question here is almost "why?" There seems to be a very large overlap between a sync callback and a task here.

For now, keeping it focused on "sync deadline alert callbacks", this seems be a lot of code replication for unclear benefit.

Hey @vikramkoka! Thanks for weighing in, here is more context:

Basically the story goes:

  1. Months ago on a dev email list/Thursday dev call discussion the community decided that async Deadlines Callbacks shall run in the Triggerer and that sync callbacks should run on the Executor workers (see your summary of the dev call here, screenshot of the relevant piece below [1] and a follow up from Ramit here).
  2. To run things on executors, now with task API, you need to submit a Workload to them. Reusing the Task Workload type does not make much sense since it requires different inputs and runtime behaviour than callbacks, so we are creating a new Workload type.
  3. While creating that new Workload type, instead of making it specific to Deadline callbacks, we're making it generic enough to run any callback. This means that we can eventually move the on_success/on_failure callbacks to run on the executors in the same way, relieving the Dag Parser of this duty and having all user code executed, rather sensibly, on the executors.
  4. However, AIP-92 has also been in discussion lately, and there they have a proposal to create a separate process to run the on_success/on_failure callbacks [2], which is an approach we thought we ruled out in 1). So we're looking to reevaluate and discuss to orient back onto a single path for callback execution. And whatever path we decide, is what we'll use for sync callbacks for Deadlines. Which will be delivered for 3.2 as discussed separately.

[1]
Screenshot from 2025-08-27 15-12-25

[2]
Screenshot from 2025-08-27 14-48-16

@ramitkataria ramitkataria marked this pull request as draft September 8, 2025 20:29
@ramitkataria ramitkataria force-pushed the ramitkataria/callback-table branch from 555c754 to 0fb75a4 Compare September 11, 2025 01:37
@ramitkataria ramitkataria force-pushed the ramitkataria/callback-table branch 4 times, most recently from 5359cc7 to 34b556c Compare September 12, 2025 23:08
@ramitkataria ramitkataria marked this pull request as ready for review September 12, 2025 23:09
@ramitkataria
Copy link
Contributor Author

ramitkataria commented Sep 12, 2025

I've removed the refactoring changes for deadline and just focused on the DB related changes for callbacks to keep this PR focused on the major change. There will be followup PRs to refactor deadlines to use TriggererCallback as well as implementing support for Executor callbacks

ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 28, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 28, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 28, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 28, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 28, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 28, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 29, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 29, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 29, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 4, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 4, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 4, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 4, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 4, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 4, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 5, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.

# Conflicts:
#	airflow-core/src/airflow/migrations/versions/0091_3_2_0_restructure_callback_table.py
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 5, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.

# Conflicts:
#	airflow-core/src/airflow/migrations/versions/0091_3_2_0_restructure_callback_table.py

# Conflicts:
#	airflow-core/src/airflow/models/deadline.py
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 5, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.

# Conflicts:
#	airflow-core/src/airflow/migrations/versions/0091_3_2_0_restructure_callback_table.py

# Conflicts:
#	airflow-core/src/airflow/models/deadline.py
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 5, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.

# Conflicts:
#	airflow-core/src/airflow/migrations/versions/0091_3_2_0_restructure_callback_table.py

# Conflicts:
#	airflow-core/src/airflow/models/deadline.py
o-nikolas pushed a commit that referenced this pull request Nov 5, 2025
Followup to #54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
xchwan pushed a commit to xchwan/airflow that referenced this pull request Nov 6, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 11, 2025
Followup to apache#54796. Since callbacks are going to be independent from
deadlines, we might as well move them to their own module.

I've essentially copied the code between files with the only actual
change being imports and switching to structlog.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 11, 2025
Followup to apache#54796. Since callbacks are going to be independent from
deadlines, we might as well move them to their own module.

I've essentially copied the code between files with the only actual
change being imports and switching to structlog.
ramitkataria added a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 12, 2025
Followup to apache#54796. Since callbacks are going to be independent from
deadlines, we might as well move them to their own module.

I've essentially copied the code between files with the only actual
change being imports and switching to structlog.
potiuk pushed a commit that referenced this pull request Nov 18, 2025
Followup to #54796. Since callbacks are going to be independent from
deadlines, we might as well move them to their own module.

I've essentially copied the code between files with the only actual
change being imports and switching to structlog.
aaron-wolmutt pushed a commit to aaron-wolmutt/airflow that referenced this pull request Nov 20, 2025
…8177)

Followup to apache#54796. Since callbacks are going to be independent from
deadlines, we might as well move them to their own module.

I've essentially copied the code between files with the only actual
change being imports and switching to structlog.
Copilot AI pushed a commit to jason810496/airflow that referenced this pull request Dec 5, 2025
Followup to apache#54796. This PR essentially moves callback functionality
from deadline callbacks to the generic callbacks and refactors Deadline
to use these callbacks.
Copilot AI pushed a commit to jason810496/airflow that referenced this pull request Dec 5, 2025
…8177)

Followup to apache#54796. Since callbacks are going to be independent from
deadlines, we might as well move them to their own module.

I've essentially copied the code between files with the only actual
change being imports and switching to structlog.
itayweb pushed a commit to itayweb/airflow that referenced this pull request Dec 6, 2025
…8177)

Followup to apache#54796. Since callbacks are going to be independent from
deadlines, we might as well move them to their own module.

I've essentially copied the code between files with the only actual
change being imports and switching to structlog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:Executors-core LocalExecutor & SequentialExecutor area:Scheduler including HA (high availability) scheduler area:Triggerer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants