From 50ed6b5ac6cf870bf43d3ae27c8dca69e18b3184 Mon Sep 17 00:00:00 2001 From: Firass Date: Sat, 9 Apr 2022 12:06:07 -0500 Subject: [PATCH 1/2] Updated ecs_task_id on reattaching --- airflow/providers/amazon/aws/operators/ecs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/providers/amazon/aws/operators/ecs.py b/airflow/providers/amazon/aws/operators/ecs.py index b6bae92388190..8eda5d200be88 100644 --- a/airflow/providers/amazon/aws/operators/ecs.py +++ b/airflow/providers/amazon/aws/operators/ecs.py @@ -409,6 +409,7 @@ def _try_reattach_task(self, context): ) if previous_task_arn in running_tasks: self.arn = previous_task_arn + self.ecs_task_id = self.arn.split("/")[-1] self.log.info("Reattaching previously launched task: %s", self.arn) else: self.log.info("No active previously launched task found to reattach") From 8795c9e5c6a954bc80d3990dbc726b64646781ef Mon Sep 17 00:00:00 2001 From: Firass Date: Thu, 14 Apr 2022 16:20:19 -0500 Subject: [PATCH 2/2] Update test_ecs.py --- tests/providers/amazon/aws/operators/test_ecs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/providers/amazon/aws/operators/test_ecs.py b/tests/providers/amazon/aws/operators/test_ecs.py index 1dde03b3249f1..6844b7461d331 100644 --- a/tests/providers/amazon/aws/operators/test_ecs.py +++ b/tests/providers/amazon/aws/operators/test_ecs.py @@ -219,6 +219,7 @@ def test_execute_without_failures( wait_mock.assert_called_once_with() check_mock.assert_called_once_with() assert self.ecs.arn == 'arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55' + assert self.ecs.ecs_task_id == 'd8c67b3c-ac87-4ffe-a847-4785bc3a8b55' def test_execute_with_failures(self): client_mock = self.aws_hook_mock.return_value.get_conn.return_value @@ -490,6 +491,7 @@ def test_reattach_successful( check_mock.assert_called_once_with() xcom_del_mock.assert_called_once() assert self.ecs.arn == 'arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55' + assert self.ecs.ecs_task_id == 'd8c67b3c-ac87-4ffe-a847-4785bc3a8b55' @parameterized.expand( [ @@ -538,6 +540,7 @@ def test_reattach_save_task_arn_xcom( check_mock.assert_called_once_with() xcom_del_mock.assert_called_once() assert self.ecs.arn == 'arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55' + assert self.ecs.ecs_task_id == 'd8c67b3c-ac87-4ffe-a847-4785bc3a8b55' def test_execute_xcom_with_log(self): self.ecs.do_xcom_push = True