Commit Graph
3638 Commits
Author SHA1 Message Date
Johan Brandhorst-Satzkorn 6b03363eb8 internal/handlers: add credential library pagination 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn c6e80dbe32 internal/credential: add library pagination logic 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 1337a57674 internal/credential/vault: add pagination logic 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn fcb47f3772 internal/db: add cred library pagination schema changes 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn a9e0d6693d internal/credential/static: simplify list parsing (#4112)
Using a struct for the list parsing simplifies the
logic and makes the mapping between the result and
the Go type safer.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 6b2f5fe29f internal/credential: fix comment (#4106) 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 9f6ac602ee internal/handlers: add credential pagination support 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn fa898fe87b internal/credential: add pagination service functions
The new service functions are used for various stages of pagination.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn e0092999de internal/credential/static: add pagination support
Refactors ListCredentials and adds the new ListCredentialsRefresh
method to the Repository, supporting pagination
of credentials. Also adds the EstimateCount and
ListDeletedCredentialIds methods used during
pagination.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 497c158b9d internal/db: add migration for static credential table
The static credential table is used rather than the credential
table as all credentials returned by ListCredentials are static
at this time.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn a470f4c0c3 internal/credential: add pagination options
The new options are used in future commits for paginating list results.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 71b21c5f39 internal/target: fix sql query nits (#4102)
Consistently use "final" for the final CTE, and put
"and"s on the line before.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 37d4f0e373 internal/target: correct comment (#4091) 2024-01-05 07:43:20 -08:00
Michael Milton 9c3eb16046 Sessions list pagination (#4079)
* Session list pagination refactor

* address pr comments, add explanatory comments, clean up sql queries, move tests into proper files

* fix build error

* fix test error
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 575e9641f8 Some pagination tweaks (#4074)
* internal/target: fix some target tests

We had dupes and missing test cases, this fixes them.

* internal/handlers: move listtoken parsing into helper

This significantly simplifies the parsing logic needed in each handler.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-SatzkornandMichael Li 6198fe279e Target pagination e2e test (#4010)
* testing/e2e: Use a separate config file for database init

The other config file contains templated parameters, which was causing
errors when loading the config file, even though the values were never
used.

* testing/e2e: add target pagination test

Exercises target pagination both over the CLI and the API. These tests
run in <10s on my machine, though they each involve creating 1000
targets (with current defaults).

---------

Co-authored-by: Michael Li <michael.li@hashicorp.com>
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn acc048a1d1 internal/genapi: correct list response body and map
When using the new auto-pagination logic, we would previously return
the Body and Map of the last response, instead of one corresponding
to the returned result. Correct this by overwriting the Body and Map
after pagination has finished.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn af61b688c6 internal/listtoken: remove overzealous validation
Validating that the update time of the last item is after the
create time of the token cannot account for items whose
update time are earlier than the original query because of
the added database transaction timeout buffer. Remove the
check.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 6181f34497 internal/db: move new migrations to new folder 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 3b54611d14 api: update api listing
Change from refresh token to list token
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 00c4f825c7 handlers/targets: refactor for new pagination design
Refactor the application layer to use the new domain layer
pagination functionality.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn eca27b00c9 internal/proto: rename refresh token to list token 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn e2fd8f9701 internal/proto: refactor list proto definitions
This aligns it more with the new domain use.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn f062a8cd75 internal/handlers: add list token helpers
Mostly a rename from refresh token, but also a new helper
for assembling the final list token.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn d4d856e712 internal/target: refactor for new pagination design
The new design uses four separate service functions; List,
ListPage, ListRefresh and ListRefreshPage. The first two are
used during the initial pagination phase and the latter two
are used for any subsequent refresh phases.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn f0f7e635a0 internal/db: add target schema for pagination design
The new design uses the base table for querying, so the base
table needs to have both create_time and update_time. In this
commit we add the update_time to the target base table. We
also add a number of new indexes to help with looking up targets.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 0657276a0e pagination: refactor for new pagination design
The new design defines 4 distinct functions, List, ListPage, ListRefresh
and ListRefreshPage. The first two are used during the initial
pagination, and the other two are used during refreshing.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 3019038eab refreshtoken: move package to listtoken
The listtoken package encapsulates the logic used for all
types of pagination and refreshing across all list endpoints.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 8b0d1aa4af globals: Add new DatabaseReadTimeout
The new field is used as a buffer in certain list queries, to account
for concurrent transactions.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 4e368f154f internal/tests: add target pagination test 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 5984f5bba6 handlers/targets: add pagination support 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn ef3bdfd5eb api: add automatic list pagination
Updates all List endpoints to automatically paginate
through results to preserve backwards compatibility.
Adding support for user controllable pagination could
be considered at a later time.
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 9ce5a14ef0 config: add max_page_size variable
The max_page_size variable lets operators control the size of the
pagination pages. This value configures both the maximum permitted
page size and the default page size when none is explicitly provided.

Operators can tweak this option up or down to increase or reduce
the load on the database during pagination.
2024-01-05 07:43:20 -08:00
5bfc8a88b1 Add indexes on update_time (#3974)
* Add indexes on update_time

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Co-authored-by: Michael Gaffney <mike@gaffney.cc>
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 43cff11865 internal/db: renumber migration 2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn 605e44e7ac target: add pagination support
Adds pagination support to the target domain
2024-01-05 07:43:20 -08:00
Johan Brandhorst-Satzkorn a5b24e79b9 handlers: add refresh token helpers
Helpers for parsing, marshalling and converting types
to domain types.
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn 84e5b9401d proto: add pagination Refresh Token
The ListRefreshToken type is used, in its marshalled form,
for pagination requests. A new refresh token is returned
which each invocation of a list method (unless
there was no input refresh token and there were no results).
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn 7b5a4be0ab internal/auth: add GrantsHash method to results
The new GrantsHash method can be used to track changes
to a users grants across requests.
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn 7c996d0e02 internal/pagination: add new purge package
The purge package contains a job that is used to purge
records from the foo_deleted tables when they become
older than 30 days.
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn 78541ad05e internal/pagination: add new pagination package
The pagination package provides generic functions for
iterating over a collection of items such that each incoming
request is filled even after filtering is applied.
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn dcb67ca616 internal/refreshtoken: add refreshtoken package
The refreshtoken package encapsulates domain logic surrouding
the refresh token. A refresh token is used both for
paginating through a collection and for requesting any
updates to that collection.
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn 0d39456418 internal/boundary: add GetResourceType to Resource
The resource type method is used to automatically
create refresh tokens from a resource when that
resource is the last item returned in a page.

This also renames the iam domain ResourceType method
to GetResourceType to align with the new method.
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn 5cded25c8d Update CHANGELOG for pagination feature (#3900) 2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn dd2b373866 internal/db: add Now method (#3887)
The Now() method returns the current transaction timestamp.
2024-01-05 07:43:19 -08:00
Johan Brandhorst-Satzkorn 38536f4eef internal/db: add deleted tables for all resources (#3885)
Creates a new foo_deleted table for each subtype of each
resource that needs to support pagination. The deleted
tables are used to track deletions of resources and return
them to users of the new pagination API. We track only the
ID and delete_time of the resource, so there's no way to
filter out resources that the user could not see before it
was deleted. This is intentional to keep the design simple
and is not considered a security issue.
2024-01-05 07:43:19 -08:00
Jeff Mitchell 263660a7cb Add support for templating key_id (#4215) 2024-01-04 21:19:36 -05:00
Dan HeathandRobin Beck f1fc5e9a29 docs: Update release notes with fixes (#4192)
* docs: Update release notes with fixes

* docs: Add note re fix in HCP/ENT

* docs: Update version numbers

* Update website/content/docs/release-notes/v0_14_0.mdx

Co-authored-by: Robin Beck <stellarsquall@users.noreply.github.com>

---------

Co-authored-by: Robin Beck <stellarsquall@users.noreply.github.com>
2024-01-03 17:09:30 -05:00
Jeff Mitchell fe4c43305c Move and export ExpectWorkers (#4207)
This is a useful test function and keeping it in the cluster package
means it can't be used by api/cli tests.
2024-01-03 10:41:12 -05:00
hc-github-team-es-release-engineering 9b56db8858 update year in license files (#4115) 2024-01-02 10:52:22 -08:00