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

   ### Apache Airflow Provider(s)
   
   amazon
   
   ### Versions of Apache Airflow Providers
   
   When using `EcsRunTaskOperator`, if an ECS task fails to start (e.g., due to 
resource constraints or misconfiguration), the `_check_success_task` method 
raises `EcsTaskFailToStart`. The `@AwsBaseHook.retry(should_retry_eni)` 
decorator retries this exception. However, the arn is set to None, so the 
function exits as success.
   
   ```
   @AwsBaseHook.retry(should_retry_eni)
   def _check_success_task(self) -> None:
       if not self.client or not self.arn:
           return
   
       response = self.client.describe_tasks(cluster=self.cluster, 
tasks=[self.arn])
       self.log.info("ECS Task stopped, check status: %s", response)
   
       if len(response.get("failures", [])) > 0:
           raise AirflowException(response)
   
       for task in response["tasks"]:
           if task.get("stopCode", "") == "TaskFailedToStart":
               # Reset task arn here otherwise the retry run will not start
               # a new task but keep polling the old dead one
               # I'm not resetting it for other exceptions here because
               # EcsTaskFailToStart is the only exception that's being retried 
at the moment
               self.arn = None
               raise EcsTaskFailToStart(f"The task failed to start due to: 
{task.get('stoppedReason', '')}")
   ```
   
   
   ### Apache Airflow version
   
   2.7.2
   
   ### Operating System
   
   Ubuntu 22.04
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   The Airflow task is marked as successful even though the ECS task never 
started successfully.
   
   ### What you think should happen instead
   
   The Airflow task should be marked as failed if the ECS task fails to start 
and all retries are exhausted.
   
   ### How to reproduce
   
   Create a misconfigured ECS Task definition 
   
   ### 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](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