Commit Graph
37 Commits
Author SHA1 Message Date
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00
Irena Rindos 2191aa1d03 refact(session connection): remove session connection state table (#4617)
* refact(session connection): remove session connection state table
2024-07-23 14:19:21 -04:00
hashicorp-copywrite[bot]andJohan Brandhorst-Satzkorn 29da0bcb92 [COMPLIANCE] License changes (#3567)
* Adding explicit MPL license for sub-package.

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Updating the license from MPL to Business Source License

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl.

* Update copyright file headers to BUS-1.1

* Rerun make gen

This will pick up the last of the license changes

* Revert "Rerun make gen"

This reverts commit dbe0968bffd92745d8663c6940debae098395a6b.

* Remove copywrite from generation script

The current version of copywrite is not sophisticated enough
to only apply the copywrite changes to certain subdirectories,
so to avoid accidentally relicensing our api and sdk modules,
we will stop running the copywrite script until such time
that it can do the right thing.

* License protobuf API as MPL

The protobuf API files are used to generate the SDK,
since we want the SDK to be MPL, the protobuf files
must also be MPL. This extends to all protobuf files
whose sources end up in the SDK directory, including:

- internal/proto/controller/api
- internal/proto/controller/custom_options
- internal/proto/plugin

It also includes the generated service directory in
internal/gen/controller/api/services, since they are
generated from the protobuf sources used for the SDK.

* Change website license file name

This makes the naming scheme consistent with the rest
of the repository.

* Add note on licensing to README

* Set copywrite license to BUSL

* Revert "Add note on licensing to README"

This reverts commit 4d865a91a7a4f11605f0dc4609355d7e3c3cfffe.

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2023-08-11 10:31:53 -07:00
Jeff Mitchell 8322916fb4 Remove all deprecated Err/Wrap/E calls (#3286) 2023-06-14 21:55:24 -04:00
Johan Brandhorst-Satzkorn 3c29308673 chore: Add license headers to all files 2023-02-03 15:54:27 -08: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
Johan Brandhorst-Satzkorn f57454b6b9 Rewrite interface{} to any (#2535)
* chore: Rewrite interface{} to any

* Add ignore revs
2022-10-25 19:29:38 -04:00
Timothy Messier eb61ac6304 refact(session): Add context to session factory
This adds a context to the session.RepositoryFactory, allowing
errors.NewDeprecated to be replaced with errors.New. It also removes the
common.SessionRepoFactory, instead packages just directly import from
the session package.
2022-09-07 17:53:40 +00:00
Todd 19b549c44a Rename package servers to server (#2222) 2022-06-20 18:20:17 -07:00
Todd beecbbb8a2 Upsert creates a new KMS and Updates PKI workers (#2187) 2022-06-15 08:27:08 -07:00
ToddandIrena Rindos 3fbf901739 Add source to worker tags table (#2087)
* Remove the server_id from session table, change it to worker_id on session_connection

This is step 1 in updating the worker table.  The worker is becoming a public resource so it must have
a public id.  We drop the server_id column on the session_connection table and add the worker_id column
so we can use the wt_public_key type.  Since db migrations are applied while the controller is offline,
it should be safe to assume all session connections are not in a running state, thus allowing us to null
out all the worker ids in the session_connection table.

For now we don't have very good enforcement of the wt_public_id contraints, since the id is currently
defined in the worker config, but this will soon change and the worker's id will be generated by the
controller.

* Adding worker tag db writing test.

* Move the server table back to the top.

* Update comment for the worker object.

* Update comment for the worker table.

* Add worker tag sources ("config" or "api")

* Revert renaming of UpsertWorker until later.

* Remove no longer needed files.

* Moving the TestWorker into the servers package. Fix the worker tags test.

* Update internal/proto/controller/storage/servers/store/v1/worker.proto

Co-authored-by: Irena Rindos <irenarindos@users.noreply.github.com>

* Place the repos back together so they can be refactored in a different PR.

Co-authored-by: Irena Rindos <irenarindos@users.noreply.github.com>
2022-05-20 11:55:54 -07:00
Todd 472d7d520a Remove the server_id from session table, change it to worker_id on session_connection (#2070)
* Remove the server_id from session table, change it to worker_id on session_connection

This is step 1 in updating the worker table.  The worker is becoming a public resource so it must have
a public id.  We drop the server_id column on the session_connection table and add the worker_id column
so we can use the wt_public_key type.  Since db migrations are applied while the controller is offline,
it should be safe to assume all session connections are not in a running state, thus allowing us to null
out all the worker ids in the session_connection table.

For now we don't have very good enforcement of the wt_public_id constraints, since the id is currently
defined in the worker config, but this will soon change and the worker's id will be generated by the
controller.
2022-05-16 15:14:12 -07:00
Jeff Mitchell 2a8e179692 Update against changes from merge 2022-05-09 14:39:15 -04:00
irenarindos 9e27605213 refact(servers): Split server table into worker and controller 2022-05-09 13:30:01 -04:00
Todd 687dd1bda6 Move the session cleanup job logic into the session package. (#2060)
* Move the session cleanup job logic into the session package.

This is part of a broader effort to more narrowly define the purpose of the internal/server directory to be for interacting with servers themselves.  Future changes will continue to remove things from this directory until the purpose of the directory is clearly working primarily with the boundary servers resource.
2022-05-05 10:29:30 -07:00
Lars Lehtonen b6ee5dc9cc internal/session: fix dropped test errors (#1928) 2022-03-17 12:57:29 -04:00
Timothy Messier 9aa2d4cd84 test(session): Speed up some tests around dead worker cleanup
This removes or reduces the time that is waited in a number of tests by
allowing the grace period time be a configuration option on the
connection repository.
2022-03-15 13:51:15 -04:00
Timothy Messier 79670180a7 refact(session): Move domain logic of Worker Status into domain service
This creates a domain service function `session.WorkerStatusReport`. The
service performs two functions:

1. Checks the status for all of the reported sessions, returning a
   report of the sessions that are in a "non-active" state, i.e.
   "cacneling" or "terminated".
2. Looks for any "orphaned" session connections, i.e. connections that
   are active but were not reported by the worker. These connections are
   marked as closed.

This also removes the "ShouldCloseConnectionsOnWorker" logic, as this
was determined to not be a possible state, and was unnecessary.
2022-03-15 13:51:15 -04:00
irenarindos 32132d6bc1 refactor(session connections): Refactor connection closure 2022-03-15 12:11:31 -04:00
irenarindos 3482f91a17 refactor(connections): Move connect connect to the Connection repo 2022-03-15 12:11:31 -04:00
Irena Rindos 5a2c0db586 fix(session connections): Create session connection repository 2022-03-15 12:11:31 -04:00
Jim 591ec476e7 refactor: Update internal/db and oplog to use go-dbw package for database operations. (#1785)
* chore: Add new dbw dependency

* refactor: Convert to use dbw.DB

* refactor (db): Change GetTicket(...) signature

* feature (db tests): Added TestDeleteWhere(...)
Adding this allows us to eliminate a leak of the gorm library

* refactor: Add ctx to ScanRows(...) signature
This is required to refactor all the deprecated errors pkg calls.
This refactor required adding a context to quite a few call chains
and in particular the job scheduler bits

* feature (db/tests): Add support for test opt: WithTestLogLevel(...)
This test only option allows callers to specify a log level for the
underlying db package (where supported/applicable) when calling
TestSetup(...)

* refactor (db): Simplify Db type
Only store the underlying *DB and create the *RW on demand when
needed.

* refactor (oplog): Port to using dbw pkg for db operations

* refactor (db): Remove gormDB(...) func

* tests (db): Add unit tests for TestDeleteWhere(...)

* chore: make fmt changes to formatting
2022-01-05 14:38:38 -05:00
Jim baa1d88f1f feature: Add client ip to inbound request information (#1678)
* feature: Add client ip to inbound request information
* feature (workers): Add the user's client IP to a session's connection information (#1749)
2021-12-09 20:41:08 -05:00
Jim 136ac00b49 refact: Changes required for gorm v2 (#1528) 2021-09-30 08:47:34 -04:00
s-christoffandJim 6b78108ecf Update primary error functions to take a context, deprecate old functions (#1358)
* add new error funcs which take a ctx and deprecate existing funcs

* use context where available when writing error events

* remove circular internal/errors pkg dep

* suppress some chatty errors using errors.WithoutEvent()

* convert auth oidc funcs to take context where needed to write events

Co-authored-by: Jim <jlambert@hashicorp.com>
2021-07-29 20:52:56 -04:00
Jeff Mitchell ce52acb968 Update strutil import 2021-07-14 17:37:40 -07:00
Chris Marchesi 5a70875726 internal/servers/controller: Worker failure connection cleanup (#1340)
This commit adds the support to do the following:

* Mark connections for non-reporting workers as closed. This is the
controller counterpart to the worker functionality (see #1330). This is
written as a scheduled job that does the work DB-side in a single atomic
query.

* Works to reconcile states if such a broken controller-worker
connection resumes and a worker reports a connection as connected that
should be disconnected. In this case, the controller will send an update
request, and the worker will honor it and terminate the connection.

* Further refinement of the grace period setting has been added here.
We have converged on the current server "liveness" setting as our
default here, which is half of the previous 30s (15 seconds, in other
words). Additionally, this is now configurable on the controller and
worker side, with the caveat that it's currently impossible to do so in
config as the setting has been untagged in HCL. This is exposed so that
we can run some sophisticated testing scenarios where we skew the grace
period to either the controller or worker to ensure the aforementioned
reconciliation works.

* Some repository functions have been added to support the new
functionality, in addition to some test code to the worker to allow
querying of session state while testing.

* Finally, we've added some add timestamp subtraction functions
as well, basically serving as the opposite of the addition functions.
2021-07-14 09:14:24 -07:00
Jeff Mitchell 2cbcf9a563 Update usage of shared-secure-libs (#1393) 2021-07-12 21:06:22 -04:00
Jeff Mitchell b47b71d26c Refactor connection listing for tests (#1224) 2021-05-14 15:57:15 -04:00
Jeff Mitchell 6f34da8923 Add cleanup of dead connections no longer reported by a worker (#1220) 2021-05-14 13:23:12 -04:00
Jim c281e808d6 refactor to use WithOrderByCreateTime(...) (#1058) 2021-04-02 19:13:48 -04:00
Louis Ruch 178d4efa64 ICU-745/Refactor internal/session to new domain errors (#877)
* Refactor internal/sessions to use domain errors
2021-02-03 16:25:56 -08:00
Louis Ruch bfbb179741 ICU-738/Refactor internal/db to domain errors (#815)
* Refactor internal/db to domain errors
2020-12-21 10:07:34 -08:00
Jim af6ef1b687 Refactor existing sentinel errors (#774) 2020-11-05 16:54:03 -05:00
Jim e7e70b1b94 new domain functions for the session repo (#368) 2020-09-18 18:12:41 -04:00
Jim 611288bdc7 basic sessions (#337) 2020-09-16 12:02:02 -04:00