This is an automated email from the ASF dual-hosted git repository. ash pushed a commit to branch v2-0-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 0cb2a967ed40f2f3bf6eeb8795d7b6e38555b3a3 Author: Ephraim Anierobi <[email protected]> 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 (cherry picked from commit 7418679591e5df4ceaab6c471bc6d4a975201871) --- 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 0da5925..83dae6a 100644 --- a/airflow/api_connexion/openapi/v1.yaml +++ b/airflow/api_connexion/openapi/v1.yaml @@ -2498,6 +2498,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()
