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

Fix queued dag runs changes catchup=False behaviour #19130

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions airflow/timetables/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ def next_dagrun_info(
return None
start = self._align(earliest)
else:
# There's a previous run. Create a data interval starting from when
# the end of the previous interval.
start = last_automated_data_interval.end
# There's a previous run.
if earliest is not None:
# Catchup is False or DAG has new start date in the future.
# Make sure we get the latest start date
start = max(last_automated_data_interval.end, earliest)
else:
# Create a data interval starting from when the end of the previous interval.
start = last_automated_data_interval.end
Comment on lines +84 to +91
Copy link
Member

Choose a reason for hiding this comment

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

Could you move the first comment to the end of the else:? Like this

else:  # There's a previous run.

Because right now it isn't very clear whether this comment is describing the else, or the if earliest is not None: block below.

Otherwise this looks good to me. Could you add a test in tests/timetables for this? There's already a file in there, and you should be able to set up cases roughly following its structure to test for the catchup, start_date, and last_automated_data_interval cases (so 8 in total) with pytest.mark.parametrize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course will look into this tomorrow


if restriction.latest is not None and start > restriction.latest:
return None
end = self._get_next(start)
Expand Down