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

EMR Cluster Import Support #6498

Merged
merged 24 commits into from
Jan 11, 2019
Merged

Conversation

mbfrahry
Copy link
Member

@mbfrahry mbfrahry commented Nov 16, 2018

This PR finalizes adding support for Import on emr clusters #6498.
It fixes an issue where changing an optional value in a Set would force the recreation of the whole resource.
It removes all log errors in favor of returning an error message #3652.

@ghost ghost added size/L Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/emr Issues and PRs that pertain to the emr service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Nov 16, 2018
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Nov 20, 2018
@ghost ghost added size/L Managed by automation to categorize the size of a PR. and removed size/XL Managed by automation to categorize the size of a PR. labels Nov 20, 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.

Oh, EMR. 😅 Feel free to ping me directly to discuss anything!

@@ -202,14 +211,16 @@ func resourceAwsEMRCluster() *schema.Resource {
Required: false,
},
"ebs_config": {
Type: schema.TypeSet,
Type: schema.TypeList,
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this change intentional? If so, we should also set MaxItems: 1 as well - otherwise we should undo this change as its not reliable to migrate a Terraform state and configuration from a multiple element TypeSet to TypeList.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was intentional because of another issue that cropped up. I've since fixed both of these issues and we're back to TypeSet on ebs_config

@@ -238,6 +249,7 @@ func resourceAwsEMRCluster() *schema.Resource {
Optional: true,
DiffSuppressFunc: suppressEquivalentJsonDiffs,
ValidateFunc: validation.ValidateJsonString,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying not to introduce too much further scope creep into this pull request, but can you please add acceptance testing that attempts to update autoscaling_policy? I have a hunch that it will result in a permanent difference, especially with the new Set function. I think the same problem also applies to bid_price, instance_count, and especially instance_role. These attributes likely should be ForceNew: true if I'm right, but maybe I'm wrong.

I'm also not opposed to updating the resource documentation to discourage the usage of instance_group in preference of the (upcoming) aws_emr_instance_fleet and aws_emr_instance_group resources.


ebsConfig = append(ebsConfig, ebsAttrs)
if ig.EbsBlockDevices != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

range automatically can handle nil slices, so I don't believe this nil check is necessary: https://play.golang.org/p/-9ZKxKImPFH

autoscalingPolicyBytes, err := json.Marshal(ig.AutoScalingPolicy)
autoscalingPolicyString := string(autoscalingPolicyBytes)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: We should probably provide some context about this error here:

Suggested change
return nil, err
return nil, fmt.Errorf("error parsing EMR Cluster Instance Groups AutoScalingPolicy: %s", err)

ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"configurations",
"core_instance_count",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this still be ignoring the core_instance_* attributes?

ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"configurations",
"core_instance_count",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this still be ignoring core_instance_* attributes?

@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Dec 10, 2018
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. and removed size/XL Managed by automation to categorize the size of a PR. labels Jan 3, 2019
@mbfrahry
Copy link
Member Author

mbfrahry commented Jan 7, 2019

@bflad, this is ready for another pass. I've swapped everything back to Sets and added hashcodes to each one. Also, I'm doing a funky thing with CustomizeDiff that is preventing changing the autoscaling policy for an instance group to recreate the whole resource.

make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSEMRCluster'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccAWSEMRCluster -timeout 120m
=== RUN   TestAccAWSEMRCluster_basic
=== PAUSE TestAccAWSEMRCluster_basic
=== RUN   TestAccAWSEMRCluster_additionalInfo
=== PAUSE TestAccAWSEMRCluster_additionalInfo
=== RUN   TestAccAWSEMRCluster_configurationsJson
=== PAUSE TestAccAWSEMRCluster_configurationsJson
=== RUN   TestAccAWSEMRCluster_instance_group
=== PAUSE TestAccAWSEMRCluster_instance_group
=== RUN   TestAccAWSEMRCluster_instance_group_update
=== PAUSE TestAccAWSEMRCluster_instance_group_update
=== RUN   TestAccAWSEMRCluster_instance_group_EBSVolumeType_st1
=== PAUSE TestAccAWSEMRCluster_instance_group_EBSVolumeType_st1
=== RUN   TestAccAWSEMRCluster_updateAutoScalingPolicy
=== PAUSE TestAccAWSEMRCluster_updateAutoScalingPolicy
=== RUN   TestAccAWSEMRCluster_Kerberos_ClusterDedicatedKdc
=== PAUSE TestAccAWSEMRCluster_Kerberos_ClusterDedicatedKdc
=== RUN   TestAccAWSEMRCluster_security_config
=== PAUSE TestAccAWSEMRCluster_security_config
=== RUN   TestAccAWSEMRCluster_Step_Basic
=== PAUSE TestAccAWSEMRCluster_Step_Basic
=== RUN   TestAccAWSEMRCluster_Step_Multiple
=== PAUSE TestAccAWSEMRCluster_Step_Multiple
=== RUN   TestAccAWSEMRCluster_bootstrap_ordering
=== PAUSE TestAccAWSEMRCluster_bootstrap_ordering
=== RUN   TestAccAWSEMRCluster_terminationProtected
=== PAUSE TestAccAWSEMRCluster_terminationProtected
=== RUN   TestAccAWSEMRCluster_keepJob
=== PAUSE TestAccAWSEMRCluster_keepJob
=== RUN   TestAccAWSEMRCluster_visibleToAllUsers
=== PAUSE TestAccAWSEMRCluster_visibleToAllUsers
=== RUN   TestAccAWSEMRCluster_s3Logging
=== PAUSE TestAccAWSEMRCluster_s3Logging
=== RUN   TestAccAWSEMRCluster_tags
=== PAUSE TestAccAWSEMRCluster_tags
=== RUN   TestAccAWSEMRCluster_root_volume_size
=== PAUSE TestAccAWSEMRCluster_root_volume_size
=== RUN   TestAccAWSEMRCluster_custom_ami_id
=== PAUSE TestAccAWSEMRCluster_custom_ami_id
=== CONT  TestAccAWSEMRCluster_basic
=== CONT  TestAccAWSEMRCluster_Step_Multiple
=== CONT  TestAccAWSEMRCluster_tags
=== CONT  TestAccAWSEMRCluster_visibleToAllUsers
=== CONT  TestAccAWSEMRCluster_s3Logging
=== CONT  TestAccAWSEMRCluster_root_volume_size
=== CONT  TestAccAWSEMRCluster_custom_ami_id
=== CONT  TestAccAWSEMRCluster_instance_group
=== CONT  TestAccAWSEMRCluster_instance_group_EBSVolumeType_st1
=== CONT  TestAccAWSEMRCluster_Step_Basic
=== CONT  TestAccAWSEMRCluster_security_config
=== CONT  TestAccAWSEMRCluster_Kerberos_ClusterDedicatedKdc
=== CONT  TestAccAWSEMRCluster_instance_group_update
=== CONT  TestAccAWSEMRCluster_terminationProtected
=== CONT  TestAccAWSEMRCluster_keepJob
=== CONT  TestAccAWSEMRCluster_configurationsJson
=== CONT  TestAccAWSEMRCluster_bootstrap_ordering
=== CONT  TestAccAWSEMRCluster_updateAutoScalingPolicy
=== CONT  TestAccAWSEMRCluster_additionalInfo
--- PASS: TestAccAWSEMRCluster_instance_group_EBSVolumeType_st1 (503.34s)
--- PASS: TestAccAWSEMRCluster_additionalInfo (543.40s)
--- PASS: TestAccAWSEMRCluster_custom_ami_id (569.04s)
--- PASS: TestAccAWSEMRCluster_security_config (591.30s)
--- PASS: TestAccAWSEMRCluster_Step_Multiple (609.49s)
--- PASS: TestAccAWSEMRCluster_terminationProtected (609.60s)
--- PASS: TestAccAWSEMRCluster_bootstrap_ordering (617.58s)
--- PASS: TestAccAWSEMRCluster_configurationsJson (638.84s)
--- PASS: TestAccAWSEMRCluster_updateAutoScalingPolicy (642.36s)
--- PASS: TestAccAWSEMRCluster_basic (643.61s)
--- PASS: TestAccAWSEMRCluster_instance_group_update (645.28s)
--- PASS: TestAccAWSEMRCluster_Kerberos_ClusterDedicatedKdc (648.19s)
--- PASS: TestAccAWSEMRCluster_instance_group (666.50s)
--- PASS: TestAccAWSEMRCluster_Step_Basic (678.44s)
--- PASS: TestAccAWSEMRCluster_keepJob (782.12s)
--- PASS: TestAccAWSEMRCluster_s3Logging (861.22s)
--- PASS: TestAccAWSEMRCluster_visibleToAllUsers (926.71s)
--- PASS: TestAccAWSEMRCluster_root_volume_size (1155.21s)
--- PASS: TestAccAWSEMRCluster_tags (1221.14s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1221.773s

@mbfrahry mbfrahry requested a review from a team January 10, 2019 23:51
@bflad bflad added this to the v1.56.0 milestone Jan 11, 2019
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.

Let's get this in. Thanks so much @mbfrahry and @tracypholmes for your dedication here! 🚀 🎉

--- PASS: TestAccAWSEMRCluster_Kerberos_ClusterDedicatedKdc (468.11s)
--- PASS: TestAccAWSEMRCluster_security_config (502.72s)
--- PASS: TestAccAWSEMRCluster_instance_group_EBSVolumeType_st1 (515.43s)
--- PASS: TestAccAWSEMRCluster_bootstrap_ordering (518.55s)
--- PASS: TestAccAWSEMRCluster_instance_group (523.49s)
--- PASS: TestAccAWSEMRCluster_keepJob (533.63s)
--- PASS: TestAccAWSEMRCluster_custom_ami_id (537.09s)
--- PASS: TestAccAWSEMRCluster_instance_group_update (551.88s)
--- PASS: TestAccAWSEMRCluster_Step_Basic (576.80s)
--- PASS: TestAccAWSEMRCluster_basic (577.48s)
--- PASS: TestAccAWSEMRCluster_configurationsJson (585.18s)
--- PASS: TestAccAWSEMRCluster_Step_Multiple (594.08s)
--- PASS: TestAccAWSEMRCluster_terminationProtected (658.88s)
--- PASS: TestAccAWSEMRCluster_s3Logging (688.12s)
--- PASS: TestAccAWSEMRCluster_updateAutoScalingPolicy (690.46s)
--- PASS: TestAccAWSEMRCluster_additionalInfo (823.56s)
--- PASS: TestAccAWSEMRCluster_visibleToAllUsers (902.38s)
--- PASS: TestAccAWSEMRCluster_root_volume_size (919.39s)
--- PASS: TestAccAWSEMRCluster_tags (989.43s)

@bflad bflad merged commit 2f99563 into master Jan 11, 2019
@bflad bflad deleted the stefansundin-aws_emr_cluster-importer branch January 11, 2019 16:14
bflad added a commit that referenced this pull request Jan 11, 2019
@mbfrahry mbfrahry changed the title [WIP] EMR Cluster Import Support EMR Cluster Import Support Jan 11, 2019
@bflad
Copy link
Contributor

bflad commented Jan 16, 2019

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

@jhart-r7
Copy link

I believe this may have introduced a bug when using the optional instance_group which causes the EMR cluster to change upon every apply. See #7278.

@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
documentation Introduces or discusses updates to documentation. service/emr Issues and PRs that pertain to the emr service. size/XXL 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.

5 participants