Skip to content

Commit

Permalink
Don't insert dag_runs beyond the min task end_date
Browse files Browse the repository at this point in the history
  • Loading branch information
r39132 committed May 5, 2016
1 parent aeb5a07 commit e15a92b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ unittests.db
rat-results.txt
/.eggs/
/.tox/
venv
10 changes: 10 additions & 0 deletions airflow/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,19 @@ def schedule_dag(self, dag):
elif next_run_date:
schedule_end = dag.following_schedule(next_run_date)

# Don't schedule a dag beyond its end_date (as specified by the dag param)
if next_run_date and dag.end_date and next_run_date > dag.end_date:
return

# Don't schedule a dag beyond its end_date (as specified by the task params)
# Get the min task end date, which may come from the dag.default_args
min_task_end_date = []
task_end_dates = [t.end_date for t in dag.tasks if t.end_date]
if task_end_dates:
min_task_end_date = min(task_end_dates)
if next_run_date and min_task_end_date and next_run_date > min_task_end_date:
return

if next_run_date and schedule_end and schedule_end <= datetime.now():
next_run = DagRun(
dag_id=dag.dag_id,
Expand Down

0 comments on commit e15a92b

Please sign in to comment.