You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/03/08 21:25:11 UTC
[airflow] branch master updated: BugFix: Fix taskInstance API call
fails if a task is removed from running DAG (#14381)
This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 7418679 BugFix: Fix taskInstance API call fails if a task is removed from running DAG (#14381)
7418679 is described below
commit 7418679591e5df4ceaab6c471bc6d4a975201871
Author: Ephraim Anierobi <sp...@gmail.com>
AuthorDate: Mon Mar 8 22:24:59 2021 +0100
BugFix: Fix taskInstance API call fails if a task is removed from running DAG (#14381)
Closes: #14331
---
airflow/api_connexion/openapi/v1.yaml | 1 +
airflow/utils/state.py | 1 +
.../endpoints/test_task_instance_endpoint.py | 31 ++++++++++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/airflow/api_connexion/openapi/v1.yaml b/airflow/api_connexion/openapi/v1.yaml
index 11a7ec5..92521c9 100644
--- a/airflow/api_connexion/openapi/v1.yaml
+++ b/airflow/api_connexion/openapi/v1.yaml
@@ -2611,6 +2611,7 @@ components:
- queued
- none
- scheduled
+ - removed
DagState:
description: DAG State.
diff --git a/airflow/utils/state.py b/airflow/utils/state.py
index 681cbc5..d5300e1 100644
--- a/airflow/utils/state.py
+++ b/airflow/utils/state.py
@@ -57,6 +57,7 @@ class State:
NONE,
SCHEDULED,
SENSING,
+ REMOVED,
)
dag_states = (
diff --git a/tests/api_connexion/endpoints/test_task_instance_endpoint.py b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
index 84c957f..4f8028e 100644
--- a/tests/api_connexion/endpoints/test_task_instance_endpoint.py
+++ b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
@@ -167,6 +167,37 @@ class TestGetTaskInstance(TestTaskInstanceEndpoint):
}
@provide_session
+ def test_should_respond_200_with_task_state_in_removed(self, session):
+ self.create_task_instances(session, task_instances=[{"state": State.REMOVED}], update_extras=True)
+ response = self.client.get(
+ "/api/v1/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/print_the_context",
+ environ_overrides={"REMOTE_USER": "test"},
+ )
+ assert response.status_code == 200
+ assert response.json == {
+ "dag_id": "example_python_operator",
+ "duration": 10000.0,
+ "end_date": "2020-01-03T00:00:00+00:00",
+ "execution_date": "2020-01-01T00:00:00+00:00",
+ "executor_config": "{}",
+ "hostname": "",
+ "max_tries": 0,
+ "operator": "PythonOperator",
+ "pid": 100,
+ "pool": "default_pool",
+ "pool_slots": 1,
+ "priority_weight": 6,
+ "queue": "default_queue",
+ "queued_when": None,
+ "sla_miss": None,
+ "start_date": "2020-01-02T00:00:00+00:00",
+ "state": "removed",
+ "task_id": "print_the_context",
+ "try_number": 0,
+ "unixname": getpass.getuser(),
+ }
+
+ @provide_session
def test_should_respond_200_task_instance_with_sla(self, session):
self.create_task_instances(session)
session.query()