ketozhang opened a new issue, #34282:
URL: https://github.com/apache/airflow/issues/34282

   ### Apache Airflow version
   
   2.7.1
   
   ### What happened
   
   I defined a task as a decorated function with `@task.kubernetes`. The 
function always fails. I want to test the DAG with `dag.test()`. Despite the 
pod failing with `ERROR` status and pod's logs report the exception, 
`dag.test()` does not raise an exception.
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   ```python
   from airflow.decorators import task
   
   ...
   with DAG(...) as dag:
       @task.kubernetes(
           image="python:3.10-slim-buster",
           log_events_on_failure=True,
       )
       def foobar():
           raise Exception("Error on foobar")
   
       foobar()
   
   def test_dag():
       dag.test()
   ```
   
   ```
   $ pytest dag.py
   >           raise AirflowException(
                   "\n".join(
                       filter(
                           None,
                           [
                               f"Pod {pod and pod.metadata.name} returned a 
failure.",
                               error_message if isinstance(error_message, str) 
else None,
                               f"remote_pod: {remote_pod}" if 
self.log_pod_spec_on_failure else None,
                           ],
                       )
                   )
               )
   E           airflow.exceptions.AirflowException: Pod 
k8s-airflow-pod-63a829091c694da3a766ccdf994157b8-ansf26or returned a failure.
   E           remote_pod: {'api_version': 'v1',
   E            'kind': 'Pod',
   ```
   
   ### Operating System
   
   Amazon Linux 2
   
   ### Versions of Apache Airflow Providers
   
   ```
   apache-airflow-providers-amazon          8.2.0
   apache-airflow-providers-cncf-kubernetes 7.5.0
   apache-airflow-providers-common-sql      1.5.1
   apache-airflow-providers-ftp             3.4.1
   apache-airflow-providers-http            4.4.1
   apache-airflow-providers-imap            3.2.1
   apache-airflow-providers-postgres        5.5.1
   apache-airflow-providers-sqlite          3.4.1
   ```
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to