[AIRFLOW-1001] Fix landing times if there is no following schedule @once does not have a following schedule. This was not checked for and therefore the landing times page could bork.
Closes #2213 from bolkedebruin/AIRFLOW-1001 (cherry picked from commit 0371df4f1bd78e220e591d5cb23630d6a062f109) Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/c94b3a02 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/c94b3a02 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/c94b3a02 Branch: refs/heads/v1-8-stable Commit: c94b3a02f430f1a5a86c83d5f7286dcdac31492b Parents: aec9770 Author: Bolke de Bruin <bo...@xs4all.nl> Authored: Wed Apr 5 09:57:55 2017 +0200 Committer: Chris Riccomini <criccom...@apache.org> Committed: Mon Apr 10 14:19:53 2017 -0700 ---------------------------------------------------------------------- airflow/www/views.py | 2 +- tests/core.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/c94b3a02/airflow/www/views.py ---------------------------------------------------------------------- diff --git a/airflow/www/views.py b/airflow/www/views.py index 962c1f0..fec4779 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -1553,7 +1553,7 @@ class Airflow(BaseView): for ti in task.get_task_instances(session, start_date=min_date, end_date=base_date): ts = ti.execution_date - if dag.schedule_interval: + if dag.schedule_interval and dag.following_schedule(ts): ts = dag.following_schedule(ts) if ti.end_date: dttm = wwwutils.epoch(ti.execution_date) http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/c94b3a02/tests/core.py ---------------------------------------------------------------------- diff --git a/tests/core.py b/tests/core.py index 870a0cb..c55b1e2 100644 --- a/tests/core.py +++ b/tests/core.py @@ -1413,6 +1413,7 @@ class WebUiTests(unittest.TestCase): self.dag_bash2 = self.dagbag.dags['test_example_bash_operator'] self.sub_dag = self.dagbag.dags['example_subdag_operator'] self.runme_0 = self.dag_bash.get_task('runme_0') + self.example_xcom = self.dagbag.dags['example_xcom'] self.dag_bash2.create_dagrun( run_id="test_{}".format(models.DagRun.id_for_date(datetime.now())), @@ -1428,6 +1429,13 @@ class WebUiTests(unittest.TestCase): state=State.RUNNING ) + self.example_xcom.create_dagrun( + run_id="test_{}".format(models.DagRun.id_for_date(datetime.now())), + execution_date=DEFAULT_DATE, + start_date=datetime.now(), + state=State.RUNNING + ) + def test_index(self): response = self.app.get('/', follow_redirects=True) assert "DAGs" in response.data.decode('utf-8') @@ -1473,8 +1481,12 @@ class WebUiTests(unittest.TestCase): assert "example_bash_operator" in response.data.decode('utf-8') response = self.app.get( '/admin/airflow/landing_times?' - 'days=30&dag_id=example_bash_operator') - assert "example_bash_operator" in response.data.decode('utf-8') + 'days=30&dag_id=test_example_bash_operator') + assert "test_example_bash_operator" in response.data.decode('utf-8') + response = self.app.get( + '/admin/airflow/landing_times?' + 'days=30&dag_id=example_xcom') + assert "example_xcom" in response.data.decode('utf-8') response = self.app.get( '/admin/airflow/gantt?dag_id=example_bash_operator') assert "example_bash_operator" in response.data.decode('utf-8')