Skip to content

Commit

Permalink
Check if awslogs_stream_prefix already ends with container_name
Browse files Browse the repository at this point in the history
Check if prefix exists before checking endswith

Check if container name exists before checking endswith

Add / to endswith

Fix indent
  • Loading branch information
pyrr committed Nov 6, 2024
1 parent 71b8d9f commit a13cd7a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 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,9 @@ 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 a13cd7a

Please sign in to comment.