-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Add start date to trigger_dagrun operator #18226
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you made the change in the wrong place. Here's where I think the change should be:
airflow/airflow/operators/trigger_dagrun.py
Line 132 in 23a68fa
conf=self.conf, |
Add
start_date=self.start_date
after the line above.
EDIT:
You are actually correct, just fix the failing tests
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. |
tests are failing |
Hey, @kaxil, I cannot recreate the failing tests using breeze env or pytest with the same python and Postgres versions. Looks like a persistent issue across PRs, https://github.com/apache/airflow/pull/18243/checks?check_run_id=3604451375 |
Looks like something went wrong in your last rebase. Please rebase again |
c23d595
to
08c329f
Compare
@@ -82,6 +82,7 @@ def _trigger_dag( | |||
for _dag in dags_to_trigger: | |||
trigger = _dag.create_dagrun( | |||
run_id=run_id, | |||
start_date=timezone.utcnow(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the dag you trigger is timezone aware does it matter?
I mean you consider here the default timezone but the dag you are triggering may be in a diffrent timezone than the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The start_date
here is not the DAG start_date. It is the dag run starting time of the run. Internally it's all tracked in UTC and rendered in the user's timezone on UI.
Correct me if I am wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’re correct. Although maybe we shouldn’t set this to RUNNING
in the first place, but should set it to QUEUED
and let the scheduler start the run (and set start_date
) instead. See how this is implemented in the new REST API (in airflow/api_connexion/endpoints/dag_run_endpoint.py::post_dag_run
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supported. Setting it to queued will save us some complaints especially about max_active_runs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only change the one identified here. Looks like others are more involved change and requires a separate PR(that's if it should be changed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will affect three places. All these use the trigger_dag
function.
- TriggerDAGRunOperator
- APIClient -
dag_runs
- CLI trigger dag
5d09be4
to
278805b
Compare
d70fc77
to
7413c49
Compare
7413c49
to
17d044d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit tests are failing - https://github.com/apache/airflow/pull/18226/checks?check_run_id=3651105087#step:6:6287
17d044d
to
1d7e0f9
Compare
Failure seems unrelated
|
task.run(start_date=execution_date, end_date=execution_date) | ||
|
||
with create_session() as session: | ||
dagruns = session.query(DagRun).filter(DagRun.dag_id == self.dag.dag_id).all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to add an explicit order_by
here, the db does not always return rows in a deterministic order.
1d7e0f9
to
b1be8cc
Compare
b1be8cc
to
45b9d4f
Compare
Thanks @bhavaniravi 🎉 |
closes: #18082
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, 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 UPDATING.md.