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

add retry to avoid ECR get auth token failed for some transient issues #1886

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion nodeadm/internal/aws/ecr/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"fmt"
"net"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/ecr"
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/aws/imds"
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/system"
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/util"
)

// Returns the base64 encoded authorization token string for ECR of the format "AWS:XXXXX"
Expand All @@ -19,7 +21,11 @@ func GetAuthorizationToken(awsRegion string) (string, error) {
return "", err
}
ecrClient := ecr.NewFromConfig(awsConfig)
token, err := ecrClient.GetAuthorizationToken(context.Background(), &ecr.GetAuthorizationTokenInput{})
var token *ecr.GetAuthorizationTokenOutput
err = util.RetryExponentialBackoff(3, 2*time.Second, func() error {
token, err = ecrClient.GetAuthorizationToken(context.Background(), &ecr.GetAuthorizationTokenInput{})
return err
})
if err != nil {
return "", err
}
Expand Down
Loading