Add fields to server_worker to be a boundary resource (#2083)

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

* Updating server_id references to controller_id.

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

* Update the newWorkerId call to take a context and fix its error.

* Correct comment for the wt_network_address domain.
This commit is contained in:
Todd authored and GitHub committed 2022-05-18 17:03:24 -07:00
1 parent 472d7d520a
commit 2ecd550e27
33 files changed
+967 -457

No files matched your search

@@ -26,6 +26,12 @@ message Job {
}
message JobRun {
// server_id referenced an server table which was replaced with both a
// server_controller table and a server_worker table. For the purpose of
// jobs, only the controller table is relevant thus we replaced this column
// with controller_id.
reserved "server_id";
// private_id is used to access the job run but not intended to be available via the API
// @inject_tag: `gorm:"primary_key;default:null"`
string private_id = 1;
@@ -38,10 +44,6 @@ message JobRun {
// @inject_tag: `gorm:"not_null"`
string job_name = 3;
// The server_id of the server running the job and must be set.
// @inject_tag: `gorm:"not_null"`
string server_id = 4;
// The create_time is set by the database.
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp create_time = 5;
@@ -65,4 +67,8 @@ message JobRun {
// status of the job run (running, completed, failed or interrupted).
// @inject_tag: `gorm:"not_null"`
string status = 10;
// The controller_id of the controller running the job and must be set.
// @inject_tag: `gorm:"not_null"`
string controller_id = 11;
}
@@ -8,12 +8,11 @@ option go_package = "github.com/hashicorp/boundary/internal/servers/store;store"
// Worker contains all fields related to a Worker resource
message Worker {
// Public ID of the resource
// public_id is a surrogate key suitable for use in a public API
// @inject_tag: `gorm:"primary_key"`
string public_id = 10;
// Name of the resource (optional)
// Description of the resource (optional)
// @inject_tag: `gorm:"default:null"`
string name = 20;
@@ -21,21 +20,39 @@ message Worker {
// @inject_tag: `gorm:"default:null"`
string description = 30;
// Address for the worker
// Address for the worker. This must be set
// @inject_tag: `gorm:"default:null"`
string address = 40;
// First seen time from the RDBMS
storage.timestamp.v1.Timestamp create_time = 50;
// The create_time is set by the database.
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp create_time = 50;
// Last time there was an update
storage.timestamp.v1.Timestamp update_time = 60;
// The update_time is set by the database.
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp update_time = 60;
// @gotags: `gorm:"-"`
map<string, TagValues> tags = 70;
// The scope_id of the owning scope and must be set.
// @inject_tag: `gorm:"not_null"`
string scope_id = 70;
// version allows optimistic locking of the resource.
// @inject_tag: `gorm:"default:null"`
uint32 version = 80;
}
// TagValues is used because map fields cannot be repeated but can be a
// message
message TagValues {
repeated string values = 10;
// WorkerTag is a tag for a worker. The primary key is comprised of the
// worker_id, key, value, and source.
message WorkerTag {
// worker_id is the public key that key of the worker this tag is for.
// @inject_tag: `gorm:"default:null"`
string worker_id = 10;
// key is the key of the tag. This must be set.
// @inject_tag: `gorm:"default:null"`
string key = 20;
// value is the value
// @inject_tag: `gorm:"default:null"`
string value = 30;
}