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

resource/aws_kinesis_stream: Retry deletion on LimitExceededException #3108

Merged
merged 2 commits into from
Feb 9, 2018

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Jan 23, 2018

This is to address the following test failure:

=== RUN   TestAccAWSKinesisStream_shardLevelMetrics
--- FAIL: TestAccAWSKinesisStream_shardLevelMetrics (149.15s)
    testing.go:573: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.
        
        Error: Error applying: 1 error(s) occurred:
        
        * aws_kinesis_stream.test_stream (destroy): 1 error(s) occurred:
        
        * aws_kinesis_stream.test_stream: LimitExceededException: Rate exceeded for stream terraform-kinesis-test-6203015600745191945 under account *******.
            status code: 400, request id: e8d516ee-dc31-d34e-ba35-e408e9363a84
        
        State: aws_kinesis_stream.test_stream:
          ID = arn:aws:kinesis:us-west-2:*******:stream/terraform-kinesis-test-6203015600745191945
          provider = provider.aws
          arn = arn:aws:kinesis:us-west-2:*******:stream/terraform-kinesis-test-6203015600745191945
          encryption_type = NONE
          kms_key_id = 
          name = terraform-kinesis-test-6203015600745191945
          retention_period = 24
          shard_count = 2
          shard_level_metrics.# = 1
          shard_level_metrics.123700221 = IncomingBytes
          tags.% = 1
          tags.Name = tf-test

Snippet from debug log:

2018/01/23 08:21:58 [DEBUG] [aws-sdk-go] DEBUG: Response kinesis/DeleteStream Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 143
Content-Type: application/x-amz-json-1.1
Date: Tue, 23 Jan 2018 08:21:57 GMT
Server: Apache-Coyote/1.1
X-Amz-Id-2: CjcrmKKLBS6budOskFaF9os926/iICeccBe89jmhfDQocgvMubxeBLkvJSnNbMfg9yJMCxTYGMHDkYAiibQUT51f0YmExBsC
X-Amzn-Requestid: e8d516ee-dc31-d34e-ba35-e408e9363a84

{"__type":"LimitExceededException","message":"Rate exceeded for stream terraform-kinesis-test-6203015600745191945 under account *REDACTED*."}
-----------------------------------------------------

Test results

=== RUN   TestAccAWSKinesisStream_basic
--- PASS: TestAccAWSKinesisStream_basic (94.90s)
=== RUN   TestAccAWSKinesisStream_importBasic
--- PASS: TestAccAWSKinesisStream_importBasic (95.57s)
=== RUN   TestAccAWSKinesisStream_encryptionWithoutKmsKeyThrowsError
--- PASS: TestAccAWSKinesisStream_encryptionWithoutKmsKeyThrowsError (108.26s)
=== RUN   TestAccAWSKinesisStream_retentionPeriod
--- PASS: TestAccAWSKinesisStream_retentionPeriod (162.46s)
=== RUN   TestAccAWSKinesisStream_shardLevelMetrics
--- PASS: TestAccAWSKinesisStream_shardLevelMetrics (173.29s)
=== RUN   TestAccAWSKinesisStream_shardCount
--- PASS: TestAccAWSKinesisStream_shardCount (214.29s)
=== RUN   TestAccAWSKinesisStream_createMultipleConcurrentStreams
--- PASS: TestAccAWSKinesisStream_createMultipleConcurrentStreams (237.69s)
=== RUN   TestAccAWSKinesisStream_encryption
--- PASS: TestAccAWSKinesisStream_encryption (267.77s)

@radeksimko radeksimko added bug Addresses a defect in current functionality. service/kinesis Issues and PRs that pertain to the kinesis service. labels Jan 23, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

This LGTM to me as-is, however would this be similarly or better handled with modifying the existing client.kinesisconn.Handlers.Retry? https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/config.go#L455-L467

@radeksimko
Copy link
Member Author

That's a very valid point - I'll rework that. I just checked the SDK's retry mechanism and it looks like it's very close to ours:
https://github.com/aws/aws-sdk-go/blob/4bd6f8bc55ec7eaf68efb9ec72983fbc0b79aba2/aws/client/default_retryer.go#L38

@radeksimko
Copy link
Member Author

radeksimko commented Jan 23, 2018

Actually I'm not so sure, I think the reason we keep retry logic for Create here is because there are different contexts in which LimitExceededException is raised. I assume breaching some hard AWS limits can be context we don't want to retry on.

It doesn't matter for Describe & List, because these won't ever run into such situation, but I'm not so sure about Create and Delete. 🤔

@bflad
Copy link
Contributor

bflad commented Jan 23, 2018

Would something like this maybe help?

	client.kinesisconn.Handlers.Retry.PushBack(func(r *request.Request) {
		err, ok := r.Error.(awserr.Error)
		if !ok || err == nil {
			return
		}
		if err.Code() == kinesis.ErrCodeLimitExceededException {
			if !strings.HasPrefix(r.Operation.Name, "Describe") && !strings.HasPrefix(r.Operation.Name, "List") && !strings.Contains(err.Message(), "Rate exceeded for stream") {
				return
			}
			r.Retryable = aws.Bool(true)
		}
	})

@radeksimko radeksimko force-pushed the b-kinesis-stream-retry branch from 2a12f14 to ee415f4 Compare February 9, 2018 11:13
@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label Feb 9, 2018
@radeksimko
Copy link
Member Author

Done. 😉

@radeksimko radeksimko merged commit ede5def into master Feb 9, 2018
@radeksimko radeksimko deleted the b-kinesis-stream-retry branch February 9, 2018 11:16
@bflad
Copy link
Contributor

bflad commented Feb 9, 2018

This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

jocgir added a commit to coveooss/terraform-provider-aws that referenced this pull request Feb 12, 2018
* commit '5293a0e3b1366ee16d8742b9b2354781a79bfbd9': (224 commits)
  v1.9.0
  Update CHANGELOG for hashicorp#1101 and hashicorp#3283
  docs/resource/aws_sns_platform_application: Add note about platform_credential and platform_principal hashing
  resource/aws_sns_platform_application: Refactor ID parsing to its own function, use testing.T in testAccAwsSnsPlatformApplicationPlatformFromEnv
  Add lambda example (hashicorp#3168)
  Update CHANGELOG for hashicorp#3157
  docs/data-source/aws_region: Remove now deprecated current argument
  data-source/aws_region: Refactor logic into findRegionByEc2Endpoint and findRegionByName functions
  Update CHANGELOG for hashicorp#3301
  Update CHANGELOG for hashicorp#2559 and hashicorp#3240
  Update CHANGELOG.md
  resource/aws_kinesis_stream: Retry deletion on LimitExceededException (hashicorp#3108)
  Update CHANGELOG.md
  resource/aws_dynamodb_table_item: Cleanup + add missing bits
  Added dynamodb_table_item resource hashicorp#517
  Update CHANGELOG.md
  New Resource: aws_cloud9_environment_ec2
  Update CHANGELOG.md
  Fixed markdown typo in docs
  resource/aws_kinesis_firehose_delivery_stream: Prevent crashes on empty CloudWatchLoggingOptions and fix extended_s3_configuration kms_key_arn
  ...

# Conflicts:
#	aws/validators.go
jocgir added a commit to coveooss/terraform-provider-aws that referenced this pull request Feb 12, 2018
…parameters-features

* commit '5293a0e3b1366ee16d8742b9b2354781a79bfbd9': (752 commits)
  v1.9.0
  Update CHANGELOG for hashicorp#1101 and hashicorp#3283
  docs/resource/aws_sns_platform_application: Add note about platform_credential and platform_principal hashing
  resource/aws_sns_platform_application: Refactor ID parsing to its own function, use testing.T in testAccAwsSnsPlatformApplicationPlatformFromEnv
  Add lambda example (hashicorp#3168)
  Update CHANGELOG for hashicorp#3157
  docs/data-source/aws_region: Remove now deprecated current argument
  data-source/aws_region: Refactor logic into findRegionByEc2Endpoint and findRegionByName functions
  Update CHANGELOG for hashicorp#3301
  Update CHANGELOG for hashicorp#2559 and hashicorp#3240
  Update CHANGELOG.md
  resource/aws_kinesis_stream: Retry deletion on LimitExceededException (hashicorp#3108)
  Update CHANGELOG.md
  resource/aws_dynamodb_table_item: Cleanup + add missing bits
  Added dynamodb_table_item resource hashicorp#517
  Update CHANGELOG.md
  New Resource: aws_cloud9_environment_ec2
  Update CHANGELOG.md
  Fixed markdown typo in docs
  resource/aws_kinesis_firehose_delivery_stream: Prevent crashes on empty CloudWatchLoggingOptions and fix extended_s3_configuration kms_key_arn
  ...

# Conflicts:
#	aws/resource_aws_ssm_parameter_test.go
@ghost
Copy link

ghost commented Apr 8, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/kinesis Issues and PRs that pertain to the kinesis service. size/S Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants