Skip to content

Commit

Permalink
Check if awslogs_stream_prefix already ends with container_name (#43724)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrr authored Nov 6, 2024
1 parent 66d3df2 commit 9a9497b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion providers/src/airflow/providers/amazon/aws/operators/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,13 @@ def _aws_logs_enabled(self):
return self.awslogs_group and self.awslogs_stream_prefix

def _get_logs_stream_name(self) -> str:
return f"{self.awslogs_stream_prefix}/{self.container_name}/{self._get_ecs_task_id(self.arn)}"
if (
self.awslogs_stream_prefix
and self.container_name
and not self.awslogs_stream_prefix.endswith(f"/{self.container_name}")
):
return f"{self.awslogs_stream_prefix}/{self.container_name}/{self._get_ecs_task_id(self.arn)}"
return f"{self.awslogs_stream_prefix}/{self._get_ecs_task_id(self.arn)}"

def _get_task_log_fetcher(self) -> AwsTaskLogFetcher:
if not self.awslogs_group:
Expand Down

0 comments on commit 9a9497b

Please sign in to comment.