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_emr_managed_scaling_policy: Ensure cluster_id attribute is saved during import and handle additional disappears cases #15541

Merged
merged 1 commit into from
Oct 7, 2020

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Oct 7, 2020

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

* resource/aws_emr_managed_scaling_policy: Ensure `cluster_id` attribute is properly saved during import
* resource/aws_emr_managed_scaling_policy: Handle additional cases where resource should be removed from Terraform state

The Terraform Plugin SDK version 2.0.4 upgrade fixed something with ImportStateVerify testing, which now catches these arguments that were not properly being set during Read.

The EMR API behavior also seems to have changed since the initial resource release where it will now return an error on GetManagedScalingPolicy when the Cluster is shutting down or finished and not returning an error when the policy has been removed. This change set updates the Read logic to handle these two new scenarios.

The test configuration change to include keep_job_flow_alive_when_no_steps is to ensure the EMR Cluster shutting down is not because it has no pre-defined steps to execute and prevent any inconsistent behaviors because of that timing.

Previously:

=== CONT  TestAccAwsEmrManagedScalingPolicy_basic
TestAccAwsEmrManagedScalingPolicy_basic: resource_aws_emr_managed_scaling_policy_test.go:17: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
(map[string]string) {
}
(map[string]string) (len=1) {
(string) (len=10) "cluster_id": (string) (len=15) "j-16JIKGI1IWJ4W"
}
TestAccAwsEmrManagedScalingPolicy_basic: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: d29fc848-2bcc-459c-ad4a-bb4b09f90060
--- FAIL: TestAccAwsEmrManagedScalingPolicy_basic (480.77s)

=== CONT  TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits: resource_aws_emr_managed_scaling_policy_test.go:41: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
(map[string]string) {
}
(map[string]string) (len=1) {
(string) (len=10) "cluster_id": (string) (len=15) "j-3Q9RF3NQJGV46"
}
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: 3faa75d9-7536-4289-9684-4ea6a13f2bfa
--- FAIL: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits (457.36s)

=== CONT  TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits: resource_aws_emr_managed_scaling_policy_test.go:65: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
(map[string]string) {
}
(map[string]string) (len=1) {
(string) (len=10) "cluster_id": (string) (len=14) "j-9DEX7HNVJG1N"
}
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: 712836ec-ab7e-4f9f-95ed-413fd9a7729c
--- FAIL: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits (474.25s)

=== CONT  TestAccAwsEmrManagedScalingPolicy_disappears
TestAccAwsEmrManagedScalingPolicy_disappears: resource_aws_emr_managed_scaling_policy_test.go:89: Step 1/1 error: Expected a non-empty plan, but got an empty plan!
TestAccAwsEmrManagedScalingPolicy_disappears: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: 98a29b6f-3c80-47ca-99ac-3f870426a93c
--- FAIL: TestAccAwsEmrManagedScalingPolicy_disappears (483.72s)

Output from acceptance testing:

--- PASS: TestAccAwsEmrManagedScalingPolicy_disappears (453.77s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_basic (456.74s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits (467.67s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits (490.01s)

…is saved during import and handle additional disappears cases

The Terraform Plugin SDK version 2.0.4 upgrade fixed something with `ImportStateVerify` testing, which now catches these arguments taht were not properly being set during `Read`.

The EMR API behavior seems to have changed since the initial resource release where it will now return an error on `GetManagedScalingPolicy` when the Cluster is shutting down or finished and not returning an error when the policy has been removed. This change set updates the `Read` logic to handle these two new scenarios.

The test configuration change to include `keep_job_flow_alive_when_no_steps` is to ensure the EMR Cluster shutting down is not because it has no pre-defined steps to execute and prevent any inconsistent behaviors because of that timing.

Previously:

```
=== CONT  TestAccAwsEmrManagedScalingPolicy_basic
TestAccAwsEmrManagedScalingPolicy_basic: resource_aws_emr_managed_scaling_policy_test.go:17: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
(map[string]string) {
}
(map[string]string) (len=1) {
(string) (len=10) "cluster_id": (string) (len=15) "j-16JIKGI1IWJ4W"
}
TestAccAwsEmrManagedScalingPolicy_basic: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: d29fc848-2bcc-459c-ad4a-bb4b09f90060
--- FAIL: TestAccAwsEmrManagedScalingPolicy_basic (480.77s)

=== CONT  TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits: resource_aws_emr_managed_scaling_policy_test.go:41: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
(map[string]string) {
}
(map[string]string) (len=1) {
(string) (len=10) "cluster_id": (string) (len=15) "j-3Q9RF3NQJGV46"
}
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: 3faa75d9-7536-4289-9684-4ea6a13f2bfa
--- FAIL: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits (457.36s)

=== CONT  TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits: resource_aws_emr_managed_scaling_policy_test.go:65: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
(map[string]string) {
}
(map[string]string) (len=1) {
(string) (len=10) "cluster_id": (string) (len=14) "j-9DEX7HNVJG1N"
}
TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: 712836ec-ab7e-4f9f-95ed-413fd9a7729c
--- FAIL: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits (474.25s)

=== CONT  TestAccAwsEmrManagedScalingPolicy_disappears
TestAccAwsEmrManagedScalingPolicy_disappears: resource_aws_emr_managed_scaling_policy_test.go:89: Step 1/1 error: Expected a non-empty plan, but got an empty plan!
TestAccAwsEmrManagedScalingPolicy_disappears: testing_new.go:62: Error running post-test destroy, there may be dangling resources: ValidationException: A job flow that is shutting down, terminated, or finished may not be modified.
  status code: 400, request id: 98a29b6f-3c80-47ca-99ac-3f870426a93c
--- FAIL: TestAccAwsEmrManagedScalingPolicy_disappears (483.72s)
```

Output from acceptance testing:

```
--- PASS: TestAccAwsEmrManagedScalingPolicy_disappears (453.77s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_basic (456.74s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits (467.67s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits (490.01s)
```
@bflad bflad added the bug Addresses a defect in current functionality. label Oct 7, 2020
@bflad bflad requested a review from a team October 7, 2020 17:06
@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/emr Issues and PRs that pertain to the emr service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Oct 7, 2020
@gdavison gdavison self-assigned this Oct 7, 2020
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

--- PASS: TestAccAwsEmrManagedScalingPolicy_basic (457.13s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumOndemandCapacityUnits (477.22s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_disappears (480.92s)
--- PASS: TestAccAwsEmrManagedScalingPolicy_ComputeLimits_MaximumCoreCapacityUnits (534.14s)

@bflad bflad added this to the v3.10.0 milestone Oct 7, 2020
@bflad bflad merged commit 626b692 into master Oct 7, 2020
@bflad bflad deleted the b-aws_emr_managed_scaling_policy-import branch October 7, 2020 19:47
bflad added a commit that referenced this pull request Oct 7, 2020
@ghost
Copy link

ghost commented Oct 9, 2020

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 7, 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 as resolved and limited conversation to collaborators Nov 7, 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/emr Issues and PRs that pertain to the emr service. size/M 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