I have a DAG A that is being triggered by a parent DAG B. So DAG A doesn't have any schedule interval defined in it.
1.I would like to set up a sla_miss_callback on one of the task in DAG A.
2.I would like to get an e-mail notification whenever the task misses it's SLA.
I have tried methods available in google and stackoverflow. The e-mail is not getting triggered as expected.
Sharing the sample code I have used for testing.
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import timedelta, datetime
import logging
def print_sla_miss(**kwargs):
logging.info("SLA missed")
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2021, 1, 1),
'email': 'sample@xxx.com',
'email_on_failure': True,
'email_on_retry': False,
'retries': 0
}
with DAG('sla_test', schedule_interval=None, max_active_runs=1, catchup=False,sla_miss_callback=print_sla_miss, default_args=default_args) as dag:
sleep = BashOperator(
task_id='timeout',
sla=timedelta(seconds=5),
bash_command='sleep 15',
retries=0,
dag=dag,
)
Thanks in advance.