Commit Graph
60 Commits
Author SHA1 Message Date
Hugo 978db86186 feat(internal/db): Storage policies implementation (#767)
This commit implements part of the storage policy's database model,
focusing specifically on the operational tables for this feature.
2024-01-16 13:20:11 -08:00
Hugo b541f8ff38 chore(plugins/aws): Bump to v0.2.1 (#3798)
This new version fixes a problem with static credentials set as
environment variables.
2023-10-05 15:38:40 +01:00
Hugo dba7d88523 fix(handlers/scopes): Whitespace on Name and Description fields (#3235)
This commit fixes the behaviour of scopes where whitespace was allowed
(and thus persisted) in the Name and Description fields.

It also adds some more tests for scope Create and Updateto cover more
error cases.

For scope update, `handlers.ValidateUpdateRequest` exists, however this
was not used as it does not work properly for requests where the
`global` scope is updated.

In `ValidateUpdateRequest`, an ID check is performed and it assumes
there's always a resource prefix (eg: "p", "o") and an identifier
(random numbers and letters) after the prefix. This fails for `global`.
See `handlers.ValidId`.
2023-05-25 15:43:52 +01:00
Hugo 22ecf95449 docs: Explain -format json behaviour on boundary authenticate cmd (#3202) 2023-05-04 16:29:08 +01:00
Hugo 5f45fb620b fix(perms): Tests use action.List in resource action set (#3188)
`action.List` is a collection action, that is, it is not part of the set
of actions that can be executed against a single instance of any given
resource.

As part of the `ListPermissions` call, `idActions` is expected, that is,
all the actions that can be executed against a resource instance.
`action.List` will never be part of this. This commit updates the tests
to reflect this fact.
2023-04-27 17:48:11 +01:00
Hugo a69e963c87 chore: Update host plugins to the latest versions (#3164) 2023-04-17 17:40:04 +01:00
Hugo 5926dc40ba fix(host/plugin): Remove dead code and duplicate imports 2023-04-04 18:51:04 +01:00
Hugo Vieira e467cbbfa2 feat(cmd): Display plugin host external name if present 2023-04-04 18:51:04 +01:00
Hugo Vieira 45dc8251ec feat(api): Support plugin host external_name field 2023-04-04 18:51:04 +01:00
Hugo Vieira 2ff9b8efac feat(host/plugin): Support External Name field
The new `ExternalName` field is an optional field that is used to store
the cloud providers' human-identifiable name for a given compute
instance. This field is not user-editable, but it is kept in sync with
the cloud provider's through Boundary's `SetSyncJob`.
2023-04-04 18:51:04 +01:00
Hugo 41b1b5b4b7 feat(db): Introduce migrations for ssh targets (#2960)
Adds the schema for ssh targets. This also changes the target listing
func to not error out when it encounters a target with an unknown type.
Instead, it now ignores it and continues to the next one.
2023-02-21 16:31:22 -05:00
Hugo e455e31f9e fix(target): Incorrectly allowing whitespace on Target's address field (#2862) 2023-02-02 10:51:39 -08:00
Hugo 0bee55aa19 fix(target): Correct accounting of updated rows when deleting address (#2799)
If an update call was made to a target that removed an address, for a
target that already did not have an address, the incorrect number of
rows updated was being reported. During the update the target's version
was correctly being updated, resulting in one row being updated.
However then the delete call would result in zero rows being deleted,
since there was no address associated with the target, and this would
replace the value for the returned rowsUpdated. This resulted in the
target service thinking that no update happened, and it would report an
error.
2023-01-19 16:12:04 -05:00
Hugo 1fb960575f Merge pull request #2613 from hashicorp/llb-target-address
Assign a Network Address to a Target
2023-01-09 18:35:19 +00:00
Hugo Vieira f85da3ee2b feat(cmd): Create target using address on boundary dev / database init
Creates a target using an address for boundary dev and when first
init-ing boundary (boundary database init).

It also makes this newly created target the default one
(ttcp_1234567890). The target using host sources is now a secondary
target (ttcp_0987654321).
2023-01-09 15:39:55 +00:00
Hugo Vieira 1f9063e042 docs(target): Introduce direct address targets and explain tradeoffs 2023-01-09 15:39:55 +00:00
Hugo Vieira 803cd278ae fix(cmd): boundary connect SSH depending on a host id for ssh aliasing
Targets are not guaranteed to have Host Ids anymore, so we now use
Target Id when a Host Id is not present.
2023-01-09 15:39:55 +00:00
Hugo Vieira c82d2efb14 feat(cli): Implement address flag for boundary targets create/update
This commit adds CLI support for addresses to be attached directly to a
Target, for all current types of Target (ssh and tcp).

It also clarifies the relevant documentation regarding the autogen of
API option functionality.
2023-01-09 15:39:55 +00:00
Hugo 4b03a39958 chore: Update changelog with bytes up and down changes (#2665) 2022-12-01 18:15:08 +00:00
Hugo Vieira bfd65feb90 feat(cmd): Display session connection information 2022-10-26 17:44:28 +01:00
Hugo Vieira d206635d74 fix(connection): Make bytes up and down a signed 64-bit integer
This fixes a theoretical issue with database interaction. Because the
fields in the database are signed 64-bit integers, it's theoretically
possible to overflow them if we're using unsigned 64-bit integers in the
application code.
2022-10-26 17:44:28 +01:00
Hugo Vieira c81398cbf3 feat(worker): Report bytes up and down on Status updates
With this commit, the Worker now sends BytesUp and BytesDown for each
of the connections it handles to the Controller in the Status request.

The Controller then persists these fields to the database. There is also
a new trigger to prevent bytes_up and bytes_down to change after a
connection has been closed, as the last update to a session_connection
row should be the one that is performed as part of the connection
closure process.
2022-10-26 17:44:22 +01:00
Hugo f023f05c11 feat(worker): Report bytes up/down on Worker connection closure
Introduces data about bytes read and written to the connection close
payload. No changes are required in the Controller because the RPC
messages already contained the required fields. As of this commit,
bytes_up and bytes_down columns in the session_connection table are now
populated when a connection closes.

Refs: #2509
2022-10-26 17:43:05 +01:00
Hugo 1bb80624b8 feat(worker): net.Conn implementation to count Bytes Read and Written
This commit introduces a new net.Conn implementation (countingConn) that
will keep track of bytes read and written for a particular client
connection. This is then implemented into the worker code using
interface composition.

Refs: #2501
2022-10-26 17:43:04 +01:00
Hugo 902ca3cccb fix(genapi): uint64 fields failing to be unmarshalled (#2492)
uint64 fields get marshalled into json by protobuf as strings, so we
have to tell the json parser to look for strings when unmarshalling.
2022-09-26 15:27:28 +01:00
Hugo f3f0c55d91 Merge pull request #2422 from hashicorp/hugoamvieira-controller-dbswap
If the database url is updated on Boundary's config and then a SIGHUP
triggered, we now connect to the new database, ensure it's OK to use
and use that one going forwards instead.

This allows a controller to be deployed in a more dynamic infrastructure
where, for example, database credentials could change, without having
to restart the controller.

This operation is done atomically to prevent errors and inconsistency. 
A timeout is present so that if the object is swapped after the 
existing one has been looked up it isn't immediately invalidated. 
The timeout is a maximum; a ticker once a second that looks at
stats to determine how many database connections are still in use 
and then closes the driver as soon as none are in use.
2022-09-12 18:05:11 +01:00
Hugo VieiraandJeff Mitchell bed6e1a0ff feat(server): Reload database on SIGHUP
If the database url is updated on Boundary's config and then a SIGHUP
triggered, we now connect to the new database, ensure it's OK to use
and use that one going forwards instead.

This allows a controller to be deployed in a more dynamic infrastructure
where, for example, database credentials could change, without having
to restart the controller. In this case only a database url config
change and a SIGHUP signal to all controllers would be required.

This uses an atomic.Pointer to store wrapped DB objects. This allows
atomically swapping to the new object. A timeout is introduced so that
if the object is swapped after the existing one has been looked up it
isn't immediately invalidated. The timeout is a maximum; a ticker once a
second that looks at stats to determine how many database connections
are still in use and then closes the driver as soon as none are in use.

This could be done with mutexes to avoid checking stats in a loop, but
that carries its own risk: if a write lock is attempted to be acquired
while a query is holding a read lock, the write lock will block, and any
subsequent read locks will also block since write locks take priority.
As a result, if a query is long-running or timing out, all other queries
in the system will become blocked. Our default user request timeout is
90 seconds and some jobs have no timeout at all, so this is not a purely
theoretical concern, even if it's unlikely.

Refs: #2435
Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2022-09-12 17:55:32 +01:00
Hugo Vieira 8ab9ffbcac refact(cmd): Encapsulate some functionality on Command and Server
This commit extracts 3 separate pieces of functionality into their own
function/method:

- Extracts the database opening with the intention to have a function
  that performs all that functionality but returns the created database
  object rather than setting it to the Server structure.
- Extracts database validation logic, to provide a common code path for
  upcoming functionality.
- Expose schema manager on the Command struct as well as providing
  common functions to acquire shared lock/close.
2022-09-12 17:55:32 +01:00
Hugo Vieira 621f8a9ff2 fix(schema): Database connection not cleanly closed
This commit introduces closing the Schema Manager's underlying driver
connection. We were only releasing the shared lock but not actually
cleaning up the db connection and relied on the fact that the process
would exit to do that for us.
2022-09-12 17:55:32 +01:00
Hugo Vieira bf1486f75e refact(target): Add context to RepositoryFactory constructor
`errors.New` requires a context, so I've made that available from the
Controller, and updated all `NewDeprecated` functions to `New` while
I was at it
2022-09-07 17:53:40 +00:00
Hugo Vieira bf263fbd7d perf(target): Use new Permissions object to determine resource access
Using the new Permissions object, we can build a list of the level of
access a user should have based on the grants they've been given,
meaining we don't need to fetch all resources from the database to then
remove the ones the user shouldn't be able to see.

This commit also removes some unused options in `ListTargets`
for the sake of simplicity.
2022-09-07 17:53:40 +00:00
Hugo Vieira 63196ee4ca feat(target): Implement new WithPermissions option
Also changes the Target RepositoryFactory to allow for passing options
at construction time.
2022-09-07 17:53:40 +00:00
Hugo Vieira 224f8d2d4e refact(controller): Move Target Repository Factory to the target package 2022-09-07 17:53:40 +00:00
Hugo Vieira ccb17df01a feat(auth): Get all authorised scope info for a given list request 2022-09-07 17:49:01 +00:00
Hugo Vieira 9ee5a9f713 feat(perms): Derive permissions list from user grants 2022-09-07 17:49:01 +00:00
Hugo cc54a834e8 feat(worker): Instrumentation for Controller Cluster Communication (#1998)
* feat(worker): Instrumentation for Controller Cluster Communication

Adds request latency observations to the worker side (client) of
worker <-> controller cluster communications by integrating a new
grpc client interceptor.

* style(controller): make-gen-deltas changes
2022-04-13 15:52:54 -07:00
Hugo 06c13064cc Merge pull request #1963 from hashicorp/hugoamvieira-proxyws-metrics
feat(worker): Implement proxy handler websocket instrumentation
2022-04-11 14:53:52 +01:00
Hugo Vieira 3564776517 feat(worker): Implement proxy handler websocket instrumentation
Add metrics on read/written bytes and active worker websocket
connections.
2022-04-11 14:34:40 +01:00
Hugo 1bb2c5983d Merge pull request #1910 from hashicorp/hugoamvieira-worker-start-listeners
refactor(worker): Startup, shutdown and cluster tests changes
2022-03-31 16:28:55 +01:00
Hugo Vieira aae944be37 test(worker): Remove test-only hooks from actual code
This change introduces a `nonceFn` field that can be changed
by a test but at runtime is transparent to the code that calls it.

The current nonce-generating logic defaults to a test-only field which
opens us up to this value inadvertently being set.
With this change, the default behavior becomes using `base62` to
generate a random nonce, and any tests have to explicitly change that.
2022-03-29 16:46:02 +01:00
Hugo Vieira 61e310998f refactor(worker): Decouple listeners/servers shutdown
This change is the Worker-side counterpart to the change in
eebdfb88dc.
2022-03-29 16:46:02 +01:00
Hugo Vieira 657b099440 refactor(worker): Ensure startListeners consistency with controller
Implements changes on Worker's `startListeners` func to be consistent
with the changes on the Controller's side done in
b5ef468d33.
2022-03-29 16:45:56 +01:00
Hugo Vieira 1ebd7deccf refactor(worker): Validate listener configuration in New
With this change, the Worker is now aware of its own listeners in a
more codified and structured way.

These changes have already been made in the controller on
8d48a8515c. They're now made on the
worker for similar reasons.
2022-03-29 16:44:05 +01:00
Hugo 244237cd2f feat(controller): Add health endpoint (#1882)
* feat(controller): New health service and server

This change also implements a new listener purpose, `ops`.

`ops` (short for operations) is a new listener purpose that is
responsible for serving Boundary's operations endpoints, like health
and possibly metrics.

At Startup: `ops` listeners get configured as late as possible to catch
any errors with the startup process;

At Shutdown: If the health endpoint has been set-up, we introduce a
configurable delay in the process. This is to enable the health endpoint
to report unhealthy for that amount of time. `ops` listeners are also
the last listeners to be shutdown.
2022-03-28 17:16:39 +01:00
Hugo 5bdc371fa1 Merge pull request #1908 from hashicorp/hugoamvieira-controller-stop-listeners
refactor(controller): Decouple listeners/servers shutdown from Worker
2022-03-25 17:37:07 +00:00
Hugo Vieira eebdfb88dc refact(controller): Decouple listeners/servers shutdown from Worker
In general, these changes were introduced in the same vein of the
changes to controller `startListeners`.

Specifically, these changes also decouple the Controller and the Worker
shutdown processes. Currently, a call to `stopListeners` on an instance
that is running as both a Controller and a Worker would stop the
listeners for both.

Lastly, we also add unit/integration tests to the shutdown code.
2022-03-25 15:04:23 +00:00
Hugo d438a6d2dd Merge pull request #1907 from hashicorp/hugoamvieira-controller-start-listeners
refactor(controller): `startListeners` improvements
2022-03-22 16:43:29 +00:00
Hugo Vieira b5ef468d33 refact(controller): Ensure deterministic listeners start order
Previously, we initialized the listeners on the order they were provided
to us on the config file. In the future, we'll want to add new listener
purposes that depend on existing ones, so the init order needs to be
deterministic.

With this change, we'll initialize components in this order:
1. gRPC Server for Controller API.
2. All `api` HTTP Servers & gRPC Gateway Muxes.
3. `cluster` gRPC Server.

This commit introduces some renames for the sake of clarity as well as
improved test coverage:

- Removes `gatewayMux` reference from Controller object. This object was
misleading and is now uneeded.
- Removed uneeded `context.Context` arguments.
- Separates gRPC Server and gRPC Gateway concerns, both in functionality
and in naming. These two were conflated before.
- Added unit tests on `startListeners`.
2022-03-17 19:12:27 +00:00
Hugo Vieira 8d48a8515c refact(controller): Validate listener configuration in New
With this change, the Controller is now aware of its own listeners in a
more codified and structured way.

The reasoning behind these changes are as follows:

1. Currently, we're iterating over these listeners in multiple spots
along this initialization flow to check each listeners' purpose. By
doing this once when we create a Controller and essentially storing the
result, we can clean up the downstream code to use those results.

2. Initial effort to centralize Controller validation. At the moment, we
are doing a lot of validation all over the `cmd` and `config` packages.
From a conceptual perspective, Controller-related validation should
be performed in the function that is responsible for constructing the
Controller object itself. This enables any developer to look in a
single place for all the constraints that we place on creating a
Controller.
2022-03-17 17:53:04 +00:00
Hugo 6c9bfc5bbc Merge pull request #1783 from hashicorp/hugoamvieira-envfile-workerdesc
feat(config): Env/file support for Worker description
2021-12-13 15:07:45 +00:00
Hugo Vieira 5f36057f65 feat(config): Env/file support for Worker description 2021-12-10 18:21:52 +00:00
Hugo d1cadd2b3b Merge pull request #1765 from hashicorp/hugoamvieira-env-file-workercontrollers
feat(config): Add env and file support to Worker Controllers
2021-12-09 16:50:02 +00:00
Hugo Vieira 8462a65637 feat(config): Add env/file support to Worker.Controllers field
This feature allows the user to set the `controllers` field to a string
that points to either an environment variable or file.
We then dynamically pull out the value and parse it into the config.
2021-12-08 17:10:41 +00:00
Hugo Vieira a097b6db8f fix(server): Duplicated Worker nil check inside Worker nil check stmt 2021-12-08 17:09:16 +00:00
Hugo faabfc0002 Merge pull request #1758 from hashicorp/hugoamvieira-env-file-workertags
feat(config): Add env and file support to Worker Tags
2021-12-08 10:40:05 +00:00
Hugo Vieira 1576af70cc feat(config): Add env and file support to Worker Tags
This feature allows the user to set the `tags` field to a string
that points to either an environment variable or file.
We then dynamically pull out the value and parse it into the config.

This can also be done at the keys level, where you set your keys
directly in Boundary's config file, but point the values to env/file.
2021-12-07 19:21:04 +00:00
Hugo 29bdc22b41 Merge pull request #1731 from hashicorp/hugoamvieira-gosockaddr-template-support
feature(config): Add go-sockaddr templating support to Controller and Worker Addresses
2021-11-30 17:57:55 +00:00
Hugo Vieira f1063a62a0 feature(config): add sockaddr template support 2021-11-30 14:07:12 +00:00
Hugo Vieira 21a771b581 test(servers base): add tests ahead of functionality change
Adds tests to `SetupControllerPublicClusterAddress` and
`SetupWorkerPublicAddress` ahead of changes in these functions to
ensure functionality is preserved.
2021-11-29 18:19:10 +00:00
Hugo 8d3f666bba docs: include boundary-ui dependencies for make dev (#1657) 2021-11-03 13:55:58 +00:00