GitHub user EvertonSA edited a discussion: on_success and on_failure callback 
logs

Hi, 

I am struggling to accept this warning as correct. 

https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/callbacks.html

![image](https://github.com/user-attachments/assets/e7ae1f74-4610-4598-aa38-71bac30ffd9d)

this is my test dag:

```
import logging
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.utils.context import Context
from datetime import datetime, timedelta

logger = logging.getLogger(__name__)

def create_incident(context: Context):
    try:
        dag_id = context["task_instance"].dag_id
        task_id = context["task_instance"].task_id
        log_url = context["task_instance"].log_url
        logger.info(f"creating an incident for task: {task_id} of DAG: {dag_id} 
and url is {log_url}")
    except Exception as e:
        logger.error(f"Failed to send failure email: {e}")

def fail_task():
    raise Exception("This task is designed to fail.")

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2025, 6, 24, 0, 0),
    'retries': 0,
    'retry_delay': timedelta(minutes=5),
    'on_failure_callback': create_incident,
}

with DAG(
    'fail_dag',
    default_args=default_args,
    description='A simple DAG that fails all the time',
    schedule_interval=timedelta(days=1),
) as dag:

    fail_task = PythonOperator(
        task_id='always_fail_task',
        python_callable=fail_task
    )

```

I understand from the warning that we should not be able to see these logs on 
UI.  

But for some reason I can see then:

![image](https://github.com/user-attachments/assets/17bb86f9-012c-44db-81e9-e5ece513bd09)

The screenshot above is from Kubernetes installation using Celery Executor on 
airflow 2.10.5

On my local installation it also shows the logs, but I assumed it was because  
as I was using LocalExecutor. 

Is there a chance the behavior described on the warning above changed? If so, I 
can open a pr to remove the warning. 



GitHub link: https://github.com/apache/airflow/discussions/52240

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscr...@airflow.apache.org

Reply via email to