Skip to content

PythonSensor is not considering mode='reschedule', instead marking task UP_FOR_RETRY #23411

Description

@pmrem

Apache Airflow version

2.3.0 (latest released)

What happened

A PythonSensor that works on versions <2.3.0 in mode reschedule is now marking the task as UP_FOR_RETRY instead.

Log says:

[2022-05-02, 15:48:23 UTC] {python.py:66} INFO - Poking callable: <function test at 0x7fd56286bc10>
[2022-05-02, 15:48:23 UTC] {taskinstance.py:1853} INFO - Rescheduling task, marking task as UP_FOR_RESCHEDULE
[2022-05-02, 15:48:23 UTC] {local_task_job.py:156} INFO - Task exited with return code 0
[2022-05-02, 15:48:23 UTC] {local_task_job.py:273} INFO - 0 downstream tasks scheduled from follow-on schedule check

But it directly marks it as UP_FOR_RETRY and then follows retry_delay and retries

What you think should happen instead

It should mark the task as UP_FOR_RESCHEDULE and reschedule it according to the poke_interval

How to reproduce

from datetime import datetime, timedelta

from airflow import DAG
from airflow.sensors.python import PythonSensor


def test():
    return False


default_args = {
    "owner": "airflow",
    "depends_on_past": False,
    "start_date": datetime(2022, 5, 2),
    "email_on_failure": False,
    "email_on_retry": False,
    "retries": 1,
    "retry_delay": timedelta(minutes=1),
}

dag = DAG("dag_csdepkrr_development_v001",
          default_args=default_args,
          catchup=False,
          max_active_runs=1,
          schedule_interval=None)

t1 = PythonSensor(task_id="PythonSensor",
                  python_callable=test,
                  poke_interval=30,
                  mode='reschedule',
                  dag=dag)

Operating System

Latest Docker image

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==3.3.0
apache-airflow-providers-celery==2.1.4
apache-airflow-providers-cncf-kubernetes==4.0.1
apache-airflow-providers-docker==2.6.0
apache-airflow-providers-elasticsearch==3.0.3
apache-airflow-providers-ftp==2.1.2
apache-airflow-providers-google==6.8.0
apache-airflow-providers-grpc==2.0.4
apache-airflow-providers-hashicorp==2.2.0
apache-airflow-providers-http==2.1.2
apache-airflow-providers-imap==2.2.3
apache-airflow-providers-microsoft-azure==3.8.0
apache-airflow-providers-mysql==2.2.3
apache-airflow-providers-odbc==2.0.4
apache-airflow-providers-oracle==2.2.3
apache-airflow-providers-postgres==4.1.0
apache-airflow-providers-redis==2.0.4
apache-airflow-providers-sendgrid==2.0.4
apache-airflow-providers-sftp==2.5.2
apache-airflow-providers-slack==4.2.3
apache-airflow-providers-sqlite==2.1.3
apache-airflow-providers-ssh==2.4.3

Deployment

Docker-Compose

Deployment details

Latest Docker compose from the documentation

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions