* 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>
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.
* 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>
* 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
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.
* 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>
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.
* 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>
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.
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.
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.
* 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
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.
* 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.
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.
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).
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.
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.
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.
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.