* 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.
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package servers
|
|
|
|
import (
|
|
"github.com/hashicorp/boundary/internal/servers/store"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// A WorkerStatus is a container for the fields that a worker reports to the
|
|
// controller about itself in its status updates. While this may include a
|
|
// Name, this is different from the Worker's name in that the Worker's name is
|
|
// the name of the Worker resource in boundary where the name in the
|
|
// WorkerStatus is the name the worker has reported about itself.
|
|
type WorkerStatus struct {
|
|
*store.WorkerStatus
|
|
Tags []*Tag `gorm:"-"`
|
|
}
|
|
|
|
// NewWorkerStatus returns a new WorkerStatus. Valid options are WithName,
|
|
// WithAddress, and WithWorkerTags. All other options are ignored.
|
|
func NewWorkerStatus(workerId string, opt ...Option) *WorkerStatus {
|
|
opts := getOpts(opt...)
|
|
return &WorkerStatus{
|
|
WorkerStatus: &store.WorkerStatus{
|
|
WorkerId: workerId,
|
|
Name: opts.withName,
|
|
Address: opts.withAddress,
|
|
},
|
|
Tags: opts.withWorkerTags,
|
|
}
|
|
}
|
|
|
|
func (w *WorkerStatus) clone() *WorkerStatus {
|
|
if w == nil {
|
|
return nil
|
|
}
|
|
tags := make([]*Tag, 0, len(w.Tags))
|
|
for _, t := range w.Tags {
|
|
tags = append(tags, &Tag{Key: t.Key, Value: t.Value})
|
|
}
|
|
cw := proto.Clone(w.WorkerStatus)
|
|
return &WorkerStatus{
|
|
WorkerStatus: cw.(*store.WorkerStatus),
|
|
Tags: tags,
|
|
}
|
|
}
|
|
|
|
// TableName overrides the table name used by WorkerStatus to `server_worker_status`
|
|
func (WorkerStatus) TableName() string {
|
|
return "server_worker_status"
|
|
}
|