Add support for vault_quota_rate_limit interval and block_interval - #1084
Conversation
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Description: "If set, when a client reaches a rate limit threshold, the client will be prohibited from any further requests until after the 'block_interval' has elapsed.", | ||
| StateFunc: durationSecond, |
There was a problem hiding this comment.
Because read requests return these values in seconds and not a duration the configuration value must be computed in terms of seconds to prevent a perpetual diff.
There was a problem hiding this comment.
Since vault converts the duration strings to seconds (int), we prefer to only support schema.TypeInt for these sorts of Vault fields. This should greatly simplify your PR.
benashz
left a comment
There was a problem hiding this comment.
Thanks for the contribution. We can scale down this PR by making interval and block_interval schema.TypeInt.
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Description: "If set, when a client reaches a rate limit threshold, the client will be prohibited from any further requests until after the 'block_interval' has elapsed.", | ||
| StateFunc: durationSecond, |
There was a problem hiding this comment.
Since vault converts the duration strings to seconds (int), we prefer to only support schema.TypeInt for these sorts of Vault fields. This should greatly simplify your PR.
|
@mdgreenfield please let us know if you have spare cycles to work on this PR. If not we would be happy to take it over. Thanks, Ben |
|
Hi @benashz I can address the comments in the next day or two. |
Allows users to specify either in terms of duration or number of seconds utilizing Vault's `parseutil.ParseDurationSecond` logic. See https://github.com/hashicorp/vault/blob/ed33ed1a0a5ecb9d41ab22b4899aa318239ac031/sdk/helper/parseutil/parseutil.go#L96-L147 Closes hashicorp#1049
65c4767 to
bbb5741
Compare
3875b7b to
d2c5ba3
Compare
d2c5ba3 to
2d8f99c
Compare
|
@benashz I've updated the PR switching to I did notice that some fields, e.g. the TTL fields on the auth mount resource, use |
|
The updated acceptance testing output: |
benashz
left a comment
There was a problem hiding this comment.
Looks good! I added a few minor suggestions that should be addressed.
| rateLimt := fmt.Sprintf("%.1f", whole+decimal) | ||
| // Vault retuns floats with trailing zeros trimmed | ||
| return strings.TrimRight(strings.TrimRight(rateLimt, "0"), ".") | ||
| rateLimit := fmt.Sprintf("%.1f", whole+decimal) |
Co-authored-by: Ben Ash <32777270+benashz@users.noreply.github.com>
|
Thanks @benashz for the review. I learned a few things about writing Terraform providers from your comments. Changes have been added to the PR. |
benashz
left a comment
There was a problem hiding this comment.
LGTM!
Thank you for you contribution to HashiCorp!
…ashicorp#1084) Co-authored-by: Ben Ash <32777270+benashz@users.noreply.github.com>
Allows users to specify either in terms of duration or number of
seconds utilizing Vault's
parseutil.ParseDurationSecondlogic. Seehttps://github.com/hashicorp/vault/blob/ed33ed1a0a5ecb9d41ab22b4899aa318239ac031/sdk/helper/parseutil/parseutil.go#L96-L147
Closes #1049
Community Note
Release note for CHANGELOG:
Output from acceptance testing: