Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tinnywang committed Dec 6, 2024
1 parent 0ed884b commit 58d51ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions ecs-agent/ec2/ec2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/config"
ec2sdk "github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
Expand Down Expand Up @@ -65,9 +64,7 @@ func NewClientImpl(awsRegion string) (Client, error) {
context.TODO(),
config.WithRegion(awsRegion),
config.WithCredentialsProvider(credentialsProvider),
config.WithRetryer(func() aws.Retryer {
return retry.AddWithMaxAttempts(retry.NewStandard(), clientRetriesNum)
}),
config.WithRetryMaxAttempts(clientRetriesNum),
)
if err != nil {
return nil, err
Expand Down
9 changes: 3 additions & 6 deletions ecs-agent/ec2/ec2_metadata_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"

Expand Down Expand Up @@ -96,7 +94,8 @@ type ec2MetadataClientImpl struct {
client HttpClient
}

// NewEC2MetadataClient creates an ec2metadata client to retrieve metadata
// NewEC2MetadataClient creates an ec2metadata client to retrieve metadata.
// Pass a non-nil HttpClient to mock behavior in tests.
func NewEC2MetadataClient(client HttpClient) (EC2MetadataClient, error) {
if client == nil {
credentialsProvider := providers.NewInstanceCredentialsCache(
Expand All @@ -107,9 +106,7 @@ func NewEC2MetadataClient(client HttpClient) (EC2MetadataClient, error) {
cfg, err := config.LoadDefaultConfig(
context.TODO(),
config.WithCredentialsProvider(credentialsProvider),
config.WithRetryer(func() aws.Retryer {
return retry.AddWithMaxAttempts(retry.NewStandard(), metadataRetries)
}),
config.WithRetryMaxAttempts(metadataRetries),
)
if err != nil {
return nil, err
Expand Down

0 comments on commit 58d51ed

Please sign in to comment.