Commit Graph
3984 Commits
Author SHA1 Message Date
Timothy Messier 3856573eeb Merge pull request #4445 from hashicorp/llb-monthly-active-users
This adds support for tracking and reporting monthly active users for
the purpose of billing. It adds a new API endpoint,
`/v1/billing:monthly-active-users` and new cli command, `boundary
billing monthly-active-users` that can be used to view the monthly
active user counts.

This adds a new accumulating fact table to the data warehouse for auth
tokens. This fact table is used to calculate the number of active users
within a month, where an active user is a user that has at least one
issued auth token within the time range of the month.
2024-02-23 11:07:51 -05:00
Timothy Messier 4b0e7ab5a3 chore(authtoken): Fix lint errors in tests 2024-02-23 16:06:36 +00:00
Michael Milton 2e69d59dd2 feat(billing): Add cli subcommand for monthly active user counts 2024-02-23 15:44:10 +00:00
Timothy Messier 111dc87ead feat(billing): Fix end time comparision for all view 2024-02-23 15:44:10 +00:00
Timothy Messier e6c3795f91 refact(db): Renumber migrations for billing 2024-02-23 15:44:10 +00:00
Timothy Messier edfd8b5f54 feat(billing): Support -/+ infinity
This updates the billing repository to use timestmap.Timestamp when
constructing the queries to retrieve monthly active users. This allows
for specifying NegativeInfinity to easily retrieve all monthly active
user counts.
2024-02-23 15:44:10 +00:00
Timothy Messier 0f765e7149 feat(timestamp): Support -/+infinity for Valuer
When converting a timestamp.Timestamp for use in SQL, this now correctly
converts the NegativeInfinity and PositiveInfinity constants into the
corresponding `-infinity` and `infinity` SQL constants.
2024-02-23 15:44:10 +00:00
Timothy Messier e09bf09a95 refact(billing): Use sql functions instead of views
These functions will ensure that UTC time is used for billing queries,
eliminating the need for the repository to set the timezone. This also
means the repository no longern needs a writer.
2024-02-23 15:44:09 +00:00
Timothy Messier 7c14e42897 refact(census): Make emitting events stateful for a census job 2024-02-23 15:44:09 +00:00
Timothy Messier a4b34f67c8 feat(census): Add support for multiple metrics 2024-02-23 15:44:09 +00:00
Timothy Messier 5405a275ab feat(census): Update census tables to support additional metrics 2024-02-23 15:44:09 +00:00
Timothy Messier 5aafe66c3c test(ratelimit): Update tests due to new endpoint 2024-02-23 15:44:09 +00:00
Michael Milton 280e9abb89 feat(billing): Add service handlers for monthly active user counts 2024-02-23 15:44:09 +00:00
Timothy Messier d84eb01516 feat(billing): Add sql functions for monthly active user counts
This adds two sql functions that can be used to access the views to
retrieve monthly active user counts. The functions ensure that any time
calculates are performed in UTC, so that the month bounds align with the
start of the month in UTC.

1. hcp_billing_monthly_active_users_last_2_months() will return monthly
   active users for the current and previous month.
2. hcp_billing_monthly_active_users_all() will return monthly active
   users for all months. This function can also be provided a start time
   and or end time to filter the results to a specific range.
2024-02-23 15:44:09 +00:00
Michael Milton 7d5c3e48cd feat(billing): Add domain level package for monthly active user counts 2024-02-23 15:44:09 +00:00
Timothy Messier 324c474f5d feat(billing): Add views for monthly active user counts 2024-02-23 15:44:09 +00:00
Timothy Messier f3caf21979 test(authtoken): Associate test account with a user
This test started failing now that the data warehouse records a auth
token fact when an auth token is issued and it requires that the auth
token has a user associated with it.

Since this test is testing the interaction with the database directly,
and not via the repository, it by-passes the application checks that
would prevent an auth token without an associated user being inserted.

This test is updated to meet this same pre-condition prior to attempting
to insert into the database.
2024-02-23 15:44:09 +00:00
Timothy Messier bbb43e20a0 test(sqltest): Remove impossible assertion
Now that there is an auth token fact table in the data warehouse, it is
not possible to insert an auth_token with an old public_id even after
that auth_token was deleted, since it now causes a constraint violation
on the data warehouse table.
2024-02-23 15:44:09 +00:00
Timothy Messier 9514a76289 test(sqltest): Fix tests due to new auth_token insert trigger
With the addition of an after insert trigger to the auth_token table,
entries are added to the wh_user_dimension table when auth token's are
inserted with the 'token issued' status. This caused a number of tests
to fail that assumed the user dimension table would be empty prior to
inserting sessions. This introduces a number of changes to the tests:

- In the test setup, auth tokens are not created with an explicit
  expiration time and status. The expiration time ensures that the
  tokens are 'valid' for the test. The status allows test to make
  assertions on tokens in different statuses, and allow the status to
  change during the test.
- Tests make the correct assertions on the number of entries in the user
  dimension table after test setup.
- User dimension tests modify a user after the standard setup to ensure
  that a new user dimension is added when a session is inserted.
2024-02-23 15:44:08 +00:00
Timothy Messier 9e0d96b887 feat(dw): Update auth token fact when auth token is deleted
This adds a function and after delete trigger to the auth_token table to
ensure that a corresponding auth token fact is updated with the deleted
time and sets the auth token valid time range. The data warehouse will
only be updated if the token that was deleted is in the 'token issued'
status.
2024-02-23 15:44:08 +00:00
Timothy Messier b938dd6706 feat(dw): Insert/update auth token fact when auth token updated
This adds a function and update trigger to auth_token to ensure that:

1. If the auth token is updated to the issued state, a auth token fact
   is added to the warehouse.
2. If the auth token's approximate last access time is updated, the
   corresponding auth token fact is updated with the new time.
2024-02-23 15:44:08 +00:00
Timothy Messier 585b344da6 feat(auth_token): Set approximate_last_access_time when token is issued 2024-02-23 15:44:08 +00:00
Timothy Messier 07b3a7a19e feat(dw): Add auth token fact after inserting issued auth token
This adds a trigger and function to ensure that an auth token fact is
created when a new auth token is created with the 'token issued' status.
2024-02-23 15:44:08 +00:00
Timothy Messier eb626bb54c refact(wh): Use auth token id for user dimension
Previously the function used to upsert into the user dimension required
both an auth token id, and a user id. However, the user id can be
determined from the auth token, in fact it already was via the
whx_user_dimension_source view. This refactor removes the user id as an
argument, since it is not needed and will not be directly available when
this function is used when populating the new auth token accumulating
fact.
2024-02-23 15:44:08 +00:00
Timothy Messier 03d1cc4572 feat(dw): Add auth token accumulating fact table 2024-02-23 15:44:08 +00:00
Timothy Messier 005f3d0843 chore(sqltest): Make it possible to enable/disable db container logs
When running the sqltests, sometimes it is helpful to see the full
database container logs, especially when there is an error in a
migration or database setup. However, it also makes it difficult to see
the test results.

This adds a new variable to the makefile to easily toggle the output of
these logs on or off. To run the tests without printing the dtabase logs
use:

    DB_LOGS=0 make test

To enable the logs use:

    DB_LOGS=1 make test

By default the logs are not printed.
2024-02-23 15:44:08 +00:00
Timothy Messier e51d0e0b4f feat(vault): Remove database notice when setting credential type
This notice just generated noise, particuarlly in some of the sqltests.
2024-02-23 15:44:08 +00:00
Timothy Messier 9d82958c9f test(sqltest): Shorten prepared statement identifiers
Some of the prepared statement identifies used in these tests exceeded
the identifier character limit. This results in postgres truncating the
name, which is fine for a test, but does result in some noise in the
test output. This change shortens the identifies to eliminate noise like
the following:

    psql:/test/credential/vault/credential_vault_library_ssh_private_key_mapping_override.sql:49: NOTICE:  identifier "insert_credential_vault_library_ssh_private_key_mapping_override" will be truncated to "insert_credential_vault_library_ssh_private_key_mapping_overrid"

The tests should no longer create notices like these.
2024-02-23 15:44:08 +00:00
Jeff Mitchell c3297bb96f Remove worker type from CLI output (#4396)
This does not currently remove the field from the message on the API but
since it will now always show `pki` it's meaningless and causing
confusion for some users.
2024-02-23 10:33:57 -05:00
Michael Li 694db71004 fix(e2e): Add extra buffer in -session-max-seconds test again (#4440) 2024-02-23 10:33:43 -05:00
Todd 366d9e95aa Add Error logging and hclog.Logger debug logging throughout the daemon (#4384) (#4439)
* Save and assign hclogger throughout the client cache daemon

* Don't event for errors happening outside of the handlers or tickers.

* Hide and ignore -store-debug and expose the -log-level flag
2024-02-22 10:20:48 -08:00
Jeff MitchellandDamian Debkowski 014a5a7aae Vet/race fixes (#4421)
This addresses all found vet/race fixes in community edition.

---------

Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
2024-02-21 16:32:26 -05:00
Ikko Eltociear Ashimine 4535af25aa Update README.md (#4434) 2024-02-21 04:26:53 -05:00
Stan Ryzhov 2497078df6 test(e2e): Add ssh log for failed requests (#4431) 2024-02-20 14:37:14 -05:00
Michael Li 4d344edecc test(e2e): Add extra buffer in -session-max-seconds test (#4428)
This test would sometimes fail due to the diff sometimes exceeding `sessionMaxSeconds+1` by less than 1 second.
2024-02-20 11:09:36 -05:00
Michael Li a48698a315 test(e2e): Add test to check target's -session-max-seconds (#4411)
* test(e2e): Add test to check target's -session-max-seconds

* test(e2e): Add additional test to check new connections are rejected

* test(e2e): Fix test check
2024-02-20 09:26:55 -05:00
Stan Ryzhov 7de0699a0d test(e2e): Verify long-lasting scripts complete successfully on tcp targets (#4423) 2024-02-16 15:22:47 -05:00
Jeff MitchellandDamian Debkowski 35cef97bd4 Linter fixes PR 3 (#4415)
* Linter fixes

* fix(bsr): update test to register TEST protocol once

---------

Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
2024-02-16 08:30:16 -05:00
Johan Brandhorst-Satzkorn e95eda7ca2 handlers: always return pagination parameters in list (#4373)
* handlers/targets: always return pagination parameters in list

* handlers/authmethods: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/accounts: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/authtokens: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/credentiallibraries: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/credentials: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/credentialstores: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/groups: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/host_catalogs: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/host_sets: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/hosts: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/managed_groups: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/roles: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/scopes: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/sessions: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/users: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.
2024-02-15 09:26:29 -08:00
Jeff Mitchell 4068829509 Merge pull request #4401 from hashicorp/jefferai-linter-fixes
Fix linter warnings, parts 1 and 2
2024-02-14 17:55:41 -05:00
Jeff Mitchell 49803e653c Linter fixes numero 2 (#4408) 2024-02-14 17:14:31 -05:00
Stan RyzhovandMichael Li a22459342b test(e2e): Add option to wait for multiple sessions (#4410)
Co-authored-by: Michael Li <michael.li@hashicorp.com>
2024-02-14 15:02:41 -05:00
Damian Debkowski 29c09f5bc2 fix(bsr): resolve race condition errors in signature file (#4393)
* fix(bsr): resolve race condition errors in signature file

* chore(bsr): add comment to define purpose of mutex lock
2024-02-14 10:33:20 -08:00
Dan Heath 2c669f4600 docs: Update deprecated install command (#4409)
* docs: Update deprecated install command

* docs: Update command to add repo
2024-02-14 13:31:30 -05:00
Dan Heath 2b938a8f10 docs: Add max # of connections to known issues (#4405) 2024-02-13 17:47:59 -05:00
Michael Li c72c614200 test(e2e): Add test to validate session connection limits (#4395)
* test(e2e): Move default client port test to its own file

* test(e2e): Add test to validate session connection limits
2024-02-13 16:28:49 -05:00
Jeff Mitchell 25bce9e8ff Fix linter warnings 2024-02-13 15:50:11 -05:00
Jim 3af259ff69 chore: update deps (#4394)
* chore: update deps

* tests: update sqlmock tests for breaking chg

* tests (handlers): sort grants in checkEqualGrants(...)

sort the expected and got grants in
checkEqualGrants(...) to make the test more
deterministic.

* tests (asciicast): update backspace enc in TestEventMarshal(...)
2024-02-13 10:50:06 -05:00
Elim Tsiagbey 1b1c8b3bf9 fix: Proxy closing listener with 0 connections left (#4389)
* fix: Proxy closing listener with 0 connections left

A bug was introduced in `0.15.0` where sessions with max connection counts were closed when the connections left hit 0. This issue was highlighted by a user: https://github.com/hashicorp/boundary/issues/4364. What was happening was when we have zero connections left the proxy code was closing the listener which closed its connections

To fix this:
- `boundary connect  -target-id=xx -host-id=xx` command with no connections left will now wait for all connections to be closed and before exiting the session just like it did in `0.14.3`
- As soon as there are no more connections left, the listener will close to stop accepting new connections
- Fix issue where the websocket connection was throwing closing errors during the session teardown.
2024-02-09 18:15:00 -05:00
Dan Heath a7b9916691 docs: Add HCSEC-2402-02 info to release notes (#4386) 2024-02-09 15:34:31 -05:00