You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2021/06/22 13:46:22 UTC

[airflow] 32/38: Allow null value for operator field in task_instance schema(REST API) (#16516)

This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch v2-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 8813c3dc85503e7c9cf8189b1bbe76e886f62bdd
Author: Ephraim Anierobi <sp...@gmail.com>
AuthorDate: Fri Jun 18 08:56:05 2021 +0100

    Allow null value for operator field in task_instance schema(REST API) (#16516)
    
    This change makes it possible to get "old" task instances from 1.10.x
    
    (cherry picked from commit 087556f0c210e345ac1749933ff4de38e40478f6)
---
 airflow/api_connexion/openapi/v1.yaml                        | 1 +
 tests/api_connexion/endpoints/test_task_instance_endpoint.py | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/airflow/api_connexion/openapi/v1.yaml b/airflow/api_connexion/openapi/v1.yaml
index 02a6690..182f356 100644
--- a/airflow/api_connexion/openapi/v1.yaml
+++ b/airflow/api_connexion/openapi/v1.yaml
@@ -2137,6 +2137,7 @@ components:
           type: integer
         operator:
           type: string
+          nullable: true
         queued_when:
           type: string
           nullable: true
diff --git a/tests/api_connexion/endpoints/test_task_instance_endpoint.py b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
index 0b35ee3..b28330e 100644
--- a/tests/api_connexion/endpoints/test_task_instance_endpoint.py
+++ b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
@@ -135,6 +135,13 @@ class TestTaskInstanceEndpoint:
 class TestGetTaskInstance(TestTaskInstanceEndpoint):
     def test_should_respond_200(self, session):
         self.create_task_instances(session)
+        # Update ti and set operator to None to
+        # test that operator field is nullable.
+        # This prevents issue when users upgrade to 2.0+
+        # from 1.10.x
+        # https://github.com/apache/airflow/issues/14421
+        session.query(TaskInstance).update({TaskInstance.operator: None}, synchronize_session='fetch')
+        session.commit()
         response = self.client.get(
             "/api/v1/dags/example_python_operator/dagRuns/TEST_DAG_RUN_ID/taskInstances/print_the_context",
             environ_overrides={"REMOTE_USER": "test"},
@@ -148,7 +155,7 @@ class TestGetTaskInstance(TestTaskInstanceEndpoint):
             "executor_config": "{}",
             "hostname": "",
             "max_tries": 0,
-            "operator": "PythonOperator",
+            "operator": None,
             "pid": 100,
             "pool": "default_pool",
             "pool_slots": 1,