Commit Graph
2698 Commits
Author SHA1 Message Date
Johan Brandhorst-Satzkorn 5de0c8c102 internal: ensure schema manager is closed (#5521)
This releases the connection it holds indefinitely
2025-02-06 13:49:49 -08:00
Damian DebkowskiandJohan Brandhorst-Satzkorn acc40e0d08 fix: resolve small issues in db transactions (#5522)
* fix: use the db transaction reader and writer

* fix: internal/server: use ctx when scanning rows

* fix(host): pass db tx reader/writer into helper funcs

* fix: more precise nil check against db.Reader & db.Writer

---------

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2025-02-06 12:20:39 -08:00
Cameron Perera fc5aa31add bump ui commit to c9a74f2 (#5512) 2025-02-04 16:42:19 -06:00
Damian Debkowski 5bd142ddb4 fix(worker): set session.CloseCallTimeout to non-zero value (#5510) 2025-02-04 13:47:32 -08:00
Lauren 43338db7ed bump ui commit 835b302c1 (#5508) 2025-02-03 15:01:28 -05:00
Louis Ruch 47e314ebc2 fix(scheduler): ignore 404 when updating job run (#5495) 2025-01-29 11:33:01 -08:00
Lisbet Alvarez 348abb164a bump ui commit ae1e6d2 (#5490) 2025-01-28 17:02:49 -08:00
Elim Tsiagbey c5cc20c649 fix(worker): add GCP plugin support on the worker (#5484)
Enable worker to run GCP plugin
2025-01-28 09:35:14 -05:00
Lauren 6065350d35 bump ui commit 639aa47e1 (#5485) 2025-01-27 19:39:54 -05:00
Damian Debkowski 94e2aceaca fix(alias): remove unnecessary subquery from alias refresh (#5481) 2025-01-27 14:18:42 -08:00
Lauren bdd2332586 bump ui commit fed32aa57 (#5475) 2025-01-24 17:00:16 -05:00
Johan Brandhorst-Satzkorn 936d320ca6 internal/scheduler/job: fix test failure (#5472)
This was failing because the compared values weren't
pointers. It was probably caused by a depedency version
update changing the behavior of this function.
2025-01-24 10:25:56 -08:00
7c4451dc73 Bug: fix groups in children scopes being filtered out by grants (#5418)
* add utility functions for grants tests

* use passed in scopeID to create user

* add test for groups list

* groups: set ParentScopeId before FetchActionSetForId

* add comment to TestRoleGrantsForToken

* lint and ran make gen

* fix import groups

* add an additional test case

* remove print

* changelog

* fix(alias): set parent scope id for alias resource (#5434)

set the `ParentScopeId` before fetching authorized actions for alias

* fix(worker): set parent scope id for worker resource (#5435)

set the `ParentScopeId` before fetching authorized actions for worker

* fix(user): children scopes being filtered out by grants for user (#5436)

* fix(user): children scopes being filtered out by grants for user

Resources are being filtered out due to missing ParentScopeId when constructing Resource to pass into authResults.FetchActionSetForId.

* fix(scope): set parent scope id for worker resource (#5439)

set the `ParentScopeId` before fetching authorized actions for worker

* fix(target): set parent scope id for target resource (#5447)

set the `ParentScopeId` before fetching authorized actions for target

* fix(roles): set parent scope id for roles resource (#5452)

* fix(roles): set parent scope id for roles resource

set the `ParentScopeId` before fetching authorized actions for role resource

* test(managed-group): add grants test coverage (#5453)

* fix(managed-group): set parent scope id for managed-group resource

set the ParentScopeId before fetching authorized actions for managed resource

* fix(host): set parent scope id for host resource (#5455)

set the `ParentScopeId` before fetching authorized actions for host resource

* fix(host-set): set parent scope id for host-set resource (#5456)

set the ParentScopeId before fetching authorized actions for host-set resource

* fix(host-catalog): set parent scope id for host-catalog resource (#5457)

set the ParentScopeId before fetching authorized actions for host-catalog resource

* fix(credential-store): set parent scope id for credential-store resource (#5458)

set the ParentScopeId before fetching authorized actions for credential-store resource

* fix(authmethods): set parent scope ID for auth methods resource (#5448)

* handlers/authmethods: fix children permission

* documentation

* formatting

* fix(credential): set parent scope id for credential resource (#5459)

set the `ParentScopeId` before fetching authorized actions for credential resource

* fix(accounts): bug grants filter children accounts (#5431)

* handlers/accounts: fix children grants filtering out results unexpectedly

* make gen

* fix(authtokens): set parent scope ID for auth token resource (#5451)

* fix authtokens not passing children scope ID

* make gen

* fix(credential-libraries): set parent scope ID (#5463)

* fix(common) set parent ID before fetching action setsparent ID before fetching action sets (#5467)

* fix(common) set parent ID before fetching action sets

* make gen

* additional test

* rename test

* more tests

* remove duplicate test

* make gen

* Update CHANGELOG.md

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>

---------

Co-authored-by: Elim Tsiagbey <elim.tsiagbey@hashicorp.com>
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2025-01-24 10:23:33 -08:00
Lauren 54d438f367 bump ui commit 064375d45 (#5471) 2025-01-23 18:23:03 -05:00
April Ayres b18b586ec8 add noOp license validator function (#5468) 2025-01-23 11:55:11 -08:00
Johan Brandhorst-Satzkorn 40cb9f5c9e Restrict concurrent password hashes (#5437)
* internal/auth/password: add resizable pool

The resizable pool wraps the permit pool with a mutex
to allow it to be resized at runtime.

* internal/auth/password: add concurrency limit

The default concurrency limit is 1, and it can be
set using the SetHashingPermits function.

* internal/cmd/config: allow configuring hashing limits

The new concurrent_password_hash_workers configuration
value can be used to loosen the constraints on the
userpass auth method hashing operation.

* internal/cmd: set password hashing constraints

Sets the password hashing concurrency constraints on
startup and config reload.

* CHANGELOG: add notice about password concurrency limit
2025-01-22 13:31:42 -08:00
Irena Rindos dfe4f91be3 refactor(server): refactor worker tags (#5445)
* refactor(server): refactor worker tags
2025-01-22 13:03:55 -05:00
Lauren 4731bc8747 bump-ui-commit-904864b14 (#5449) 2025-01-21 15:38:53 -08:00
Johan Brandhorst-Satzkorn a43cb90a32 internal/session: ensure orphaned connection cleanup (#5438)
Previously, the orphaned connection cleanup job would
not detect that a connection that was created before a
worker had submitted a successful session info was
orphaned. We now fall back to using the worker update
time as an indicator if the session info time is not set.
2025-01-21 11:09:15 -08:00
Johan Brandhorst-SatzkornandDamian Debkowski ec0a3f964b Worker status refactor (#5417)
* oss: feat(proto): statistics rpc added to server coordination service

* oss: feat(session): add update statistics status service

* oss: feat(handlers): add Statistics method to worker service server

* oss: feat(worker): add statistics ticking

* oss: internal/proto: define the new RoutingInfo RPC

* oss: internal/server: repository changes for RoutingInfo RPC

* oss: internal/daemon: add RoutingInfo handler to worker service

The new RoutingInfo RPC is used to get information from the worker
that is used to make routing decisions on the controller. It also
handles the initial request from the worker.

* oss: feat(db): server_worker_session_info table

* oss: feat(proto): session info rpc for server coordination service

* oss: feat(server): worker session info request data type

* oss: feat(worker): session info ticker

* oss: feat(handler): server coordination handler for session info

* oss: feat(session): utilize session info request time for session cleanup

* oss: proto: fix some gotags comments

Some of these fields were missing comments, while others had
incorrectly formatted comments.

* oss: worker: send connection status to server

This is required for the correct tracking of orphaned connections

* oss: internal/daemon/worker: add function to wait for Statistics RPC

* oss: internal/daemon/worker: add routing info RPC

The new RoutingInfo RPC replaces part of the Status RPC,
namely the part which is used by the controller and worker
to perform decisions around the establishment of new sessions
and new worker connections.

* oss: internal/daemon/worker: remove unnecessary error check

* oss: internal/daemon/worker: lock access to config and upstreams

The new confLock protects access to the conf value and to the
addressReceivers slice.

* oss: worker: replace Status RPC with RoutingInfo

* oss: worker: deprecate the Status RPC and related types

The Status RPC and related messages have been replaced
by the RoutingInfo/SessionInfo/Statistics RPCs. The controller
will continue to support the Status RPC until two new minor
versions have been released.

* oss: internal/event: add default deny for new worker RPCs

* oss: internal/daemon/worker: allow RPC interval to be set

The new SessionInfo/RoutingInfo/Statistics RPCs run at
long intervals, which make some of our cluster tests take
a long time to complete. This allows their interval to be
configured in tests.

* oss: all: use TestWorkerRPCInterval in slow tests

This should speed up these tests significantly.

* oss: internal/tests/cluster: reset sys eventer in test

---------

Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
2025-01-09 10:26:37 -08:00
Hugo 346ac58fa3 feat(cmd): Default to azure plugin when performing db migration (#5422) 2025-01-08 17:25:13 +00:00
Timothy Messier 71af25f584 fix(db): Remove begin when assembling migrations (#5148)
When building the set of migrations to run as part of executing the
`database migrate` or `database init`, the migrations are collected and
combined to run within a database transaction. As such the `begin` and
`commit` statements in the migration files should get removed from the
final set of statements that get executed. However, when the migrations
files were updated to include copyright and license headers, this broke
the logic that would strip out the `begin` statement.

While this does not cause any issue with executing the statements in a
single transaction, it does result in noise in the database server's
logs, with log messages like:

    BEGIN WARNING:  25001: there is already a transaction in progress
    BEGIN LOCATION:  BeginTransactionBlock, xact.c:3778

This commit fixes the logic to correctly strip the `begin` for files
that have the header lines.
2025-01-08 10:40:21 -05:00
846c849589 Worker Domain Refactor (#5338)
* feat(server): Refactor LookupWorkerByName to be a test method

* feat(server): Split worker tags table

* refact(worker): Export api and config tags

* refact(server): Return worker id from UpsertWorkerStatus

* refact(server): Create ListWorkerStorageBucketUpdates domain function

* refact(server): Use dedicated HCPb-worker list func

* refact(server): Create ConnectionRoute domain function

* refact(handlers): Move worker selection logic to internal/server package

This commit moves all the logic to select a worker to handle a session
to the internal/server package. Most functions were moved to this
package with no changes, however, there are a couple of notable
exceptions:

- Given that we don't use GRPC errors in repos, all errors were adjusted
  to use the internal/errors package instead.
- StorageBucketFilterCredIdFn is now used to prevent the internal/server
  package from importing internal/storage/plugin, which would cause a
  dep cycle. Callers of SelectSessionWorkers must implement this func
  which is responsible for returning a storage bucket's worker filter as
  well as its associated credential id.
- authorizeSessionWithWorkerFilter now receives an
  internal/server.(*Repository) object when called. This is transparent
  to SelectSessionWorkers callers as it is handled internally.

* feat(server): Add FilteredWithFeatures fn and new server options

* refact(server): create new list and lookup worker queries

* test(server): Add WorkerList unit tests

* feat(server): Implement WorkerList randomness using crypto/rand pkg

* chore(db): add index to server_worker table

* refact(server): prefix test method with Test

* refact(server): rename Downstreamers interface to Graph

* chore(server): unexport and rename method

* chore: add doc string to WorkerAddress (#5420)

---------

Co-authored-by: Irena Rindos <irenarindos@users.noreply.github.com>
Co-authored-by: irenarindos <irena.rindos@gmail.com>
2025-01-08 15:18:03 +00:00
Johan Brandhorst-Satzkorn 1cbe1ca463 internal/event: fix log processor race (#5401)
The cloud events formatter Process function would call
the signer without protecting it, which was racy with the Rotate
function.
2025-01-07 09:11:52 -08:00
Johan Brandhorst-Satzkorn 7b30697ddd internal/session: fix race condition in connection cleanup (#5402)
The totalClosed variable was accessed in both the Status and the Run
functions, which may be called from independent goroutines.
2025-01-03 10:28:21 -08:00
Damian Debkowski 868d7b8a2d test(daemon): remove tests with multihop (#5397) 2024-12-30 12:21:52 -08:00
David Kanney 2342e4b644 fix(target): Assign session connection limit to SessionAuthorization.ConnectionLimit (#5396)
* fix(target): Assign session connection limit to SessionAuthorization.ConnectionLimit

* test(target): Update TestAuthorizeSession & TestAuthorizeSessionTypedCredentials to check session connection limit
2024-12-30 14:16:39 -05:00
Damian Debkowski dd1482b5ac test(cluster): check worker status multiple times (#5393) 2024-12-23 11:39:58 -08:00
Johan Brandhorst-Satzkorn 1a6320794e cmd: propagate keyring reading errors (#5360)
Reading a token from the keyring can sometimes fail for reasons
other than the token not being present in the keyring. This PR
introduces a new error used to indicate that the token requested
could not be found in the keyring and propagates errors from the
keyring up to the caller, so that the caller can act on them.

Additionally, this fixes a bug in the client cache where it would
incorrectly assume that a token had been removed from the
keyring, when in fact there was an error reading from the keyring.
2024-12-23 09:21:18 -08:00
Damian Debkowski 98bb4c8c31 test(cluster): split tests between parallel and sequential packages (#5390) 2024-12-20 13:53:37 -08:00
Johan Brandhorst-Satzkorn 1b6b22ef4f internal/daemon/worker: improve runtime and reduce noise (#5387)
TestRotationTicking would previously wait for 5 rotations, which is
pretty slow considering each rotation takes 20 seconds. Reduce
the number to 3, and use require instead of assert to remove
noise during flaky test runs.

This doesn't fix the flakiness of this test, but it should reduce the log spam.
2024-12-20 12:02:22 -08:00
Johan Brandhorst-Satzkorn 20f11ab01b Revert "internal/daemon: speed up multi-worker tests (#5370)" (#5386)
Unfortunately, this started causing the enterprise tests to break in
an unexpected way. Reverting to spend some more time testing the changes.
2024-12-19 09:29:48 -08:00
Johan Brandhorst-Satzkorn 862a30c389 internal/daemon: speed up multi-worker tests (#5370)
Instead of sleeping, we can poll for the desired state. Also,
run shutdowns in parallel.
2024-12-17 09:18:27 -08:00
David Kanney f62e67584e chore: Clarify GrantHash behavior when there are no GrantTuples (#5334)
* chore: Simplify appending

* test(grants): De-dupe hash comparison

* chore(grants): Remove TODO & add clarifying comment

* test(grants): Add test cases to enforce empty grants behavior
2024-12-06 16:45:38 -05:00
Johan Brandhorst-Satzkorn c85fad27f6 internal/event: avoid reusing canceled context (#5304)
Don't error in ReleaseGate if the context used for the original
event has been cancelled. Any error in ReleaseGate causes the
controller to terminate its startup. If a user was trying to send
a request to the Boundary controller as it started up, the context
tied to the request would be reused to attempt logging the
observation associated with the request after the logging gate
was released. This would always fail, as the context associated
with the request was canceled.

We now use a new context timeout for events logged after the release
gate is released, if the original context was canceled.
2024-12-04 09:50:25 -08:00
Bharath Gajjala 58cc322c63 Refactor redundant append operations in test setup (#5211)
* Refactor redundant append operations in test setup

- Simplified code by removing unnecessary if-else conditions in the wantUserIds and wantGroupIds blocks.

Fixes #5205

* chore: fmt fix
2024-12-03 08:47:51 -05:00
Johan Brandhorst-Satzkorn 10370edf59 internal/commands/server: prevent test panic on timeout (#5249)
Previously, if one of these tests failed to start their servers before
the timeout, there was a risk that the goroutine started to run
the server would invoke t.Errorf after the test itself had concluded.
Replace t.Errorf with fmt.Printf to avoid the panic, and include
the test name for debugging.
2024-11-22 09:57:41 -08:00
Michael Gaffney e086fd3007 test(batch): Fix data races in tests
Fixes: 9b984b0ab6
2024-11-19 08:49:57 -05:00
Johan Brandhorst-Satzkorn a2be306eb4 More managed groups limit fixes (#5245)
* internal/handlers/managed_groups: ensure membership lookup is unlimited

Previously, we would only show the first 10,000 members in the group,
giving the impression that a complete list was performed. Now we
list all members.

* internal/handlers/accounts: ensure group lookup is unlimited

Previously, we would only show the first 10,000 managed group
memberships. Now we list all group memberships of an account.
2024-11-15 10:27:20 -08:00
Johan Brandhorst-Satzkorn d830bdd416 internal/auth/oidc: ensure all managed groups are tested on auth (#5242)
Previously, we would list the managed groups with an implied
filter of db.DefaultLimit (10,000), which would incorrectly remove
a user from managed group memberships if there were more
than 10,000 managed groups in an auth method. Explicitly
set the list limit to unlimited to ensure all managed groups are
updated appropriately.
2024-11-14 15:47:08 -08:00
Elim Tsiagbey 514bcc19f6 feat(gcp): add GCP plugin (#5229)
Add GCP as a supported plugin for dynamic host catalogs
2024-11-08 11:09:29 -05:00
Hugo f227020b67 feat(scheduler): Use job table to select jobs to run
This commit changes the logic around selecting jobs to run. Before this,
Boundary used a view "job_jobs_to_run" which was a collation of all jobs
that were not running and scheduled to run. When jobs were requested to
run, Boundary would look at this view, grab a certain amount of jobs and
insert them into the "job_run" table. Importantly, while the amount of
jobs to be scheduled at once defaulted to 1 in the scheduler package,
this was entirely overriden in the controller package to -1 (no limit,
run all jobs that the query would return).

With this commit, Boundary now looks at the "job" table directly for
jobs to run, regardless of job run status. This was done to improve DB
performance as the view (which queried all "job_run" rows) was causing
significant DB contention.

Additionally, the option to limit job runs is now removed since it was
already hardcoded to -1 and not user-configurable anyways.

Should the need arise to implement this limit again, this will have to
be done in a different way since the new query does not account for
running jobs and limiting the rows returned after jobs are already
running would yield a no-op (the new query inserts nothing into
"job_run" if any given job is already running).
2024-11-06 16:15:49 +00:00
Hugo 27c432a748 feat(scheduler): Drop completed job runs as they complete
Before this change, upon the completion of a job run, the scheduler
would update a job_run entry with the completed status as well as the
number of objects affected by the run. Additionally, we then had a
cleaner job whose scope was deleting these completed entries from
job_run.

This commit changes this design to drop the cleaner job the and rolls
its functionality directly into the scheduler. Now, when any given job
run is complete, the scheduler will automatically delete it from the
job_run table itself.

In addition, the completed status has been removed as a valid status as
it is not set anymore.

This change follows a decision that given the data in these job_run
entries is already being deleted by the cleaner job, updating its state
when a job completes just to have it deleted is not efficient.
Additionally, no use-case for this data was surfaced.
2024-11-05 17:10:39 +00:00
daniandDamian Debkowski 62c41191ff [fix] allow IPv6 controllers, workers, and targets (#5221)
Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
2024-11-01 13:27:40 -04:00
Michael Gaffney 9529491fa6 feat(session): Delete terminated sessions in batches
This changes the periodic job that deletes terminated sessions to delete
the those sessions in batches. Prior to this, a single SQL DELETE
command was used to delete all qualifying terminated sessions. In
systems under heavy load, the statement could timeout leading to a
situation where no qualifying terminated sessions were ever being
deleted.
2024-10-25 10:25:52 -04:00
Michael Gaffney 9b984b0ab6 feat(batch): Add batching for SQL jobs
This adds a new `batch` package under the `scheduler` package.
2024-10-25 10:25:51 -04:00
Michael Gaffney 8c291a2934 feat(scheduler): Add retries to job status
This adds retries as an attribute to JobStatus allowing a job to
indicate liveness to the scheduler when work has not progressed.
A job could use this and the statusThreshold passed into the Run method
to break work up into batches that would otherwise timeout if all the
work was attempted at once, for example a long running SQL delete
command.
2024-10-25 10:25:51 -04:00
Michael Gaffney 9354a4ebcf refactor(scheduler): Add statusThreshold parameter to job.Run
The scheduler monitors running jobs to make sure they are not hung. If
the status of a running job does not change after a duration (the
interruptThreshold in the scheduler), the scheduler kills the job. This
change passes the scheduler's interruptThreshold to the job when it
calls Run() on the job.
2024-10-25 10:25:51 -04:00
Michael Gaffney 50ab600519 docs(scheduler): Clarify Job and JobStatus
This adds more details to the Job interface and the JobStatus struct to
clarify how the scheduler uses them.
2024-10-25 10:25:50 -04:00
Irena Rindos 36158056d9 feat(workers): add VerifyKnownWorkers repo function (#5189) 2024-10-23 13:41:44 -04:00