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

provider: Migrate to iamwaiter.PropagationTimeout constant and begin enabling go-mnd linter #17811

Merged
merged 2 commits into from
Mar 26, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Feb 25, 2021

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

Closes #13199
Closes #16752
Reference: #16753

IAM eventual consistency handling has long been the source of needing retries in resource logic. Due to the lack of a consistent implementation (e.g. static constant) for how long to retry for these types of errors, there have been varying retry durations. The iamwaiter.PropagationTimeout constant was introduced for this purpose.

This change begins by introducing the go-mnd linter to enforce the usage of constants in function arguments. Example reports below. The rest of the changes are the minimum required to ensure iamwaiter.PropagationTimeout with its 2 minute duration is applied. You will note that this is fixing the duration in some cases to slightly increase it to the standard value. Any higher durations are ignored to reduce changes for now. As such, this can be reviewed by validating that a lower duration was not introduced and skipping acceptance testing since no logic changes should be introduced.

One caveat to go-mnd is that it currently ignores 1 as a magic number, which is possible in usage such as 1*time.Minute, and that ignored number cannot be overriden. An upstream issue will be created to ask the ignore-number configuration to overwrite instead of append.

Example previous report:

aws/resource_aws_api_gateway_account.go:99:23: mnd: Magic number: 2, in <argument> detected (gomnd)
	err = resource.Retry(2*time.Minute, func() *resource.RetryError {
	                     ^

Output from acceptance testing: N/A (see note above)

@bflad bflad requested a review from a team as a code owner February 25, 2021 02:00
@ghost ghost added size/L Managed by automation to categorize the size of a PR. service/apigateway Issues and PRs that pertain to the apigateway service. service/applicationautoscaling service/autoscaling Issues and PRs that pertain to the autoscaling service. service/backup Issues and PRs that pertain to the backup service. service/cloud9 Issues and PRs that pertain to the cloud9 service. service/cloudtrail Issues and PRs that pertain to the cloudtrail service. service/codebuild Issues and PRs that pertain to the codebuild service. service/configservice Issues and PRs that pertain to the configservice service. service/datasync Issues and PRs that pertain to the datasync service. service/dax Issues and PRs that pertain to the dax service. service/docdb Issues and PRs that pertain to the docdb service. service/ec2 Issues and PRs that pertain to the ec2 service. service/ecr Issues and PRs that pertain to the ecr service. service/eks Issues and PRs that pertain to the eks service. service/elasticsearch Issues and PRs that pertain to the elasticsearch service. service/emr Issues and PRs that pertain to the emr service. service/iam Issues and PRs that pertain to the iam service. service/lakeformation Issues and PRs that pertain to the lakeformation service. service/rds Issues and PRs that pertain to the rds service. labels Feb 25, 2021
@bflad bflad added the bug Addresses a defect in current functionality. label Feb 25, 2021
…enabling go-mnd linter

Reference: #13199
Reference: #16752
Reference: #16753

IAM eventual consistency handling has long been the source of needing retries in resource logic. Due to the lack of a consistent implementation (e.g. static constant) for how long to retry for these types of errors, there have been varying retry durations. The `iamwaiter.PropagationTimeout` constant was introduced for this purpose.

This change begins by introducing the `go-mnd` linter to enforce the usage of constants in function arguments. Example reports below. The rest of the changes are the minimum required to ensure `iamwaiter.PropagationTimeout` with its 2 minute duration is applied. You will note that this is fixing the duration in some cases to slightly increase it to the standard value. Any higher durations are ignored to reduce changes for now. As such, this can be reviewed by validating that a lower duration was not introduced and skipping acceptance testing since no logic changes should be introduced.

One caveat to `go-mnd` is that it currently ignores `1` as a magic number, which is possible in usage such as `1*time.Minute`, and that ignored number cannot be overriden. An upstream issue will be created to ask the `ignore-number` configuration to overwrite instead of append.

Example previous report:

```
aws/resource_aws_api_gateway_account.go:99:23: mnd: Magic number: 2, in <argument> detected (gomnd)
	err = resource.Retry(2*time.Minute, func() *resource.RetryError {
	                     ^
```
@bflad bflad force-pushed the b-iamwaiter-PropagationTimeout branch from 1308fa6 to e33607e Compare March 22, 2021 14:53
@bflad
Copy link
Contributor Author

bflad commented Mar 22, 2021

(Rebased to ensure this is up to date)

@gdavison gdavison self-assigned this Mar 25, 2021
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 🚀

@bflad bflad merged commit f17c81e into main Mar 26, 2021
@bflad bflad deleted the b-iamwaiter-PropagationTimeout branch March 26, 2021 15:29
@github-actions github-actions bot added this to the v3.35.0 milestone Mar 26, 2021
@ghost
Copy link

ghost commented Apr 1, 2021

This has been released in version 3.35.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 Apr 25, 2021

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 Apr 25, 2021
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/apigateway Issues and PRs that pertain to the apigateway service. service/autoscaling Issues and PRs that pertain to the autoscaling service. service/backup Issues and PRs that pertain to the backup service. service/cloud9 Issues and PRs that pertain to the cloud9 service. service/cloudtrail Issues and PRs that pertain to the cloudtrail service. service/codebuild Issues and PRs that pertain to the codebuild service. service/configservice Issues and PRs that pertain to the configservice service. service/datasync Issues and PRs that pertain to the datasync service. service/dax Issues and PRs that pertain to the dax service. service/docdb Issues and PRs that pertain to the docdb service. service/ec2 Issues and PRs that pertain to the ec2 service. service/ecr Issues and PRs that pertain to the ecr service. service/eks Issues and PRs that pertain to the eks service. service/elasticsearch Issues and PRs that pertain to the elasticsearch service. service/emr Issues and PRs that pertain to the emr service. service/iam Issues and PRs that pertain to the iam service. service/lakeformation Issues and PRs that pertain to the lakeformation service. service/rds Issues and PRs that pertain to the rds service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
2 participants