airflow icon indicating copy to clipboard operation
airflow copied to clipboard

ExternalTaskSensor with execution_delta not correctly running

Open pharoson opened this issue 11 years ago • 7 comments

I'm using an ExternalTaskSensor with the execution_delta parameter to coordinate between a daily DAG and an hourly DAG (daily depends on hourly). The daily runs at 1:00 and the hourly runs at x:10.

It hasn't run a scheduled instance (it will run later tonight), so I ran it manually via the run command.

I have the daily workflow set to depend on the hourly run 110 minutes earlier (23:10 in this case). Although Airflow reports it was successful, the log files report the wrong time when poking for the task instance. It reports that the 2015-08-17 01:00:00 was successful, not the 2015-08-16 23:10:00.

Relevant code and log files are below. If the normal scheduled run has correct logs, I'll close the issue. Thanks!

Daily DAG definition:

default_args = {
    ...
    'start_date': datetime(2015, 8, 11, 1),
    ...
    'schedule_interval': timedelta(days=1),
}

dag = DAG('check_for_missing_logs', default_args=default_args, schedule_interval=timedelta(days=1))
...
ext_dep = ExternalTaskSensor(
    external_dag_id='hourly_logs',
    external_task_id='end_of_logs', # end_of_logs is a DummyOperator that depends on all other tasks
    execution_delta=timedelta(minutes=110),
    task_id='hourly_logs_sensor',
    dag=dag)

Hourly DAG definition:

default_args = {
    ...
    'start_date': datetime(2015, 8, 10, 0, 10),
    ...
    'schedule_interval': timedelta(hours=1),
}

dag = DAG('hourly_logs', default_args=default_args, schedule_interval=timedelta(hours=1))

Logs files from ExternalTaskSensor in Daily DAG:

--------------------------------------------------------------------------------
New run starting @2015-08-18T17:05:33.597081
--------------------------------------------------------------------------------
[2015-08-18 17:05:33,619] {models.py:826} INFO - Executing <Task(ExternalTaskSensor): hourly_logs_sensor> on 2015-08-17 01:00:00
[2015-08-18 17:05:33,621] {sensors.py:139} INFO - Poking for hourly_logs.end_of_logs on 2015-08-17 01:00:00 ... 
[2015-08-18 17:05:33,648] {sensors.py:57} INFO - Success criteria met. Exiting.

pharoson avatar Aug 18 '15 21:08 pharoson

The ExternalTaskSensor did not actually work last night.

Is there anything I am defining incorrectly?

pharoson avatar Aug 24 '15 15:08 pharoson

The log should be clear about what it is poking for, seem like it's a simple issue around how time and delta are aligned isn't it?

mistercrunch avatar Aug 28 '15 16:08 mistercrunch

Reopen if the log says it's poking for something that does exist and is stuck, or if it's not poking where you set it up to poke.

mistercrunch avatar Aug 28 '15 16:08 mistercrunch

Hi pharoson, Did you manage to use ExternalTaskSensor? I am new to airflow and trying to implement daily dag that depends on hourly dag, didn't find any other documentation for implement the dag's dependency that actually works with airflow scheduler. Thanks!

hilaviz avatar May 03 '16 11:05 hilaviz

@hilaviz Please open a Jira issue as we are migrating off Github Issues and place a pointer here (assign to me as well).

I'd be happy to provide a working example for you there.

r39132 avatar May 03 '16 18:05 r39132

Hi, Thank you for your quick reply. I am not sure that there is an issue with the operator, I assume that I am missing something in strat_date/schedule_interval/execution_delta parameters

hilaviz avatar May 04 '16 04:05 hilaviz

https://issues.apache.org/jira/browse/AIRFLOW-47

thanks!

hilaviz avatar May 04 '16 06:05 hilaviz