Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename to_delete to to_cancel in TriggerRunner #20658

Merged

Conversation

dstandish
Copy link
Contributor

@dstandish dstandish commented Jan 4, 2022

The queue's purpose is to track triggers that need to be canceled. I found the language to_delete a bit confusing because for one it does not actually delete them but cancel them. The deletion work is actually in cleanup_finished_triggers (and there it's deleting only from the triggers dict and not the database. Deletion from the database happens elsewhere.

It seems that this method will usually not do anything. The normal flow is that the trigger process will exit normally and be purged from the triggers dict by the cleanup process. This method is more for exceptional circumstances where we need to cancel (in other words terminate) triggers that are currently running but for whatever reason no longer should be. E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.

Additionally the use of the word deletion here has an ambiguity which would be good to avoid. Namely, we are talking about deletion from the triggers dict, and not deletion from the database.

@kaxil @potiuk i think these objects should be renamed but just not sure if this is considered "breaking" since maybe you could say the triggerer process is "internal"

The queue's purpose is to track triggers that need to be canceled. I found the language `to_delete` a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that the canceling of triggers with this method will usually not do anything and it's only for cancelling triggers that are currently running  but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.
@dstandish dstandish requested a review from kaxil January 4, 2022 19:17
@boring-cyborg boring-cyborg bot added the area:Scheduler including HA (high availability) scheduler label Jan 4, 2022
Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

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

LGTM, Is backward compatibility an issue here? It seems like delete_triggers is somewhat expected to be called externally since it does not have an underscore prefix.

@dstandish
Copy link
Contributor Author

dstandish commented Jan 5, 2022

LGTM, Is backward compatibility an issue here?

Just chatted with @ashb and his position is that methods like this on the trigger internals, or scheduler internals, should be considered private and can be refactored freely. But added that we should probablly also try to indicate that somewhere in the docs -- that there's no guarantee that they won't change from [minor] version to version.

@github-actions
Copy link

github-actions bot commented Jan 5, 2022

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Jan 5, 2022
@potiuk
Copy link
Member

potiuk commented Jan 5, 2022

Just chatted with @ashb and his position is that methods like this on the trigger internals, or scheduler internals, should be considered private and can be refactored freely. But added that we should probablly also try to indicate that somewhere in the docs -- that there's no guarantee that they won't change from [minor] version to version.

I think we should - rather than explaining this come up with the list of Classes/APIs (Protocols + Models ?) that would become our official Python API that we will guarantee to not change until major version increase. I don't think there will be awfully lot of those and I think in most cases it wil be enough to just list the classes that we treat this way.

@ashb
Copy link
Member

ashb commented Jan 5, 2022

Yeah, my view is that the "public" API is, loosely

  • anything operator related, or passed in via the Context (so this includes methods and properties on TI and DagRun etc.)
  • anything that is used as a base class where the user can configure a custom class to be used.

So Executors are part of the public API, but the SchedulerJob, nor TriggererJob are not.

Clearly this isn't a fully description but the ground work of what I think it should be

@potiuk
Copy link
Member

potiuk commented Jan 5, 2022

Clearly this isn't a fully description but the ground work of what I think it should be

Yeah. Some (obvious) models Variables, Connections etc (they will become non-SQLAlchemy Models really when we agree/implement this part of the API in AIP-44) + configuration + some logging part + some base opareators (DBapi for example) . Those on top of what you wrote @ashb

@dstandish dstandish merged commit c20ad79 into apache:main Jan 5, 2022
@dstandish dstandish deleted the trigger-runner-to_delete-to-to_cancel branch January 5, 2022 20:12
@ephraimbuddy ephraimbuddy added this to the Airflow 2.2.5 milestone Mar 18, 2022
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Mar 18, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 20, 2022
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that this method will usually not do anything and it's only for cancelling triggers that are currently running but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.  So putting cancel in the name also highlights that this is about stopping running triggers, not e.g. purging completed ones.

(cherry picked from commit c20ad79)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that this method will usually not do anything and it's only for cancelling triggers that are currently running but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.  So putting cancel in the name also highlights that this is about stopping running triggers, not e.g. purging completed ones.

(cherry picked from commit c20ad79)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that this method will usually not do anything and it's only for cancelling triggers that are currently running but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.  So putting cancel in the name also highlights that this is about stopping running triggers, not e.g. purging completed ones.

(cherry picked from commit c20ad79)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that this method will usually not do anything and it's only for cancelling triggers that are currently running but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.  So putting cancel in the name also highlights that this is about stopping running triggers, not e.g. purging completed ones.

(cherry picked from commit c20ad79)
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that this method will usually not do anything and it's only for cancelling triggers that are currently running but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.  So putting cancel in the name also highlights that this is about stopping running triggers, not e.g. purging completed ones.

(cherry picked from commit c20ad79)
ephraimbuddy pushed a commit that referenced this pull request Mar 24, 2022
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that this method will usually not do anything and it's only for cancelling triggers that are currently running but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.  So putting cancel in the name also highlights that this is about stopping running triggers, not e.g. purging completed ones.

(cherry picked from commit c20ad79)
@ephraimbuddy ephraimbuddy added type:misc/internal Changelog: Misc changes that should appear in change log and removed type:bug-fix Changelog: Bug Fixes labels Mar 26, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 26, 2022
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them.  The deletion work is actually in `cleanup_finished_triggers`.  It seems that this method will usually not do anything and it's only for cancelling triggers that are currently running but for whatever reason no longer should be.  E.g. when a task is killed and therefore the trigger is no longer needed, or some multi-triggerer scenarios.  So putting cancel in the name also highlights that this is about stopping running triggers, not e.g. purging completed ones.

(cherry picked from commit c20ad79)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Scheduler including HA (high availability) scheduler full tests needed We need to run full set of tests for this PR to merge type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants