Skip to content

Commit

Permalink
fix: timeout for ECR client
Browse files Browse the repository at this point in the history
The default for the AWS SDK does not contain a timeout and can cause the connection to hang.
  • Loading branch information
estahn committed Sep 30, 2021
1 parent e151055 commit 26bdc10
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/registry/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package registry

import (
"encoding/base64"
"net/http"
"os/exec"
"time"

Expand Down Expand Up @@ -149,7 +150,15 @@ func NewECRClient(region string, ecrDomain string) (*ECRClient, error) {
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
ecrClient := ecr.New(sess, &aws.Config{Region: aws.String(region)})

config := aws.NewConfig().
WithRegion(region).
WithCredentialsChainVerboseErrors(true).
WithHTTPClient(&http.Client{
Timeout: 3 * time.Second,
})

ecrClient := ecr.New(sess, config)

cache, err := ristretto.NewCache(&ristretto.Config{
NumCounters: 1e7, // number of keys to track frequency of (10M).
Expand Down

0 comments on commit 26bdc10

Please sign in to comment.