You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "boushphong (via GitHub)" <gi...@apache.org> on 2023/11/13 18:55:35 UTC
Re: [I] Manually marking dag run state will change end date [airflow]
boushphong commented on issue #31555:
URL: https://github.com/apache/airflow/issues/31555#issuecomment-1808817295
I just tried to fix this.
I have no clue how `dag_run.end_date` field here is always equal to the `timezone.utcnow()` to be honest. Even before assigning `state == DagRunState.RUNNING:` at line **368**. This seems to be the problem, it just doesn't get the `end_date` from it's latest run but always resolves to the value of `timezone.utcnow()`. Hence the `session.merge(dagrun)` will always alter the `end_date`.
https://github.com/apache/airflow/blob/270e2190b8bd15594af5a936fd54d35cb3a3b8ac/airflow/api/common/mark_tasks.py#L360-L369
perhaps someone could pick this up from my clue maybe. Maybe the code below would work after one could resolve the above problem. I suspect the problem comes from the `@provide_session` decorator. But I'm not too sure.
```python
if state == DagRunState.RUNNING:
dag_run.start_date = timezone.utcnow()
dag_run.end_date = None
elif state == DagRunState.QUEUE:
dag_run.end_date = timezone.utcnow()
session.merge(dagrun)
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org