Skip to content

Add awslogs-endpoint for isolated regions via sdk go v2 #4570

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

Merged
merged 3 commits into from
Apr 30, 2025

Conversation

Yiyuanzzz
Copy link
Contributor

@Yiyuanzzz Yiyuanzzz commented Apr 14, 2025

Summary

Currently agent rely on aws-sdk-go v1 to add awslogs-endpoint for all isolated regions when awslogs driver is configured for the container, This PR migrates the logic to use aws-sdk-go-v2 instead.

Implementation details

  • we rely on cloudwatchlogs package from aws-sdk-go-v2 to resolve the cloudwatch endpoint for all the isolated regions

Testing

New tests cover the changes:

Description for the changelog

Enhancement: Add awslogs-endpoint for isolated regions via aws-sdk-go v2

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Yiyuanzzz Yiyuanzzz requested a review from a team as a code owner April 14, 2025 19:10
@Yiyuanzzz Yiyuanzzz changed the title [WIP]Sdkv2/endpoint Add awslogs-endpoint for isolated regions via sdk go v2 Apr 14, 2025
logger.Warn("No partition resolved for region. Using AWS default", logger.Fields{
dnsSuffix := "amazonaws.com"
partition := awsrulesfn.GetPartition(region)
if partition == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have (or need) tests that cover the various partitions where the partition values may differ from the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/prateekchaudhry/amazon-ecs-agent/blob/8d0adff66e63ea9b94852966c4e4bdf1af511f04/agent/engine/docker_task_engine_test.go#L2949
Yes, we do! TestCreateContainerAwslogsLogDriver explicitly covers various isolated regions across different AWS partitions. It validates the generated awslogs-endpoint against the expected endpoint for each isolated region

ShelbyZ
ShelbyZ previously approved these changes Apr 14, 2025

// aws-sdk-go-v2 does not export partition metadata, so copy the files from vendor to make it accessible.

//go:generate cp ../vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/awsrulesfn/partition.go ../vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/awsrulesfn/partitions.go .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious if the go generate needs to be run manually to keep partitions.go updated, or if is automated in some way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whenever SDK dependencies is updated in go.mod and static checks fail due to go generate producing a diff in the future, we'll need to run go generate manually to ensure that the generated files stay in sync with the vendored AWS SDK files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the gogenerate target keep it updated? That is each time there is an sdk update, there needs to be a gogenerate run to keep this updated? Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's correct

@prateekchaudhry prateekchaudhry dismissed their stale review April 15, 2025 20:11

Requesting comments to be addressed

amogh09
amogh09 previously approved these changes Apr 18, 2025
@Yiyuanzzz Yiyuanzzz enabled auto-merge (squash) April 18, 2025 19:16
@Yiyuanzzz Yiyuanzzz disabled auto-merge April 18, 2025 19:21
@Yiyuanzzz Yiyuanzzz enabled auto-merge (squash) April 18, 2025 19:28
@Yiyuanzzz Yiyuanzzz dismissed stale reviews from prateekchaudhry and amogh09 via 186b582 April 18, 2025 21:54
amogh09
amogh09 previously approved these changes Apr 18, 2025
@@ -1954,27 +1954,20 @@ func (engine *DockerTaskEngine) createContainer(task *apitask.Task, container *a
} else {
Copy link
Contributor

@prateekchaudhry prateekchaudhry Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, non blocking: This is a short term solution only for specific regions comment is specific to the else section for isolated regions as per my understanding. We can consider moving the comment to relevant block.

@Yiyuanzzz Yiyuanzzz merged commit c87fccb into aws:dev Apr 30, 2025
40 of 41 checks passed
singholt pushed a commit that referenced this pull request May 1, 2025
timj-hh pushed a commit to timj-hh/amazon-ecs-agent that referenced this pull request Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants