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

aws/EC2Metadata: Reduces timeout and number of max retries for EC2Metadata client #3028

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
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
80 changes: 80 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,83 @@
Release v1.27.0 (2020-01-02)
===

### Service Client Updates
* `service/ce`: Updates service documentation
* `service/ecr`: Updates service waiters
* Adds waiters for ImageScanComplete and LifecyclePolicyPreviewComplete
* `service/lex-models`: Updates service documentation
* `service/lightsail`: Updates service API and documentation
* This release adds support for Certificate Authority (CA) certificate identifier to managed databases in Amazon Lightsail.

### SDK Features
* `services/transcribestreamingservice`: Support for Amazon Transcribe Streaming ([#3048](https://github.com/aws/aws-sdk-go/pull/3048))
* The SDK now supports the Amazon Transcribe Streaming APIs by utilizing event stream encoding over HTTP/2
* See [Amazon Transcribe Developer Guide](https://docs.aws.amazon.com/transcribe/latest/dg)
* Fixes [#2487](https://github.com/aws/aws-sdk-go/issues/2487)

Release v1.26.8 (2019-12-23)
===

### Service Client Updates
* `service/detective`: Updates service documentation
* `service/fsx`: Updates service API, documentation, and paginators
* `service/health`: Updates service API, documentation, and paginators
* With this release, you can now centrally aggregate AWS Health events from all accounts in your AWS organization. Visit AWS Health documentation to learn more about enabling and using this feature: https://docs.aws.amazon.com/health/latest/ug/organizational-view-health.html.

Release v1.26.7 (2019-12-20)
===

### Service Client Updates
* `service/devicefarm`: Updates service API, documentation, and paginators
* Introduced browser testing support through AWS Device Farm
* `service/ec2`: Updates service API and documentation
* This release introduces the ability to tag key pairs, placement groups, export tasks, import image tasks, import snapshot tasks and export image tasks. You can use tags to organize and identify your resources for cost allocation.
* `service/eks`: Updates service API and documentation
* `service/pinpoint`: Updates service API and documentation
* This release of the Amazon Pinpoint API introduces versioning support for message templates.
* `service/rds`: Updates service API and documentation
* This release adds an operation that enables users to specify whether a database is restarted when its SSL/TLS certificate is rotated. Only customers who do not use SSL/TLS should use this operation.
* `service/redshift`: Updates service documentation
* Documentation updates for Amazon Redshift RA3 node types.
* `service/securityhub`: Updates service API and documentation
* `service/ssm`: Updates service API and documentation
* This release updates the attachments support to include AttachmentReference source for Automation documents.
* `service/transcribe`: Updates service API, documentation, and paginators

Release v1.26.6 (2019-12-19)
===

### Service Client Updates
* `service/codestar-connections`: Adds new service
* `service/dlm`: Updates service API and documentation
* `service/ec2`: Updates service API and documentation
* We are updating the supportedRootDevices field to supportedRootDeviceTypes for DescribeInstanceTypes API to ensure that the actual value is returned, correcting a previous error in the model.
* `service/gamelift`: Updates service API and documentation
* Amazon GameLift now supports ARNs for all key GameLift resources, tagging for GameLift resource authorization management, and updated documentation that articulates GameLift's resource authorization strategy.
* `service/lex-models`: Updates service API and documentation
* `service/personalize-runtime`: Updates service API and documentation
* `service/ssm`: Updates service API and documentation
* This release allows customers to add tags to Automation execution, enabling them to sort and filter executions in different ways, such as by resource, purpose, owner, or environment.
* `service/transcribe`: Updates service API and documentation

Release v1.26.5 (2019-12-18)
===

### Service Client Updates
* `service/cloudfront`: Updates service documentation
* Documentation updates for CloudFront
* `service/ec2`: Updates service API and documentation
* This release introduces the ability to tag Elastic Graphics accelerators. You can use tags to organize and identify your accelerators for cost allocation.
* `service/opsworkscm`: Updates service API and documentation
* AWS OpsWorks CM now supports tagging, and tag-based access control, of servers and backups.
* `service/resourcegroupstaggingapi`: Updates service documentation
* Documentation updates for resourcegroupstaggingapi
* `service/s3`: Updates service documentation
* Updates Amazon S3 endpoints allowing you to configure your client to opt-in to using S3 with the us-east-1 regional endpoint, instead of global.

### SDK Bugs
* `aws/request`: Fix shouldRetry behavior for nested errors ([#3017](https://github.com/aws/aws-sdk-go/pull/3017))

Release v1.26.4 (2019-12-17)
===

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
### SDK Enhancements

### SDK Bugs
* `aws/session`: Fix client init not exposing endpoint resolve error ([#3059](https://github.com/aws/aws-sdk-go/pull/3059))
* Fixes the SDK API clients not surfacing endpoint resolution errors, when the EndpointResolver is unable to resolve an endpoint for the client and region.
* `aws/ec2metadata` : Reduces request timeout for EC2Metadata client along with maximum number of retries ([#3028](https://github.com/aws/aws-sdk-go/pull/3028))
* Reduces latency while fetching response from EC2Metadata client running in a container to around 3 seconds
* Fixes [#2972](https://github.com/aws/aws-sdk-go/issues/2972)
2 changes: 1 addition & 1 deletion aws/corehandlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func handleSendError(r *request.Request, err error) {
}
// Catch all request errors, and let the default retrier determine
// if the error is retryable.
r.Error = awserr.New("RequestError", "send request failed", err)
r.Error = awserr.New(request.ErrCodeRequestError, "send request failed", err)

// Override the error with a context canceled error, if that was canceled.
ctx := r.Context()
Expand Down
2 changes: 1 addition & 1 deletion aws/csm/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func getMetricException(err awserr.Error) metricException {
code := err.Code()

switch code {
case "RequestError",
case request.ErrCodeRequestError,
request.ErrCodeSerialization,
request.CanceledErrorCode:
return sdkException{
Expand Down
6 changes: 3 additions & 3 deletions aws/csm/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func TestReportingMetrics(t *testing.T) {
req := request.New(*sess.Config, md, sess.Handlers, client.DefaultRetryer{NumMaxRetries: 3}, op, nil, nil)
errs := []error{
awserr.New("AWSError", "aws error", nil),
awserr.New("RequestError", "sdk error", nil),
awserr.New(request.ErrCodeRequestError, "sdk error", nil),
nil,
}
resps := []*http.Response{
Expand Down Expand Up @@ -182,8 +182,8 @@ func TestReportingMetrics(t *testing.T) {
},
{
"Type": "ApiCallAttempt",
"SdkException": "RequestError",
"SdkExceptionMessage": "RequestError: sdk error",
"SdkException": request.ErrCodeRequestError,
"SdkExceptionMessage": request.ErrCodeRequestError+": sdk error",
"HttpStatusCode": float64(500),
},
{
Expand Down
15 changes: 11 additions & 4 deletions aws/ec2metadata/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ func TestMetadataNotAvailable(t *testing.T) {
Status: http.StatusText(int(0)),
Body: ioutil.NopCloser(bytes.NewReader([]byte{})),
}
r.Error = awserr.New("RequestError", "send request failed", nil)
r.Error = awserr.New(request.ErrCodeRequestError, "send request failed", nil)
r.Retryable = aws.Bool(true) // network errors are retryable
})

Expand Down Expand Up @@ -997,9 +997,12 @@ func TestRequestTimeOut(t *testing.T) {

c.Handlers.Complete.PushBack(op.addToOperationPerformedList)

start := time.Now()
resp, err := c.GetMetadata("/some/path")

expectedOperationsPerformed := []string{"GetToken", "GetMetadata"}
if e, a := 1*time.Second, time.Since(start); e < a {
t.Fatalf("expected duration of test to be less than %v, got %v", e, a)
}

if e, a := "IMDSProfileForSDKGo", resp; e != a {
t.Fatalf("Expected %v, got %v", e, a)
Expand All @@ -1009,13 +1012,16 @@ func TestRequestTimeOut(t *testing.T) {
t.Fatalf("Expected no error, got %v", err)
}

expectedOperationsPerformed := []string{"GetToken", "GetMetadata"}
if e, a := expectedOperationsPerformed, op.operationsPerformed; !reflect.DeepEqual(e, a) {
t.Fatalf("expect %v operations, got %v", e, a)
}

start = time.Now()
resp, err = c.GetMetadata("/some/path")

expectedOperationsPerformed = []string{"GetToken", "GetMetadata", "GetMetadata"}
if e, a := 1*time.Second, time.Since(start); e < a {
t.Fatalf("expected duration of test to be less than %v, got %v", e, a)
}

if e, a := "IMDSProfileForSDKGo", resp; e != a {
t.Fatalf("Expected %v, got %v", e, a)
Expand All @@ -1025,6 +1031,7 @@ func TestRequestTimeOut(t *testing.T) {
t.Fatalf("Expected no error, got %v", err)
}

expectedOperationsPerformed = []string{"GetToken", "GetMetadata", "GetMetadata"}
if e, a := expectedOperationsPerformed, op.operationsPerformed; !reflect.DeepEqual(e, a) {
t.Fatalf("expect %v operations, got %v", e, a)
}
Expand Down
4 changes: 3 additions & 1 deletion aws/ec2metadata/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ func NewClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegio
// use a shorter timeout than default because the metadata
// service is local if it is running, and to fail faster
// if not running on an ec2 instance.
Timeout: 5 * time.Second,
Timeout: 1 * time.Second,
}
// max number of retries on the client operation
cfg.MaxRetries = aws.Int(2)
}

svc := &EC2Metadata{
Expand Down
2 changes: 1 addition & 1 deletion aws/ec2metadata/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestClientOverrideDefaultHTTPClientTimeout(t *testing.T) {
t.Errorf("expect %v, not to equal %v", e, a)
}

if e, a := 5*time.Second, svc.Config.HTTPClient.Timeout; e != a {
if e, a := 1*time.Second, svc.Config.HTTPClient.Timeout; e != a {
t.Errorf("expect %v to be %v", e, a)
}
}
Expand Down
2 changes: 1 addition & 1 deletion aws/ec2metadata/token_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (t *tokenProvider) fetchTokenHandler(r *request.Request) {

// Check if request timed out while waiting for response
if e, ok := requestFailureError.OrigErr().(awserr.Error); ok {
if e.Code() == "RequestError" {
if e.Code() == request.ErrCodeRequestError {
atomic.StoreUint32(&t.disabled, 1)
}
}
Expand Down
Loading