question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExternalTaskSensor does not fail when failed_states is set along with a execution_date_fn

See original GitHub issue

Apache Airflow version: 2.x including main

What happened:

I am using an execution_date_fn in an ExternalTaskSensor that also sets allowed_states=['success'] and failed_states=['failed']. When one of the N upstream tasks fails, the sensor will hang forever in the poke method because there is a bug in checking for failed_states.

What you expected to happen:

I would expect the ExternalTaskSensor to fail.

I think this is due to a bug in the poke method where it should check if count_failed > 0 as opposed to checking count_failed == len(dttm_filter). I’ve created a fix locally that works for my case and have submitted a PR #16205 for it as reference.

How to reproduce it:

Create any ExternalTaskSensor that checks for failed_states and have one of the external DAGs tasks fail while others succeed.

E.g.

ExternalTaskSensor(
        task_id='check_external_dag',                                                     
        external_dag_id='external_dag',                                                               
        external_task_id=None,                              
        execution_date_fn=dependent_date_fn,
        allowed_states=['success'],
        failed_states=['failed'],                                                                     
        check_existence=True)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
eitanmecommented, Oct 21, 2022

@o-nikolas , OK, I’ve re-opened the PR after merging in main as #27190.

We can pick up discussion over there, hopefully it’s pretty straightforward.

0reactions
o-nikolascommented, Oct 20, 2022

Hey @eitanme,

I do apologize about that, it wasn’t a great experience for your first contribution! But we really appreciate your time, I’ll definitely have a look at the PR if you re-raise it, feel free to ping me directly on it once it’s up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Airflow ExternalTaskSensor don't fail when External Task fails
This sets the execution_date to the same value in both dags. This works perfectly when the state of the dummy_dag last task, ends...
Read more >
Airflow - External Task Sensor - Cloud Walker
Here is my thought as to why an external task sensor is very useful. ... detect if the task in DAG A has...
Read more >
Source code for airflow.sensors.external_task
It is possible to alter the default behavior by setting states which cause the sensor to fail, e.g. by setting ``allowed_states=[State.FAILED]`` and ...
Read more >
ExternalTaskSensor can never find External Parent Task
Apache Airflow version: 2.0 Kubernetes version (if you are using ... loop until it times out because the execution date filter is only ......
Read more >
Dependencies between DAGs in Apache Airflow
However, the name execution_date might be misleading: it is not a date, but an instant. So DAGs that are cross-dependent between them need ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found