Skip to content

Commit

Permalink
Allow null value for operator field in task_instance schema(REST API)
Browse files Browse the repository at this point in the history
This change makes it possible to get "old" task instances from 1.10.x
  • Loading branch information
ephraimbuddy committed Jun 16, 2021
1 parent a7738cf commit e7b19d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions airflow/api_connexion/openapi/v1.yaml
Expand Up @@ -2176,6 +2176,7 @@ components:
type: integer
operator:
type: string
nullable: true
queued_when:
type: string
nullable: true
Expand Down
9 changes: 8 additions & 1 deletion tests/api_connexion/endpoints/test_task_instance_endpoint.py
Expand Up @@ -135,6 +135,13 @@ def create_task_instances(
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"},
Expand All @@ -148,7 +155,7 @@ def test_should_respond_200(self, session):
"executor_config": "{}",
"hostname": "",
"max_tries": 0,
"operator": "PythonOperator",
"operator": None,
"pid": 100,
"pool": "default_pool",
"pool_slots": 1,
Expand Down

0 comments on commit e7b19d0

Please sign in to comment.