diff --git a/airflow/providers/amazon/aws/hooks/base_aws.py b/airflow/providers/amazon/aws/hooks/base_aws.py index 0a4c58b5ffee6..16c7385f9c1ef 100644 --- a/airflow/providers/amazon/aws/hooks/base_aws.py +++ b/airflow/providers/amazon/aws/hooks/base_aws.py @@ -584,7 +584,7 @@ def decorator_f(self, *args, **kwargs): min_limit = retry_args.get('min', 1) max_limit = retry_args.get('max', 1) stop_after_delay = retry_args.get('stop_after_delay', 10) - tenacity_logger = tenacity.before_log(self.log, logging.DEBUG) if self.log else None + tenacity_logger = tenacity.before_log(self.log, logging.INFO) if self.log else None default_kwargs = { 'wait': tenacity.wait_exponential(multiplier=multiplier, max=max_limit, min=min_limit), 'retry': tenacity.retry_if_exception(should_retry), diff --git a/airflow/providers/amazon/aws/operators/ecs.py b/airflow/providers/amazon/aws/operators/ecs.py index 8a4a039bc2b9b..ca52e0af41868 100644 --- a/airflow/providers/amazon/aws/operators/ecs.py +++ b/airflow/providers/amazon/aws/operators/ecs.py @@ -51,7 +51,10 @@ def should_retry(exception: Exception): def should_retry_eni(exception: Exception): """Check if exception is related to ENI (Elastic Network Interfaces).""" if isinstance(exception, EcsTaskFailToStart): - return any(eni_reason in exception.message for eni_reason in ['network interface provisioning']) + return any( + eni_reason in exception.message + for eni_reason in ['network interface provisioning', 'ResourceInitializationError'] + ) return False @@ -450,6 +453,11 @@ def _check_success_task(self) -> None: 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', '')}") # This is a `stoppedReason` that indicates a task has not