sla_miss_callback is not working with 5 input parameters as official document, only dag_id 1 input is allowed, no enough context for alert
Apache Airflow version
2.9.0
If "Other Airflow 2 version" selected, which one?
2.8.4
What happened?
Just as MathematicalOwl told in at the end of a stackoverflow post: https://stackoverflow.com/questions/59959290/airflow-sla-miss-callback-function-not-triggering Unlike the on_failure_callback that is looking for a python callable function, it appears that sla_miss_callback needs the full function call. Only below way it can work, then no context except dag_id.
def on_sla_miss_callback(dag):
continue
dag_id="my_example_alert"
with DAG(
dag_id=dag_id,
sla_miss_callback=on_sla_miss_callback(dag_id),
this_will_skip = BashOperator(
task_id="this_will_skip",
#bash_command='echo "hello world"; exit 99;',
bash_command='echo "hello world"; sleep 40;',
#execution_timeout=timedelta(seconds=3),
sla=timedelta(seconds=32),
dag=dag,
)
What you think should happen instead?
No response
How to reproduce
Just as described in "what happended", define a sla_miss_callback, only take dag_id as input, then give the callback to DAG as construction input by sla_miss_callback=sla_miss_callback(dag_id). Add a operator with sla little than the execution duration. Then the callback is triggered. But if define the callback like these, all not working:
#def on_sla_miss_callback(dag, task_list, blocking_task_list, slas, blocking_tis, *args, **kwargs):
#def on_sla_miss_callback(dag, task_list, blocking_task_list, slas, blocking_tis):
#def on_sla_miss_callback(*args, **kwargs):
def on_sla_miss_callback(dag):
Operating System
centos 7
Versions of Apache Airflow Providers
no providers are used in this example
Deployment
Official Apache Airflow Helm Chart
Deployment details
Both 2.9.0/2.8.4 manual deployment on centos cluster. And also a K8S cluster by official helm and docker image.
Anything else?
No response
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
According to the doc, the recommended args in sla_miss_callback function is:
def on_sla_miss_callback(dag, task_list, blocking_task_list, slas, blocking_tis):
...
or
def on_sla_miss_callback(*args):
...
And both are working in current main branch. Ref: https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/tasks.html#sla-miss-callback
Can you provide the error you are seeing
There are no errors in scheduler or executor logs, also neither visible errors on web UI, just the callback is not called at all. It can be reproduced on 2.8.4. I didn't try it on main branch.
Thank you!
BR, Alex
发件人: Ephraim Anierobi @.> 发送时间: 2024年4月15日 5:32 收件人: apache/airflow @.> 抄送: bronzels @.>; Author @.> 主题: Re: [apache/airflow] sla_miss_callback is not working with 5 input parameters as official document, only dag_id 1 input is allowed, no enough context for alert (Issue #38931)
Can you provide the error you are seeing
― Reply to this email directly, view it on GitHubhttps://github.com/apache/airflow/issues/38931#issuecomment-2054190330, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACAYA53ADVNDGUPOFYUBFDY5LYX5AVCNFSM6AAAAABGCKHQDSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJUGE4TAMZTGA. You are receiving this because you authored the thread.Message ID: @.***>
This issue has been automatically marked as stale because it has been open for 14 days with no response from the author. It will be closed in next 7 days if no further activity occurs from the issue author.
This issue has been closed because it has not received response from the issue author.