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: Allow bootstrap action empty args #32956

Merged
merged 5 commits into from
Aug 10, 2023

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented Aug 10, 2023

Description

Bootstrap args should be able to include empty strings. This change allows them to.

If you have this schema:

"args": {
	Type:     schema.TypeList,
	Optional: true,
	ForceNew: true,
	Elem:     &schema.Schema{Type: schema.TypeString},
},

Any empty strings in that list end up as nil rather than "" in the d.Get() []interface{}. Thus, if you loop through the list, doing this check, you'll get !ok for the empty string in the config that is now a nil in the slice.

if v, ok := v.(string); ok {
	vs = append(vs, aws.String(v))
}

In order to include an empty string, you instead need to do this:

if v, ok := v.(string); ok {
	vs = append(vs, aws.String(v))
} else {
	vs = append(vs, aws.String(""))
}

Relations

Closes #32735.
Relates #32738.

References

Output from Acceptance Testing

(Failure unrelated to these changes.)

% make t T=TestAccEMRCluster_ K=emr                  
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/emr/... -v -count 1 -parallel 20 -run='TestAccEMRCluster_'  -timeout 180m
=== RUN   TestAccEMRCluster_basic
=== PAUSE TestAccEMRCluster_basic
=== RUN   TestAccEMRCluster_autoTerminationPolicy
=== PAUSE TestAccEMRCluster_autoTerminationPolicy
=== RUN   TestAccEMRCluster_additionalInfo
=== PAUSE TestAccEMRCluster_additionalInfo
=== RUN   TestAccEMRCluster_disappears
=== PAUSE TestAccEMRCluster_disappears
=== RUN   TestAccEMRCluster_sJSON
=== PAUSE TestAccEMRCluster_sJSON
=== RUN   TestAccEMRCluster_CoreInstanceGroup_autoScalingPolicy
=== PAUSE TestAccEMRCluster_CoreInstanceGroup_autoScalingPolicy
=== RUN   TestAccEMRCluster_CoreInstanceGroup_bidPrice
=== PAUSE TestAccEMRCluster_CoreInstanceGroup_bidPrice
=== RUN   TestAccEMRCluster_CoreInstanceGroup_instanceCount
=== PAUSE TestAccEMRCluster_CoreInstanceGroup_instanceCount
=== RUN   TestAccEMRCluster_CoreInstanceGroup_instanceType
=== PAUSE TestAccEMRCluster_CoreInstanceGroup_instanceType
=== RUN   TestAccEMRCluster_CoreInstanceGroup_name
=== PAUSE TestAccEMRCluster_CoreInstanceGroup_name
=== RUN   TestAccEMRCluster_EC2Attributes_defaultManagedSecurityGroups
=== PAUSE TestAccEMRCluster_EC2Attributes_defaultManagedSecurityGroups
=== RUN   TestAccEMRCluster_Kerberos_clusterDedicatedKdc
=== PAUSE TestAccEMRCluster_Kerberos_clusterDedicatedKdc
=== RUN   TestAccEMRCluster_MasterInstanceGroup_bidPrice
=== PAUSE TestAccEMRCluster_MasterInstanceGroup_bidPrice
=== RUN   TestAccEMRCluster_MasterInstanceGroup_instanceCount
=== PAUSE TestAccEMRCluster_MasterInstanceGroup_instanceCount
=== RUN   TestAccEMRCluster_MasterInstanceGroup_instanceType
=== PAUSE TestAccEMRCluster_MasterInstanceGroup_instanceType
=== RUN   TestAccEMRCluster_MasterInstanceGroup_name
=== PAUSE TestAccEMRCluster_MasterInstanceGroup_name
=== RUN   TestAccEMRCluster_security
=== PAUSE TestAccEMRCluster_security
=== RUN   TestAccEMRCluster_Step_basic
=== PAUSE TestAccEMRCluster_Step_basic
=== RUN   TestAccEMRCluster_Step_mode
=== PAUSE TestAccEMRCluster_Step_mode
=== RUN   TestAccEMRCluster_Step_multiple
=== PAUSE TestAccEMRCluster_Step_multiple
=== RUN   TestAccEMRCluster_Step_multiple_listStates
=== PAUSE TestAccEMRCluster_Step_multiple_listStates
=== RUN   TestAccEMRCluster_Bootstrap_ordering
=== PAUSE TestAccEMRCluster_Bootstrap_ordering
=== RUN   TestAccEMRCluster_PlacementGroupConfigs
=== PAUSE TestAccEMRCluster_PlacementGroupConfigs
=== RUN   TestAccEMRCluster_terminationProtected
=== PAUSE TestAccEMRCluster_terminationProtected
=== RUN   TestAccEMRCluster_keepJob
=== PAUSE TestAccEMRCluster_keepJob
=== RUN   TestAccEMRCluster_visibleToAllUsers
=== PAUSE TestAccEMRCluster_visibleToAllUsers
=== RUN   TestAccEMRCluster_s3Logging
=== PAUSE TestAccEMRCluster_s3Logging
=== RUN   TestAccEMRCluster_s3LogEncryption
=== PAUSE TestAccEMRCluster_s3LogEncryption
=== RUN   TestAccEMRCluster_tags
=== PAUSE TestAccEMRCluster_tags
=== RUN   TestAccEMRCluster_RootVolume_size
=== PAUSE TestAccEMRCluster_RootVolume_size
=== RUN   TestAccEMRCluster_StepConcurrency_level
=== PAUSE TestAccEMRCluster_StepConcurrency_level
=== RUN   TestAccEMRCluster_ebs
=== PAUSE TestAccEMRCluster_ebs
=== RUN   TestAccEMRCluster_CustomAMI_id
=== PAUSE TestAccEMRCluster_CustomAMI_id
=== RUN   TestAccEMRCluster_InstanceFleet_basic
=== PAUSE TestAccEMRCluster_InstanceFleet_basic
=== RUN   TestAccEMRCluster_InstanceFleetMaster_only
=== PAUSE TestAccEMRCluster_InstanceFleetMaster_only
=== CONT  TestAccEMRCluster_basic
=== CONT  TestAccEMRCluster_Step_mode
=== CONT  TestAccEMRCluster_tags
=== CONT  TestAccEMRCluster_MasterInstanceGroup_bidPrice
=== CONT  TestAccEMRCluster_s3LogEncryption
=== CONT  TestAccEMRCluster_CoreInstanceGroup_autoScalingPolicy
=== CONT  TestAccEMRCluster_InstanceFleetMaster_only
=== CONT  TestAccEMRCluster_InstanceFleet_basic
=== CONT  TestAccEMRCluster_CustomAMI_id
=== CONT  TestAccEMRCluster_ebs
=== CONT  TestAccEMRCluster_StepConcurrency_level
=== CONT  TestAccEMRCluster_RootVolume_size
=== CONT  TestAccEMRCluster_CoreInstanceGroup_name
=== CONT  TestAccEMRCluster_Step_basic
=== CONT  TestAccEMRCluster_security
=== CONT  TestAccEMRCluster_MasterInstanceGroup_name
=== CONT  TestAccEMRCluster_MasterInstanceGroup_instanceType
=== CONT  TestAccEMRCluster_MasterInstanceGroup_instanceCount
=== CONT  TestAccEMRCluster_CoreInstanceGroup_instanceType
=== CONT  TestAccEMRCluster_CoreInstanceGroup_instanceCount
--- PASS: TestAccEMRCluster_basic (411.75s)
=== CONT  TestAccEMRCluster_CoreInstanceGroup_bidPrice
=== CONT  TestAccEMRCluster_Kerberos_clusterDedicatedKdc
--- PASS: TestAccEMRCluster_ebs (415.06s)
--- PASS: TestAccEMRCluster_security (424.54s)
=== CONT  TestAccEMRCluster_disappears
--- PASS: TestAccEMRCluster_Step_basic (451.82s)
=== CONT  TestAccEMRCluster_sJSON
--- PASS: TestAccEMRCluster_StepConcurrency_level (640.74s)
=== CONT  TestAccEMRCluster_terminationProtected
--- PASS: TestAccEMRCluster_CoreInstanceGroup_autoScalingPolicy (644.94s)
=== CONT  TestAccEMRCluster_s3Logging
--- PASS: TestAccEMRCluster_CustomAMI_id (757.75s)
=== CONT  TestAccEMRCluster_visibleToAllUsers
--- PASS: TestAccEMRCluster_CoreInstanceGroup_instanceType (829.24s)
=== CONT  TestAccEMRCluster_keepJob
--- PASS: TestAccEMRCluster_s3LogEncryption (838.01s)
=== CONT  TestAccEMRCluster_Bootstrap_ordering
--- PASS: TestAccEMRCluster_tags (838.72s)
=== CONT  TestAccEMRCluster_PlacementGroupConfigs
--- PASS: TestAccEMRCluster_MasterInstanceGroup_instanceType (842.02s)
=== CONT  TestAccEMRCluster_additionalInfo
--- PASS: TestAccEMRCluster_RootVolume_size (856.41s)
=== CONT  TestAccEMRCluster_autoTerminationPolicy
--- PASS: TestAccEMRCluster_sJSON (404.72s)
=== CONT  TestAccEMRCluster_Step_multiple
--- PASS: TestAccEMRCluster_disappears (432.29s)
=== CONT  TestAccEMRCluster_EC2Attributes_defaultManagedSecurityGroups
--- PASS: TestAccEMRCluster_Kerberos_clusterDedicatedKdc (456.95s)
=== CONT  TestAccEMRCluster_Step_multiple_listStates
--- PASS: TestAccEMRCluster_InstanceFleetMaster_only (884.77s)
--- PASS: TestAccEMRCluster_MasterInstanceGroup_bidPrice (901.34s)
--- PASS: TestAccEMRCluster_MasterInstanceGroup_name (942.49s)
--- PASS: TestAccEMRCluster_terminationProtected (428.14s)
--- PASS: TestAccEMRCluster_CoreInstanceGroup_instanceCount (1165.66s)
--- PASS: TestAccEMRCluster_keepJob (352.81s)
--- PASS: TestAccEMRCluster_Step_multiple (385.03s)
--- PASS: TestAccEMRCluster_Step_multiple_listStates (388.32s)
--- PASS: TestAccEMRCluster_MasterInstanceGroup_instanceCount (1268.87s)
=== NAME  TestAccEMRCluster_visibleToAllUsers
    cluster_test.go:1294: Step 3/4 error: Check failed: Check 2/2 error: aws_emr_cluster.test: Attribute 'visible_to_all_users' expected "false", got "true"
--- PASS: TestAccEMRCluster_s3Logging (711.25s)
--- PASS: TestAccEMRCluster_additionalInfo (515.11s)
--- PASS: TestAccEMRCluster_Step_mode (1357.84s)
--- PASS: TestAccEMRCluster_CoreInstanceGroup_bidPrice (1027.05s)
--- FAIL: TestAccEMRCluster_visibleToAllUsers (695.60s)
--- PASS: TestAccEMRCluster_PlacementGroupConfigs (664.77s)
--- PASS: TestAccEMRCluster_autoTerminationPolicy (772.24s)
--- PASS: TestAccEMRCluster_CoreInstanceGroup_name (1742.61s)
--- PASS: TestAccEMRCluster_EC2Attributes_defaultManagedSecurityGroups (972.05s)
--- PASS: TestAccEMRCluster_InstanceFleet_basic (2059.26s)
--- PASS: TestAccEMRCluster_Bootstrap_ordering (1222.34s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/emr	2062.368s

@github-actions
Copy link

Community Note

Voting for Prioritization

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

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/emr Issues and PRs that pertain to the emr service. flex Pertains to FLatteners and EXpanders. labels Aug 10, 2023
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Aug 10, 2023
vs = append(vs, aws.String(v))
}
}
return vs
}

// ExpandStringListEmpty the result of flatmap. Expand for an array of strings
// and returns a []*string. Empty strings are NOT skipped.
func ExpandStringListEmpty(configured []interface{}) []*string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add unit test(s) to internal/flex/flex_test.go?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, good idea. The unit tests can easily give a false positive if we put "" (which is not what Terraform does) instead of nil in the test.

@YakDriver YakDriver force-pushed the b-emr-cluster-bootstrap-action-empty-args branch from 9c62af0 to c51ef98 Compare August 10, 2023 19:13
@YakDriver YakDriver force-pushed the b-emr-cluster-bootstrap-action-empty-args branch from 6e55206 to 2dc1edb Compare August 10, 2023 19:37
@YakDriver YakDriver merged commit 40b85f8 into main Aug 10, 2023
34 checks passed
@YakDriver YakDriver deleted the b-emr-cluster-bootstrap-action-empty-args branch August 10, 2023 19:59
@github-actions github-actions bot added this to the v5.12.0 milestone Aug 10, 2023
github-actions bot pushed a commit that referenced this pull request Aug 10, 2023
@github-actions
Copy link

This functionality has been released in v5.12.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. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Feb 10, 2024
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. flex Pertains to FLatteners and EXpanders. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/emr Issues and PRs that pertain to the emr service. size/S 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.

r/aws_emr_cluster: bootstrap_action.args empty string value not sent to AWS
3 participants