-
Notifications
You must be signed in to change notification settings - Fork 551
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
Add support for vault_quota_rate_limit interval and block_interval #1084
Conversation
vault/resource_quota_rate_limit.go
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. We can scale down this PR by making interval
and block_interval
schema.TypeInt
.
vault/resource_quota_rate_limit.go
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.ParseDurationSecond
logic. 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: