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_elasticache_parameter_group: Handle API reset issues with reserved-memory parameter #6752

Merged

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Dec 7, 2018

The Elasticache API is currently always returning an InternalFailure error when attempting to reset the reserved-memory parameter. The Terraform resource previously provided an unhelpful timeout error with no way to workaround the behavior to properly update reserved-memory to a new value or switch to the reserved-memory-percentage parameter.

The resource now employs some handling to skip the problematic reserved-memory reset, but only after its attempted before, in case the Elasticache API is fixed in the future.

Changes:

  • resource/aws_elasticache_parameter_group: Code and acceptance test workarounds for reserved-memory parameter always returning an error during update
  • tests/resource/aws_elasticache_parameter_group: Switch from bespoke import test to always testing import
  • tests/resource/aws_elasticache_parameter_group: Other minor refactoring to clean acceptance testing

Previously failing acceptance testing:

--- FAIL: TestAccAWSElasticacheParameterGroup_removeReservedMemoryParameter (76.81s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: Error resetting Cache Parameter Group: timeout while waiting for state to become 'success' (timeout: 30s)

--- FAIL: TestAccAWSElasticacheParameterGroup_updateReservedMemoryParameter (76.81s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: Error resetting Cache Parameter Group: timeout while waiting for state to become 'success' (timeout: 30s)

--- FAIL: TestAccAWSElasticacheParameterGroup_switchReservedMemoryParameter (77.01s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: Error resetting Cache Parameter Group: timeout while waiting for state to become 'success' (timeout: 30s)

Output from acceptance testing:

--- PASS: TestAccAWSElasticacheParameterGroup_basic (19.94s)
--- PASS: TestAccAWSElasticacheParameterGroup_UppercaseName (23.09s)
--- PASS: TestAccAWSElasticacheParameterGroup_Description (33.43s)
--- PASS: TestAccAWSElasticacheParameterGroup_addParameter (34.66s)
--- PASS: TestAccAWSElasticacheParameterGroup_removeAllParameters (43.51s)
--- PASS: TestAccAWSElasticacheParameterGroup_removeReservedMemoryParameter (43.57s)
--- PASS: TestAccAWSElasticacheParameterGroup_updateReservedMemoryParameter (86.12s)
--- PASS: TestAccAWSElasticacheParameterGroup_switchReservedMemoryParameter (95.82s)

…sues with reserved-memory parameter where possible

The Elasticache API is currently always returning an `InternalFailure` when attempting to reset the `reserved-memory` parameter. The resource previously provided an uphelpful timeout error with no way to workaround the behavior to properly update `reserved-memory` to a new value or switch to the `reserved-memory-percentage` parameter.

The resource now employs some handling to skip the `reserved-memory` reset, but only after its attempted before in case the Elasticache API is fixed in the future.

Changes:

* resource/aws_elasticache_parameter_group: Code and acceptance test workarounds for `reserved-memory` parameter always returning an error during update
* tests/resource/aws_elasticache_parameter_group: Switch from bespoke import test to always testing import
* tests/resource/aws_elasticache_parameter_group: Other minor refactoring to clean acceptance testing

Previously failing acceptance testing:

```
--- FAIL: TestAccAWSElasticacheParameterGroup_removeReservedMemoryParameter (76.81s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: Error resetting Cache Parameter Group: timeout while waiting for state to become 'success' (timeout: 30s)

--- FAIL: TestAccAWSElasticacheParameterGroup_updateReservedMemoryParameter (76.81s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: Error resetting Cache Parameter Group: timeout while waiting for state to become 'success' (timeout: 30s)

--- FAIL: TestAccAWSElasticacheParameterGroup_switchReservedMemoryParameter (77.01s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: 1 error occurred:
        	* aws_elasticache_parameter_group.bar: Error resetting Cache Parameter Group: timeout while waiting for state to become 'success' (timeout: 30s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSElasticacheParameterGroup_basic (19.94s)
--- PASS: TestAccAWSElasticacheParameterGroup_UppercaseName (23.09s)
--- PASS: TestAccAWSElasticacheParameterGroup_Description (33.43s)
--- PASS: TestAccAWSElasticacheParameterGroup_addParameter (34.66s)
--- PASS: TestAccAWSElasticacheParameterGroup_removeAllParameters (43.51s)
--- PASS: TestAccAWSElasticacheParameterGroup_removeReservedMemoryParameter (43.57s)
--- PASS: TestAccAWSElasticacheParameterGroup_updateReservedMemoryParameter (86.12s)
--- PASS: TestAccAWSElasticacheParameterGroup_switchReservedMemoryParameter (95.82s)
```
@bflad bflad added bug Addresses a defect in current functionality. service/elasticache Issues and PRs that pertain to the elasticache service. labels Dec 7, 2018
@bflad bflad requested a review from a team December 7, 2018 04:02
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Dec 7, 2018
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM with some minor comments

}
}

if !tryReservedMemoryPercentageWorkaround {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove this bit. I only see it becoming false on line 230 and we break there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That break is for the inner for loop. We need this boolean to determine the rest of this flow.


// The reserved-memory-percentage parameter does not exist in redis2.6 and redis2.8
family := d.Get("family").(string)
if family == "redis2.6" || family == "redis2.8" {
Copy link
Member

Choose a reason for hiding this comment

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

We should add a log here or I'm even tempted to error out if this value has changed while using this family

Suggested change
if family == "redis2.6" || family == "redis2.8" {
log.Printf("[WARN] unable to update `reserved-memory-percentage` while family is %q: %s", family, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a warning log in there 👍

@bflad bflad added this to the v1.52.0 milestone Dec 7, 2018
…d-memory parameter reset with redis2.6 and redis2.8
@bflad bflad merged commit 9490017 into master Dec 7, 2018
@bflad bflad deleted the b-aws_elasticache_parameter_group-reserved-memory-reset branch December 7, 2018 19:04
bflad added a commit that referenced this pull request Dec 7, 2018
@bflad
Copy link
Contributor Author

bflad commented Dec 13, 2018

This has been released in version 1.52.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 1, 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 1, 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. documentation Introduces or discusses updates to documentation. service/elasticache Issues and PRs that pertain to the elasticache service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants