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

Do not validate items that conflict #24202

Merged
merged 6 commits into from
Apr 14, 2022
Merged

Do not validate items that conflict #24202

merged 6 commits into from
Apr 14, 2022

Conversation

MarkCBell
Copy link
Contributor

@MarkCBell MarkCBell commented Apr 12, 2022

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

The failure_tolerance_count and failure_tolerance_percentage conflict with each other, so one should be validated only if the other has failed. The same applies for max_concurrent_count and max_concurrent_percentage.

Closes #24161

The `failure_tolerance_count` and `failure_tolerance_percentage` conflict with each other so one should be validated only if the other has failed. The same applies for `max_concurrent_count` and `max_concurrent_percentage`
@github-actions github-actions bot added service/cloudformation Issues and PRs that pertain to the cloudformation service. needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. labels Apr 12, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @MarkCBell 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 12, 2022
@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/M Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Apr 14, 2022
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

Prior to fix:

% make testacc TESTS=TestAccCloudFormationStackSet_operationPreferences PKG=cloudformation
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudformation/... -v -count 1 -parallel 20 -run='TestAccCloudFormationStackSet_operationPreferences'  -timeout 180m
=== RUN   TestAccCloudFormationStackSet_operationPreferences
=== PAUSE TestAccCloudFormationStackSet_operationPreferences
=== CONT  TestAccCloudFormationStackSet_operationPreferences
    stack_set_test.go:268: Step 4/5 error: Error running apply: exit status 1
        
        Error: error updating CloudFormation StackSet (tf-acc-test-1440391482554017189): InvalidParameter: 1 validation error(s) found.
        - minimum field value of 1, UpdateStackSetInput.OperationPreferences.MaxConcurrentCount.
        
        
          with aws_cloudformation_stack_set.test,
          on terraform_plugin_test.tf line 25, in resource "aws_cloudformation_stack_set" "test":
          25: resource "aws_cloudformation_stack_set" "test" {
        
--- FAIL: TestAccCloudFormationStackSet_operationPreferences (47.90s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/cloudformation	51.741s
FAIL
make: *** [testacc] Error 1

After fix:

% make testacc TESTS=TestAccCloudFormationStackSet_operationPreferences PKG=cloudformation
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudformation/... -v -count 1 -parallel 20 -run='TestAccCloudFormationStackSet_operationPreferences'  -timeout 180m
=== RUN   TestAccCloudFormationStackSet_operationPreferences
=== PAUSE TestAccCloudFormationStackSet_operationPreferences
=== CONT  TestAccCloudFormationStackSet_operationPreferences
--- PASS: TestAccCloudFormationStackSet_operationPreferences (81.30s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/cloudformation	85.855s

@ewbankkit
Copy link
Contributor

@MarkCBell Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 3a8e1cb into hashicorp:main Apr 14, 2022
@github-actions github-actions bot added this to the v4.10.0 milestone Apr 14, 2022
@MarkCBell MarkCBell deleted the MarkCBell-stackset-operation-preference-validation branch April 14, 2022 19:21
@github-actions
Copy link

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

@MarkCBell
Copy link
Contributor Author

@ewbankkit Thank you for working on this. However I believe that there is a bug in the logic that you have added to internal/service/cloudformation/type.go. Specifically, in order for one of FailureTolerancePercentage or FailureToleranceCount to be removed (set to nil) either ftc > 0 or ftp > 0. Therefore a block such as:

  operation_preferences {
    failure_tolerance_percentage = 0
    max_concurrent_percentage = 100
  }

will trigger neither case since ftp has be set to 0 and ftc has defaulted to zero. Therefore if you attempt to run a stack set with the above operations_preferences, terraform fails with Validation Error: Exactly one of FailureTolerancePercentage and FailureToleranceCount must be specified since both parameters are present.

You could address this by modifying the logic to:

	if ftc, ftp := aws.Int64Value(apiObject.FailureToleranceCount), aws.Int64Value(apiObject.FailureTolerancePercentage); ftp == 0 {
		apiObject.FailureTolerancePercentage = nil
	} else if ftc == 0 {
		apiObject.FailureToleranceCount = nil
        }

I will open a new issue / PR proposing this change.

Note that this does not apply to max_concurrent_percentage / max_concurrent_count since at least one of these must be at least one.

@MarkCBell
Copy link
Contributor Author

@ewbankkit I have proposed this change in PR #24250

@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 May 15, 2022
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/cloudformation Issues and PRs that pertain to the cloudformation 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.

Unable to update aws_cloudformation_stack_set with max_concurrent_percentage field set
3 participants