This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new d6141c6594 Fix attempting to reattach in `ECSOperator` (#23370)
d6141c6594 is described below
commit d6141c6594da86653b15d67eaa99511e8fe37a26
Author: Firass <[email protected]>
AuthorDate: Sun May 1 05:58:13 2022 -0500
Fix attempting to reattach in `ECSOperator` (#23370)
* Updated ecs_task_id on reattaching
---
airflow/providers/amazon/aws/operators/ecs.py | 1 +
tests/providers/amazon/aws/operators/test_ecs.py | 3 +++
2 files changed, 4 insertions(+)
diff --git a/airflow/providers/amazon/aws/operators/ecs.py
b/airflow/providers/amazon/aws/operators/ecs.py
index b6bae92388..8eda5d200b 100644
--- a/airflow/providers/amazon/aws/operators/ecs.py
+++ b/airflow/providers/amazon/aws/operators/ecs.py
@@ -409,6 +409,7 @@ class EcsOperator(BaseOperator):
)
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")
diff --git a/tests/providers/amazon/aws/operators/test_ecs.py
b/tests/providers/amazon/aws/operators/test_ecs.py
index 1dde03b324..6844b7461d 100644
--- a/tests/providers/amazon/aws/operators/test_ecs.py
+++ b/tests/providers/amazon/aws/operators/test_ecs.py
@@ -219,6 +219,7 @@ class TestEcsOperator(unittest.TestCase):
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 @@ class TestEcsOperator(unittest.TestCase):
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 @@ class TestEcsOperator(unittest.TestCase):
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