Skip to content

ExternalTaskSensor with mode='reschedule' raising module 'airflow.settings' has no attribute 'engine' error #47948

@atul-astronomer

Description

@atul-astronomer

Apache Airflow version

main (development)

If "Other Airflow 2 version" selected, which one?

No response

What happened?

ExternalTaskSensor with mode='reschedule' raising module 'airflow.settings' has no attribute 'engine' error

Traceback (most recent call last):
  File "/opt/airflow/airflow/sensors/base.py", line 206, in _validate_input_values
    if self.reschedule and _is_metadatabase_mysql():
  File "/opt/airflow/airflow/sensors/base.py", line 60, in _is_metadatabase_mysql
    if settings.engine is None:
AttributeError: module 'airflow.settings' has no attribute 'engine'

What you think should happen instead?

No response

How to reproduce

Have the below Dag in dags folder and notice import error:

from airflow import DAG
from airflow.providers.standard.operators.empty import EmptyOperator
from airflow.sensors.external_task import ExternalTaskMarker, ExternalTaskSensor
from pendulum import today

start_date = today('UTC').add(days=-1)

with DAG(
    dag_id="example_external_task_marker_parent",
    start_date=start_date,
    schedule=None,
    tags=["core"],
) as parent_dag:
    # [START howto_operator_external_task_marker]
    parent_task = ExternalTaskMarker(
        task_id="parent_task",
        external_dag_id="example_external_task_marker_child",
        external_task_id="child_task1",
    )
    # [END howto_operator_external_task_marker]

with DAG(
    dag_id="example_external_task_marker_child",
    start_date=start_date,
    schedule=None,
    tags=["core"],
) as child_dag:
    # [START howto_operator_external_task_sensor]
    child_task1 = ExternalTaskSensor(
        task_id="child_task1",
        external_dag_id=parent_dag.dag_id,
        external_task_id=parent_task.task_id,
        timeout=600,
        allowed_states=["success"],
        failed_states=["failed", "skipped"],
        mode="reschedule",
    )
    # [END howto_operator_external_task_sensor]
    child_task2 = EmptyOperator(task_id="child_task2")
    child_task1 >> child_task2

Operating System

Linux

Versions of Apache Airflow Providers

No response

Deployment

Other

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Labels

area:corekind:bugThis is a clearly a bugpriority:highHigh priority bug that should be patched quickly but does not require immediate new release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions