Taragolis commented on code in PR #29447:
URL: https://github.com/apache/airflow/pull/29447#discussion_r1145084972
##########
airflow/providers/amazon/aws/operators/ecs.py:
##########
@@ -564,29 +561,17 @@ def _start_task(self, context):
self.ecs_task_id = self.arn.split("/")[-1]
self.log.info("ECS task ID is: %s", self.ecs_task_id)
- if self.reattach:
- # Save the task ARN in XCom to be able to reattach it if needed
- self.xcom_push(context, key=self.REATTACH_XCOM_KEY, value=self.arn)
-
- def _try_reattach_task(self, context):
- task_def_resp =
self.client.describe_task_definition(taskDefinition=self.task_definition)
- ecs_task_family = task_def_resp["taskDefinition"]["family"]
-
+ def _try_reattach_task(self):
list_tasks_resp = self.client.list_tasks(
- cluster=self.cluster, desiredStatus="RUNNING",
family=ecs_task_family
+ cluster=self.cluster, desiredStatus="RUNNING",
startedBy=self.started_by
)
running_tasks = list_tasks_resp["taskArns"]
-
- # Check if the ECS task previously launched is already running
- previous_task_arn = self.xcom_pull(
- context,
-
task_ids=self.REATTACH_XCOM_TASK_ID_TEMPLATE.format(task_id=self.task_id),
- key=self.REATTACH_XCOM_KEY,
- )
- if previous_task_arn in running_tasks:
- self.arn = previous_task_arn
- self.ecs_task_id = self.arn.split("/")[-1]
+ if running_tasks:
+ if len(running_tasks) > 1:
+ self.log.warning("Found more then one previously launched
tasks: %s", running_tasks)
Review Comment:
This is very rare situation.
1. For trigger rerun should something bad happen with Airflow itself, so
worker can't run `on_kill` method but when task still alive
2. For more than one task user should run Different Airflow deployment
within same task key and both described in p1 happen on different Airflow
deployment.
But it general it is very rare case, which I reproduce locally during local
debugging. But in general I would very surprised if it happen 🤣
--
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]