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

Vault 1979: Query API for Irrevocable Leases #11607

Merged
merged 28 commits into from Jun 2, 2021

Conversation

swayne275
Copy link
Contributor

No description provided.

@vercel vercel bot temporarily deployed to Preview – vault May 20, 2021 18:28 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook May 20, 2021 18:28 Inactive
@vercel vercel bot temporarily deployed to Preview – vault May 20, 2021 19:12 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook May 20, 2021 19:12 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook May 20, 2021 20:41 Inactive
@vercel vercel bot temporarily deployed to Preview – vault May 20, 2021 20:41 Inactive
@vercel vercel bot temporarily deployed to Preview – vault May 21, 2021 01:22 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook May 21, 2021 01:22 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook May 21, 2021 01:53 Inactive
@vercel vercel bot temporarily deployed to Preview – vault May 21, 2021 01:53 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook May 21, 2021 16:18 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook May 26, 2021 21:48 Inactive
@vercel vercel bot temporarily deployed to Preview – vault May 26, 2021 21:48 Inactive

// sort the results for consistent API response
sort.Slice(matchingLeases, func(i, j int) bool {
return matchingLeases[i].LeaseID < matchingLeases[j].LeaseID
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine, but we could also sort by expiration time then lease id, so the operator can get a sense of how old the oldest irrevocable leases are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that sounds like a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Other way around on that sort? I think you want to do it in just one pass with the sort predicate testing expiration time and returning if non-equal, then testing leaseid if the expiration times are equal.

Copy link
Contributor Author

@swayne275 swayne275 Jun 1, 2021

Choose a reason for hiding this comment

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

can you clarify how you'd like this sorted? the current code will display the oldest-expiring leases at the top of the list, and if multiple leases have the same expiration time it will then display them in increasing order by the lease id (a comes before b)

i can certainly do it in one slice sort path, but let's verify how we want the results displayed first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we chatted in slack. sorting is correct, but made more efficient here: 585caea

vault/logical_system_paths.go Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – vault-storybook June 1, 2021 16:57 Inactive
@vercel vercel bot temporarily deployed to Preview – vault June 1, 2021 16:57 Inactive
@swayne275 swayne275 requested a review from sgmiller June 1, 2021 16:57
@vercel vercel bot temporarily deployed to Preview – vault-storybook June 1, 2021 17:02 Inactive
@vercel vercel bot temporarily deployed to Preview – vault June 1, 2021 17:02 Inactive

// sort the results for consistent API response
sort.Slice(matchingLeases, func(i, j int) bool {
return matchingLeases[i].LeaseID < matchingLeases[j].LeaseID
Copy link
Contributor

Choose a reason for hiding this comment

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

Other way around on that sort? I think you want to do it in just one pass with the sort predicate testing expiration time and returning if non-equal, then testing leaseid if the expiration times are equal.

@vercel vercel bot temporarily deployed to Preview – vault-storybook June 2, 2021 15:43 Inactive
@vercel vercel bot temporarily deployed to Preview – vault June 2, 2021 15:43 Inactive
@swayne275 swayne275 requested a review from sgmiller June 2, 2021 15:44
@swayne275 swayne275 merged commit b56a109 into master Jun 2, 2021
@swayne275 swayne275 deleted the vault-1979_expr-irrevocable-query-api branch June 2, 2021 16:11
AndreyZamyslov pushed a commit to yandex-cloud/vault that referenced this pull request Jun 10, 2021
* build out lease count (not fully working), start lease list

* build out irrevocable lease list

* bookkeeping

* test irrevocable lease counts for API/CLI

* fix listIrrevocableLeases, test listIrrevocableLeases, cleanup

* test expiration API limit

* namespace tweaks, test force flag on lease list

* integration test leases/count API, plenty of fixes and improvements

* test lease list API, fixes and improvements

* test force flag for irrevocable lease list API

* i guess this wasn't saved on the last refactor...

* fixes and improvements found during my review

* better test error msg

* Update vault/logical_system_paths.go

Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>

* Update vault/logical_system_paths.go

Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>

* return warning with data if more than default leases to list without force flag

* make api doc more generalized

* list leases in general, not by mount point

* change force flag to include_large_results

* sort leases by LeaseID for consistent API response

* switch from bool flag for API limit to string value

* sort first by leaseID, then stable sort by expiration

* move some utils to be in oss and ent

* improve sort efficiency for API response

Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>
jartek pushed a commit to jartek/vault that referenced this pull request Sep 11, 2021
* build out lease count (not fully working), start lease list

* build out irrevocable lease list

* bookkeeping

* test irrevocable lease counts for API/CLI

* fix listIrrevocableLeases, test listIrrevocableLeases, cleanup

* test expiration API limit

* namespace tweaks, test force flag on lease list

* integration test leases/count API, plenty of fixes and improvements

* test lease list API, fixes and improvements

* test force flag for irrevocable lease list API

* i guess this wasn't saved on the last refactor...

* fixes and improvements found during my review

* better test error msg

* Update vault/logical_system_paths.go

Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>

* Update vault/logical_system_paths.go

Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>

* return warning with data if more than default leases to list without force flag

* make api doc more generalized

* list leases in general, not by mount point

* change force flag to include_large_results

* sort leases by LeaseID for consistent API response

* switch from bool flag for API limit to string value

* sort first by leaseID, then stable sort by expiration

* move some utils to be in oss and ent

* improve sort efficiency for API response

Co-authored-by: Brian Kassouf <briankassouf@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants