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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max leases quota #948

Merged
merged 10 commits into from
Jun 28, 2021
Merged

Max leases quota #948

merged 10 commits into from
Jun 28, 2021

Conversation

rhys-evans
Copy link
Contributor

@rhys-evans rhys-evans commented Jan 16, 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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Closes #947

Release note for CHANGELOG:

* Adds ability to manage lease-count quota's (Vault Enterprise Feature)

Output from acceptance testing:

TESTARGS="--run QuotaLeaseCount" make test
==> Checking that code complies with gofmt requirements...
go test -i $(go list ./... |grep -v 'vendor') || exit 1
echo $(go list ./... |grep -v 'vendor') | \
                xargs -t -n4 go test --run QuotaLeaseCount -timeout=30s -parallel=4
go test --run QuotaLeaseCount -timeout=30s -parallel=4 github.com/hashicorp/terraform-provider-vault github.com/hashicorp/terraform-provider-vault/cmd/coverage github.com/hashicorp/terraform-provider-vault/cmd/generate github.com/hashicorp/terraform-provider-vault/codegen
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
go test --run QuotaLeaseCount -timeout=30s -parallel=4 github.com/hashicorp/terraform-provider-vault/generated github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet
?       github.com/hashicorp/terraform-provider-vault/generated [no test files]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode    (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode    (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet    (cached) [no tests to run]
go test --run QuotaLeaseCount -timeout=30s -parallel=4 github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation github.com/hashicorp/terraform-provider-vault/schema
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role        (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template    (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation      (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
go test --run QuotaLeaseCount -timeout=30s -parallel=4 github.com/hashicorp/terraform-provider-vault/util github.com/hashicorp/terraform-provider-vault/vault
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/vault     (cached)
...

The code for this PR was largely cloned from https://github.com/hashicorp/terraform-provider-vault/pull/825/files

1st draft, not tested

Ref: hashicorp#947
TESTARGS="--run QuotaLeaseCount" make test
@hashicorp-cla
Copy link

hashicorp-cla commented Jan 16, 2021

CLA assistant check
All committers have signed the CLA.

@rhysxevans
Copy link

Hi, the quotaLeaseCountUpdate (in resource_quota_lease_count.go) function is as it is due to hashicorp/vault#10712

@rhys-evans rhys-evans marked this pull request as ready for review January 16, 2021 20:21
Removes , horrible quotaLeaseCountUpdate logic
@tvoran tvoran self-requested a review June 24, 2021 00:41
@tvoran
Copy link
Member

tvoran commented Jun 28, 2021

Hi @rhys-evans I see some of the update code has been commented out due to hashicorp/vault#10712, which has been closed. I wasn't able to reproduce that issue with vault enterprise 1.7.3, so it seems like those code blocks could be restored?

Copy link
Member

@tvoran tvoran left a comment

Choose a reason for hiding this comment

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

Thanks for the patch! Please take a look at the comments; I think they're mostly leftover copy/paste from #825.

Also note that you'll need to make testacc to run the lease quota test in this PR:

TESTARGS="--run QuotaLeaseCount" make testacc

Currently it fails because vault expects max_leases as an int, but this patch is sending it as a float.

Do let us know if you'd like to work on these changes, otherwise we can take it over and finish it up.

vault/resource_quota_lease_count.go Outdated Show resolved Hide resolved
vault/resource_quota_lease_count.go Outdated Show resolved Hide resolved
vault/resource_quota_lease_count_test.go Outdated Show resolved Hide resolved
vault/resource_quota_lease_count_test.go Outdated Show resolved Hide resolved
vault/resource_quota_lease_count.go Outdated Show resolved Hide resolved
vault/resource_quota_lease_count.go Outdated Show resolved Hide resolved
vault/resource_quota_lease_count.go Outdated Show resolved Hide resolved
When trying int in resource_quota_lease_count.go we get

Error: rpc error: code = Unavailable desc = transport is closing
Error: rpc error: code = Canceled desc = context canceled
@rhysxevans
Copy link

AULT_ADDR='http://0.0.0.0:8200' VAULT_TOKEN='xxxxxxxxxl' TF_ACC_ENTERPRISE=true TESTARGS="--run QuotaLeaseCount" make testacc
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v --run QuotaLeaseCount -timeout 120m
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/generated [no test files]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode    (cached) [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode    (cached) [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet    (cached) [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role        (cached) [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template    (cached) [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation      (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

=== RUN   TestQuotaLeaseCount
--- PASS: TestQuotaLeaseCount (0.95s)
PASS
ok      github.com/hashicorp/terraform-provider-vault/vault     (cached)

go.mod Outdated Show resolved Hide resolved
vendor/modules.txt Outdated Show resolved Hide resolved
website/docs/r/quota_lease_count.md Outdated Show resolved Hide resolved
vault/resource_quota_lease_count.go Outdated Show resolved Hide resolved
vault/resource_quota_lease_count.go Outdated Show resolved Hide resolved
@rhys-evans
Copy link
Contributor Author

VAULT_ADDR='http://0.0.0.0:8200' VAULT_TOKEN='s.xxxxxxxx' TF_ACC_ENTERPRISE=true TESTARGS="--run QuotaLeaseCount" make testacc
Password:
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v --run QuotaLeaseCount -timeout 120m
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/generated [no test files]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode    3.843s [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode    4.665s [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet    1.564s [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role        3.374s [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template    2.176s [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation      1.097s [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

=== RUN   TestQuotaLeaseCount
--- PASS: TestQuotaLeaseCount (1.05s)
PASS
ok      github.com/hashicorp/terraform-provider-vault/vault     6.429s

@rhys-evans
Copy link
Contributor Author

ok, so seems to work with int instead of int64 , but I probably missed something else before. My fault

Copy link
Member

@tvoran tvoran left a comment

Choose a reason for hiding this comment

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

Just one more small suggestion.

vault/resource_quota_lease_count_test.go Outdated Show resolved Hide resolved
Copy link
Member

@tvoran tvoran left a comment

Choose a reason for hiding this comment

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

Thanks!

@tvoran tvoran merged commit 6836ef0 into hashicorp:master Jun 28, 2021
davidmontoyago pushed a commit to davidmontoyago/terraform-provider-vault that referenced this pull request Aug 17, 2021
Adds ability to manage lease-count quota's (Vault Enterprise Feature)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request - lease count quotas
4 participants