Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent usage of awslogs_stream_prefix #43130

Closed
2 tasks done
pyrr opened this issue Oct 17, 2024 · 0 comments · Fixed by #43138
Closed
2 tasks done

Inconsistent usage of awslogs_stream_prefix #43130

pyrr opened this issue Oct 17, 2024 · 0 comments · Fixed by #43138
Assignees
Labels
area:providers good first issue kind:bug This is a clearly a bug provider:amazon AWS/Amazon - related issues

Comments

@pyrr
Copy link
Contributor

pyrr commented Oct 17, 2024

Apache Airflow Provider(s)

amazon

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==8.29.0

Apache Airflow version

2.9.2

Operating System

Amazon Linux 2023.5.20240805

Deployment

Amazon (AWS) MWAA

Deployment details

Using a Python 3.11 environment with botocore==1.34.106 and apache-airflow-providers-amazon==8.29.0.

What happened

The code for EcsRunTaskOperator looks for log streams by using the pattern prefix-name/ecs-task-id:

    def _get_logs_stream_name(self) -> str:
        return f"{self.awslogs_stream_prefix}/{self._get_ecs_task_id(self.arn)}"

In the AWS ECS docs for LogConfiguration, log streams are created using the pattern prefix-name/container-name/ecs-task-id.

What you think should happen instead

EcsRunTaskOperator should follow the same log stream naming convention as specified in the AWS ECS docs.

Because this isn't the case, you need to specify a stream prefix using a different pattern when registering your task vs. when running your task.

How to reproduce

  1. Register a task definition with a containerDefinition containing at least the following:
  "name": "my-container-name",
  "logConfiguration": {
      "logDriver": "awslogs",
      "options": {
          "awslogs-group": "my-log-group",
          "awslogs-region": "us-east-1",
          "awslogs-create-group": "true",
          "awslogs-stream-prefix": "my-container-prefix",
      },
  },

The logs in your ECS task will be uploaded to CloudWatch under the log group my-log-group and the prefix my-container-prefix/my-container-name/task-id.

  1. Run the task using the EcsRunTaskOperator with the same awslogs-stream-prefix.
  2. View the logs in Airflow-- they will fail to fetch the task logs from CloudWatch because they are looking for the log group my-log-group and prefix my-container-prefix/task-id.

Anything else

The only workaround for this issue is to specify the task definition's awslogs-stream-prefix with my-prefix-name and the EcsRunTaskOperator's awslogs_stream_prefix with my-prefix-name/my-container-name.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@pyrr pyrr added area:providers kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels Oct 17, 2024
@dosubot dosubot bot added the provider:amazon AWS/Amazon - related issues label Oct 17, 2024
@potiuk potiuk added good first issue and removed needs-triage label for new issues that we didn't triage yet labels Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers good first issue kind:bug This is a clearly a bug provider:amazon AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants