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.
This commit is contained in:
43 files changed
+578
-1079
No files matched your search
@@ -28,7 +28,6 @@ type Session struct {
|
||||
Endpoint string `json:"endpoint,omitempty"`
|
||||
States []*SessionState `json:"states,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
WorkerInfo []*WorkerInfo `json:"worker_info,omitempty"`
|
||||
Certificate []byte `json:"certificate,omitempty"`
|
||||
TerminationReason string `json:"termination_reason,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
// Code generated by "make api"; DO NOT EDIT.
|
||||
package sessions
|
||||
|
||||
type WorkerInfo struct {
|
||||
Address string `json:"address,omitempty"`
|
||||
}
|
||||
@@ -685,10 +685,6 @@ var inputStructs = []*structInfo{
|
||||
inProto: &sessions.SessionState{},
|
||||
outFile: "sessions/state.gen.go",
|
||||
},
|
||||
{
|
||||
inProto: &sessions.WorkerInfo{},
|
||||
outFile: "sessions/workers.gen.go",
|
||||
},
|
||||
{
|
||||
inProto: &sessions.Connection{},
|
||||
outFile: "sessions/connection.gen.go",
|
||||
|
||||
@@ -14,9 +14,10 @@ import (
|
||||
"github.com/hashicorp/boundary/api/authmethods"
|
||||
"github.com/hashicorp/boundary/api/authtokens"
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/tests/helper"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/testing/controller"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/atomic"
|
||||
@@ -24,54 +25,13 @@ import (
|
||||
_ "github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets/tcp"
|
||||
)
|
||||
|
||||
const shutdownReloadApiAddr = "http://127.0.0.1:9203"
|
||||
|
||||
const shutdownReloadControllerConfig = `
|
||||
disable_mlock = true
|
||||
|
||||
controller {
|
||||
name = "dev-controller"
|
||||
description = "A default controller created in dev mode"
|
||||
database {
|
||||
url = "%s"
|
||||
}
|
||||
}
|
||||
|
||||
kms "aead" {
|
||||
purpose = "root"
|
||||
aead_type = "aes-gcm"
|
||||
key = "%s"
|
||||
key_id = "global_root"
|
||||
}
|
||||
|
||||
kms "aead" {
|
||||
purpose = "worker-auth"
|
||||
aead_type = "aes-gcm"
|
||||
key = "%s"
|
||||
key_id = "global_worker-auth"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
purpose = "api"
|
||||
address = "127.0.0.1:9203"
|
||||
tls_disable = true
|
||||
cors_enabled = true
|
||||
cors_allowed_origins = ["*"]
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
purpose = "cluster"
|
||||
address = "127.0.0.1:9204"
|
||||
}
|
||||
`
|
||||
|
||||
const shutdownReloadWorkerConfig = `
|
||||
disable_mlock = true
|
||||
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1:9204"]
|
||||
controllers = ["%s"]
|
||||
}
|
||||
|
||||
kms "aead" {
|
||||
@@ -89,35 +49,16 @@ listener "tcp" {
|
||||
|
||||
func TestServer_ShutdownWorker(t *testing.T) {
|
||||
require := require.New(t)
|
||||
controllerKey, workerAuthKey, _ := config.DevKeyGeneration()
|
||||
|
||||
// Start the controller
|
||||
controllerCmd := testServerCommand(t, testServerCommandOpts{
|
||||
CreateDevDatabase: true,
|
||||
ControllerKey: controllerKey,
|
||||
UseDevAuthMethod: true,
|
||||
UseDevTarget: true,
|
||||
})
|
||||
t.Cleanup(func() {
|
||||
if controllerCmd.DevDatabaseCleanupFunc != nil {
|
||||
require.NoError(controllerCmd.DevDatabaseCleanupFunc())
|
||||
}
|
||||
})
|
||||
controllerCmd.presetConfig = atomic.NewString(fmt.Sprintf(shutdownReloadControllerConfig, controllerCmd.DatabaseUrl, controllerKey, workerAuthKey))
|
||||
|
||||
// Use code channel so that we can use test assertions on the returned integer.
|
||||
// It is illegal to call `t.FailNow()` from a goroutine.
|
||||
// https://pkg.go.dev/testing#T.FailNow
|
||||
controllerCodeChan := make(chan int)
|
||||
go func() {
|
||||
controllerCodeChan <- controllerCmd.Run(nil)
|
||||
}()
|
||||
|
||||
waitCh(t, controllerCmd.startedCh)
|
||||
rootWrapper, _ := wrapperWithKey(t)
|
||||
recoveryWrapper, _ := wrapperWithKey(t)
|
||||
workerAuthWrapper, key := wrapperWithKey(t)
|
||||
testController := controller.NewTestController(t, controller.WithWorkerAuthKms(workerAuthWrapper), controller.WithRootKms(rootWrapper), controller.WithRecoveryKms(recoveryWrapper))
|
||||
defer testController.Shutdown()
|
||||
|
||||
// Start the worker
|
||||
workerCmd := testServerCommand(t, testServerCommandOpts{})
|
||||
workerCmd.presetConfig = atomic.NewString(fmt.Sprintf(shutdownReloadWorkerConfig, workerAuthKey))
|
||||
workerCmd.presetConfig = atomic.NewString(fmt.Sprintf(shutdownReloadWorkerConfig, testController.ClusterAddrs()[0], key))
|
||||
|
||||
workerCodeChan := make(chan int)
|
||||
go func() {
|
||||
@@ -131,24 +72,27 @@ func TestServer_ShutdownWorker(t *testing.T) {
|
||||
|
||||
// Set up the target
|
||||
ctx := context.Background()
|
||||
client := buildClient(t, shutdownReloadApiAddr)
|
||||
client := buildClient(t, testController.ApiAddrs()[0])
|
||||
setAuthToken(ctx, t, client)
|
||||
|
||||
tcl := targets.NewClient(client)
|
||||
tgt, err := tcl.Read(ctx, "ttcp_1234567890")
|
||||
tgtL, err := tcl.List(ctx, scope.Global.String(), targets.WithRecursive(true))
|
||||
// tgt, err := tcl.Read(ctx, "ttcp_1234567890")
|
||||
require.NoError(err)
|
||||
require.Len(tgtL.Items, 1)
|
||||
tgt := tgtL.Items[0]
|
||||
require.NotNil(tgt)
|
||||
|
||||
// Create test server, update default port on target
|
||||
ts := helper.NewTestTcpServer(t)
|
||||
require.NotNil(ts)
|
||||
defer ts.Close()
|
||||
tgt, err = tcl.Update(ctx, tgt.Item.Id, tgt.Item.Version, targets.WithTcpTargetDefaultPort(ts.Port()))
|
||||
tgtR, err := tcl.Update(ctx, tgt.Id, tgt.Version, targets.WithTcpTargetDefaultPort(ts.Port()))
|
||||
require.NoError(err)
|
||||
require.NotNil(tgt)
|
||||
require.NotNil(tgtR)
|
||||
|
||||
// Authorize and connect
|
||||
sess := helper.NewTestSession(ctx, t, tcl, "ttcp_1234567890")
|
||||
sess := helper.NewTestSession(ctx, t, tcl, tgt.Id)
|
||||
sConn := sess.Connect(ctx, t)
|
||||
|
||||
// Run initial send/receive test, make sure things are working
|
||||
@@ -164,14 +108,7 @@ func TestServer_ShutdownWorker(t *testing.T) {
|
||||
|
||||
// Connection should fail, and the session should be closed on the DB.
|
||||
sConn.TestSendRecvFail(t)
|
||||
sess.ExpectConnectionStateOnController(ctx, t, controllerCmd.controller.ConnectionRepoFn, session.StatusClosed)
|
||||
|
||||
// We're done! Shutdown the controller, and that's it.
|
||||
close(controllerCmd.ShutdownCh)
|
||||
if <-controllerCodeChan != 0 {
|
||||
output := controllerCmd.UI.(*cli.MockUi).ErrorWriter.String() + controllerCmd.UI.(*cli.MockUi).OutputWriter.String()
|
||||
require.FailNow(output, "command exited with non-zero error code")
|
||||
}
|
||||
sess.ExpectConnectionStateOnController(ctx, t, testController.Controller().ConnectionRepoFn, session.StatusClosed)
|
||||
}
|
||||
|
||||
// largely copied from controller/testing.go
|
||||
|
||||
@@ -10,12 +10,17 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
"github.com/hashicorp/boundary/testing/controller"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/go-kms-wrapping/v2/aead"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/atomic"
|
||||
@@ -24,26 +29,6 @@ import (
|
||||
const workerBaseConfig = `
|
||||
disable_mlock = true
|
||||
|
||||
telemetry {
|
||||
prometheus_retention_time = "24h"
|
||||
disable_hostname = true
|
||||
}
|
||||
|
||||
controller {
|
||||
name = "dev-controller"
|
||||
description = "A default controller created in dev mode"
|
||||
database {
|
||||
url = "%s"
|
||||
}
|
||||
}
|
||||
|
||||
kms "aead" {
|
||||
purpose = "root"
|
||||
aead_type = "aes-gcm"
|
||||
key = "%s"
|
||||
key_id = "global_root"
|
||||
}
|
||||
|
||||
kms "aead" {
|
||||
purpose = "worker-auth"
|
||||
aead_type = "aes-gcm"
|
||||
@@ -51,38 +36,17 @@ kms "aead" {
|
||||
key_id = "global_worker-auth"
|
||||
}
|
||||
|
||||
kms "aead" {
|
||||
purpose = "recovery"
|
||||
aead_type = "aes-gcm"
|
||||
key = "%s"
|
||||
key_id = "global_recovery"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
purpose = "api"
|
||||
address = "127.0.0.1:9403"
|
||||
tls_disable = true
|
||||
cors_enabled = true
|
||||
cors_allowed_origins = ["*"]
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
purpose = "cluster"
|
||||
address = "127.0.0.1:9404"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
purpose = "proxy"
|
||||
address = "127.0.0.1:9405"
|
||||
}
|
||||
|
||||
`
|
||||
|
||||
const tag1Config = `
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1:9404"]
|
||||
controllers = ["%s"]
|
||||
tags {
|
||||
type = ["dev", "local"]
|
||||
}
|
||||
@@ -91,9 +55,9 @@ worker {
|
||||
|
||||
const tag2Config = `
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1:9404"]
|
||||
controllers = ["%s"]
|
||||
tags {
|
||||
foo = ["bar", "baz"]
|
||||
}
|
||||
@@ -103,23 +67,17 @@ worker {
|
||||
func TestServer_ReloadWorkerTags(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
rootWrapper, _ := wrapperWithKey(t)
|
||||
recoveryWrapper, _ := wrapperWithKey(t)
|
||||
workerAuthWrapper, key := wrapperWithKey(t)
|
||||
testController := controller.NewTestController(t, controller.WithWorkerAuthKms(workerAuthWrapper), controller.WithRootKms(rootWrapper), controller.WithRecoveryKms(recoveryWrapper))
|
||||
defer testController.Shutdown()
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
|
||||
controllerKey, workerAuthKey, recoveryKey := config.DevKeyGeneration()
|
||||
|
||||
cmd := testServerCommand(t, testServerCommandOpts{
|
||||
CreateDevDatabase: true,
|
||||
ControllerKey: controllerKey,
|
||||
UseDevAuthMethod: true,
|
||||
UseDevTarget: true,
|
||||
})
|
||||
defer func() {
|
||||
if cmd.DevDatabaseCleanupFunc != nil {
|
||||
require.NoError(cmd.DevDatabaseCleanupFunc())
|
||||
}
|
||||
}()
|
||||
|
||||
cmd.presetConfig = atomic.NewString(fmt.Sprintf(workerBaseConfig+tag1Config, cmd.DatabaseUrl, controllerKey, workerAuthKey, recoveryKey))
|
||||
cmd := testServerCommand(t, testServerCommandOpts{})
|
||||
cmd.presetConfig = atomic.NewString(fmt.Sprintf(workerBaseConfig+tag1Config, key, testController.ClusterAddrs()[0]))
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
@@ -138,9 +96,9 @@ func TestServer_ReloadWorkerTags(t *testing.T) {
|
||||
|
||||
fetchWorkerTags := func(name string, key string, values []string) {
|
||||
t.Helper()
|
||||
serversRepo, err := cmd.controller.ServersRepoFn()
|
||||
serversRepo, err := testController.Controller().ServersRepoFn()
|
||||
require.NoError(err)
|
||||
tags, err := serversRepo.ListTagsForWorkers(cmd.Context, []string{name})
|
||||
tags, err := serversRepo.ListTagsForWorkers(testController.Context(), []string{name})
|
||||
require.NoError(err)
|
||||
require.Len(tags, 2)
|
||||
require.Equal(key, tags[0].Key)
|
||||
@@ -151,9 +109,9 @@ func TestServer_ReloadWorkerTags(t *testing.T) {
|
||||
|
||||
// Give time to populate up to the controller
|
||||
time.Sleep(10 * time.Second)
|
||||
fetchWorkerTags("dev-worker", "type", []string{"dev", "local"})
|
||||
fetchWorkerTags("w_1234567890", "type", []string{"dev", "local"})
|
||||
|
||||
cmd.presetConfig.Store(fmt.Sprintf(workerBaseConfig+tag2Config, cmd.DatabaseUrl, controllerKey, workerAuthKey, recoveryKey))
|
||||
cmd.presetConfig.Store(fmt.Sprintf(workerBaseConfig+tag2Config, key, testController.ClusterAddrs()[0]))
|
||||
|
||||
cmd.SighupCh <- struct{}{}
|
||||
select {
|
||||
@@ -163,9 +121,31 @@ func TestServer_ReloadWorkerTags(t *testing.T) {
|
||||
}
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
fetchWorkerTags("dev-worker", "foo", []string{"bar", "baz"})
|
||||
fetchWorkerTags("w_1234567890", "foo", []string{"bar", "baz"})
|
||||
|
||||
close(cmd.ShutdownCh)
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// TestWrapper initializes an AEAD wrapping.Wrapper for testing the oplog
|
||||
func wrapperWithKey(t testing.TB) (wrapping.Wrapper, string) {
|
||||
t.Helper()
|
||||
rootKey := make([]byte, 32)
|
||||
n, err := rand.Read(rootKey)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n != 32 {
|
||||
t.Fatal(n)
|
||||
}
|
||||
root := aead.NewWrapper()
|
||||
_, err = root.SetConfig(context.Background(), wrapping.WithKeyId(base64.StdEncoding.EncodeToString(rootKey)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := root.SetAesGcmKeyBytes(rootKey); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return root, base64.StdEncoding.EncodeToString(rootKey)
|
||||
}
|
||||
@@ -196,19 +196,6 @@ func printItemTable(result api.GenericResult) string {
|
||||
}
|
||||
}
|
||||
|
||||
var workerInfoMaps []map[string]interface{}
|
||||
if len(item.WorkerInfo) > 0 {
|
||||
for _, wi := range item.WorkerInfo {
|
||||
m := map[string]interface{}{
|
||||
"Address": wi.Address,
|
||||
}
|
||||
workerInfoMaps = append(workerInfoMaps, m)
|
||||
}
|
||||
if l := len("Address"); l > maxLength {
|
||||
maxLength = l
|
||||
}
|
||||
}
|
||||
|
||||
ret := []string{
|
||||
"",
|
||||
"Session information:",
|
||||
@@ -244,17 +231,5 @@ func printItemTable(result api.GenericResult) string {
|
||||
}
|
||||
}
|
||||
|
||||
if len(item.WorkerInfo) > 0 {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Worker Info: %s", ""),
|
||||
)
|
||||
for _, m := range workerInfoMaps {
|
||||
ret = append(ret,
|
||||
base.WrapMap(4, maxLength, m),
|
||||
"",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return base.WrapForHelpText(ret)
|
||||
}
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/go-secure-stdlib/base62"
|
||||
configutil "github.com/hashicorp/go-secure-stdlib/configutil/v2"
|
||||
"github.com/hashicorp/go-secure-stdlib/parseutil"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
@@ -87,7 +87,7 @@ listener "tcp" {
|
||||
}
|
||||
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1"]
|
||||
tags {
|
||||
@@ -205,7 +205,7 @@ func (w *Worker) InitNameIfEmpty() (string, error) {
|
||||
func initNameIfEmpty(name *string) error {
|
||||
if *name == "" {
|
||||
var err error
|
||||
if *name, err = base62.Random(10); err != nil {
|
||||
if *name, err = db.NewPublicId("w"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ func TestDevWorker(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Worker: &Worker{
|
||||
Name: "dev-worker",
|
||||
Name: "w_1234567890",
|
||||
Description: "A default worker created in dev mode",
|
||||
Controllers: []string{"127.0.0.1"},
|
||||
ControllersRaw: []interface{}{"127.0.0.1"},
|
||||
@@ -201,7 +201,7 @@ func TestDevWorker(t *testing.T) {
|
||||
}
|
||||
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1"]
|
||||
tags = ["type=dev", "type=local"]
|
||||
@@ -221,7 +221,7 @@ func TestDevWorker(t *testing.T) {
|
||||
}
|
||||
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1"]
|
||||
tags {
|
||||
@@ -246,7 +246,7 @@ func TestDevWorker(t *testing.T) {
|
||||
}
|
||||
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1"]
|
||||
tags = ["tyPe=dev", "type=local"]
|
||||
@@ -263,7 +263,7 @@ func TestDevWorker(t *testing.T) {
|
||||
}
|
||||
|
||||
worker {
|
||||
name = "dev-worker"
|
||||
name = "w_1234567890"
|
||||
description = "A default worker created in dev mode"
|
||||
controllers = ["127.0.0.1"]
|
||||
tags = ["type=dev", "type=loCal"]
|
||||
@@ -315,18 +315,18 @@ func TestParsingName(t *testing.T) {
|
||||
{
|
||||
name: "no env",
|
||||
templateController: "foobar",
|
||||
templateWorker: "barfoo",
|
||||
templateWorker: "test_worker_barfoo",
|
||||
expectedController: "foobar",
|
||||
expectedWorker: "barfoo",
|
||||
expectedWorker: "test_worker_barfoo",
|
||||
},
|
||||
{
|
||||
name: "env",
|
||||
templateController: fmt.Sprintf("env://%s", controllerEnv),
|
||||
templateWorker: fmt.Sprintf("env://%s", workerEnv),
|
||||
envController: "foobar2",
|
||||
envWorker: "barfoo2",
|
||||
envWorker: "env_name_barfoo2",
|
||||
expectedController: "foobar2",
|
||||
expectedWorker: "barfoo2",
|
||||
expectedWorker: "env_name_barfoo2",
|
||||
},
|
||||
}
|
||||
for _, tt := range cases {
|
||||
@@ -390,7 +390,7 @@ func TestWorkerTags(t *testing.T) {
|
||||
name: "no tags",
|
||||
in: `
|
||||
worker {
|
||||
name = "testworker"
|
||||
name = "w_1234567890"
|
||||
}
|
||||
`,
|
||||
expWorkerTags: nil,
|
||||
@@ -400,7 +400,7 @@ func TestWorkerTags(t *testing.T) {
|
||||
name: "empty tags",
|
||||
in: `
|
||||
worker {
|
||||
name = "testworker"
|
||||
name = "w_1234567890"
|
||||
tags = {}
|
||||
}
|
||||
`,
|
||||
@@ -411,7 +411,7 @@ func TestWorkerTags(t *testing.T) {
|
||||
name: "empty tags 2",
|
||||
in: `
|
||||
worker {
|
||||
name = "testworker"
|
||||
name = "w_1234567890"
|
||||
tags = []
|
||||
}
|
||||
`,
|
||||
|
||||
@@ -903,7 +903,7 @@ func (s Service) AuthorizeSession(ctx context.Context, req *pbs.AuthorizeSession
|
||||
}
|
||||
for _, v := range servers {
|
||||
if hasWorkerFilter {
|
||||
workerIds = append(workerIds, v.GetPrivateId())
|
||||
workerIds = append(workerIds, v.GetPublicId())
|
||||
}
|
||||
workers = append(workers, &pb.WorkerInfo{Address: v.Address})
|
||||
}
|
||||
|
||||
@@ -2790,7 +2790,7 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
workerService := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
||||
_, err = workerService.Status(ctx, &spbs.StatusRequest{
|
||||
Worker: &spb.Server{
|
||||
PrivateId: "testworker",
|
||||
PrivateId: "w_1234567890",
|
||||
Address: "localhost:8457",
|
||||
},
|
||||
})
|
||||
@@ -3078,7 +3078,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
workerService := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
||||
_, err = workerService.Status(ctx, &spbs.StatusRequest{
|
||||
Worker: &spb.Server{
|
||||
PrivateId: "testworker",
|
||||
PrivateId: "w_1234567890",
|
||||
Address: "localhost:8457",
|
||||
},
|
||||
})
|
||||
@@ -3209,7 +3209,7 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
workerService := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
||||
_, err := workerService.Status(context.Background(), &spbs.StatusRequest{
|
||||
Worker: &spb.Server{
|
||||
PrivateId: "testworker",
|
||||
PrivateId: "w_1234567890",
|
||||
Address: "localhost:123",
|
||||
},
|
||||
})
|
||||
|
||||
@@ -82,7 +82,7 @@ func (ws *workerServiceServer) Status(ctx context.Context, req *pbs.StatusReques
|
||||
workerTags[k] = thisTag
|
||||
}
|
||||
worker := &store.Worker{
|
||||
PrivateId: reqServer.PrivateId,
|
||||
PublicId: reqServer.PrivateId,
|
||||
Address: reqServer.Address,
|
||||
CreateTime: reqServer.CreateTime,
|
||||
UpdateTime: reqServer.UpdateTime,
|
||||
@@ -318,12 +318,7 @@ func (ws *workerServiceServer) ActivateSession(ctx context.Context, req *pbs.Act
|
||||
return nil, status.Errorf(codes.Internal, "error getting session repo: %v", err)
|
||||
}
|
||||
|
||||
sessionInfo, sessionStates, err := sessRepo.ActivateSession(
|
||||
ctx,
|
||||
req.GetSessionId(),
|
||||
req.GetVersion(),
|
||||
req.GetWorkerId(),
|
||||
[]byte(req.GetTofuToken()))
|
||||
sessionInfo, sessionStates, err := sessRepo.ActivateSession(ctx, req.GetSessionId(), req.GetVersion(), []byte(req.GetTofuToken()))
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "error looking up session: %v", err)
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ func TestStatus(t *testing.T) {
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
serverRepo.UpsertWorker(ctx, &store.Worker{
|
||||
PrivateId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
PublicId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
@@ -83,14 +83,14 @@ func TestStatus(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker1.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
s := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
||||
require.NotNil(t, s)
|
||||
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
||||
require.NoError(t, err)
|
||||
|
||||
cases := []struct {
|
||||
@@ -105,7 +105,7 @@ func TestStatus(t *testing.T) {
|
||||
wantErr: false,
|
||||
req: &pbs.StatusRequest{
|
||||
Worker: &servers.Server{
|
||||
PrivateId: worker1.PrivateId,
|
||||
PrivateId: worker1.PublicId,
|
||||
Address: worker1.Address,
|
||||
CreateTime: worker1.CreateTime,
|
||||
UpdateTime: worker1.UpdateTime,
|
||||
@@ -125,7 +125,7 @@ func TestStatus(t *testing.T) {
|
||||
wantErr: false,
|
||||
req: &pbs.StatusRequest{
|
||||
Worker: &servers.Server{
|
||||
PrivateId: worker1.PrivateId,
|
||||
PrivateId: worker1.PublicId,
|
||||
Address: worker1.Address,
|
||||
CreateTime: worker1.CreateTime,
|
||||
UpdateTime: worker1.UpdateTime,
|
||||
@@ -206,8 +206,8 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
serverRepo.UpsertWorker(ctx, &store.Worker{
|
||||
PrivateId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
PublicId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
@@ -251,7 +251,7 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker1.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
sess2 := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
@@ -264,13 +264,13 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu2 := session.TestTofu(t)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, worker1.PrivateId, tofu2)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
||||
require.NoError(t, err)
|
||||
|
||||
s := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
||||
require.NotNil(t, s)
|
||||
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
||||
require.NoError(t, err)
|
||||
|
||||
cases := []struct {
|
||||
@@ -290,7 +290,7 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
},
|
||||
req: &pbs.StatusRequest{
|
||||
Worker: &servers.Server{
|
||||
PrivateId: worker1.PrivateId,
|
||||
PrivateId: worker1.PublicId,
|
||||
Address: worker1.Address,
|
||||
CreateTime: worker1.CreateTime,
|
||||
UpdateTime: worker1.UpdateTime,
|
||||
@@ -388,8 +388,8 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
serverRepo.UpsertWorker(ctx, &store.Worker{
|
||||
PrivateId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
PublicId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
@@ -433,7 +433,7 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker1.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
sess2 := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
@@ -446,21 +446,21 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu2 := session.TestTofu(t)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, worker1.PrivateId, tofu2)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
||||
require.NoError(t, err)
|
||||
|
||||
s := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
||||
require.NotNil(t, s)
|
||||
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
||||
require.NoError(t, err)
|
||||
deadConn, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker1.PrivateId)
|
||||
deadConn, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker1.PublicId)
|
||||
require.NoError(t, err)
|
||||
require.NotEqual(t, deadConn.PublicId, connection.PublicId)
|
||||
|
||||
req := &pbs.StatusRequest{
|
||||
Worker: &servers.Server{
|
||||
PrivateId: worker1.PrivateId,
|
||||
PrivateId: worker1.PublicId,
|
||||
Address: worker1.Address,
|
||||
CreateTime: worker1.CreateTime,
|
||||
UpdateTime: worker1.UpdateTime,
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
"github.com/hashicorp/boundary/internal/daemon/worker/session"
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/go-secure-stdlib/base62"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
@@ -316,7 +316,7 @@ func (tw *TestWorker) AddClusterWorkerMember(t testing.TB, opts *TestWorkerOpts)
|
||||
}
|
||||
if nextOpts.Name == "" {
|
||||
var err error
|
||||
nextOpts.Name, err = base62.Random(5)
|
||||
nextOpts.Name, err = db.NewPublicId("w")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -25,9 +25,11 @@ create trigger controller_insert_time_column before insert on server_controller
|
||||
create trigger controller_update_time_column before update on server_controller
|
||||
for each row execute procedure update_time_column();
|
||||
|
||||
-- Worker table adds the field: name
|
||||
-- Worker table takes the place of the server table.
|
||||
-- instead of the private_id we use a wt_public_id field named public_id since
|
||||
-- workers will now be exposed as resources in boundary.
|
||||
create table server_worker (
|
||||
private_id text primary key,
|
||||
public_id wt_public_id primary key,
|
||||
description wt_description,
|
||||
name wt_name unique,
|
||||
address text not null
|
||||
@@ -40,7 +42,7 @@ comment on table server_worker is
|
||||
'server_worker is a table where each row represents a Boundary worker.';
|
||||
|
||||
create trigger immutable_columns before update on server_worker
|
||||
for each row execute procedure immutable_columns('private_id','create_time');
|
||||
for each row execute procedure immutable_columns('public_id','create_time');
|
||||
|
||||
create trigger default_create_time_column before insert on server_worker
|
||||
for each row execute procedure default_create_time();
|
||||
@@ -51,13 +53,11 @@ create trigger worker_insert_time_column before insert on server_worker
|
||||
create trigger worker_update_time_column before update on server_worker
|
||||
for each row execute procedure update_time_column();
|
||||
|
||||
-- TODO: Migrate server entries to worker and controller tables, if necessary
|
||||
|
||||
-- Create table worker tag
|
||||
create table server_worker_tag (
|
||||
worker_id text
|
||||
worker_id wt_public_id
|
||||
constraint server_worker_fkey
|
||||
references server_worker(private_id)
|
||||
references server_worker(public_id)
|
||||
on delete cascade
|
||||
on update cascade,
|
||||
key wt_tagpair,
|
||||
@@ -71,55 +71,43 @@ drop table server_tag;
|
||||
-- Update session table to use worker_id instead of server_id, drop view first because of dependency on server type
|
||||
drop view session_list;
|
||||
|
||||
alter table session
|
||||
drop constraint session_server_id_fkey;
|
||||
-- Update session table to use worker_id instead of server_id
|
||||
-- Updating the session table modified in 01/01_server_tags_migrations.up.sql
|
||||
drop trigger update_version_column
|
||||
on session;
|
||||
alter table session
|
||||
drop column server_type;
|
||||
|
||||
alter table session
|
||||
rename column server_id to worker_id;
|
||||
alter table session
|
||||
add constraint server_worker_fkey
|
||||
foreign key (worker_id)
|
||||
references server_worker(private_id)
|
||||
on delete set null
|
||||
on update cascade;
|
||||
|
||||
drop constraint session_server_id_fkey,
|
||||
drop column server_type,
|
||||
drop column server_id;
|
||||
create trigger
|
||||
update_version_column
|
||||
after update of version, termination_reason, key_id, tofu_token, worker_id on session
|
||||
after update of version, termination_reason, key_id, tofu_token on session
|
||||
for each row execute procedure update_version_column();
|
||||
|
||||
-- Update session_connection table to use worker_id instead of server_id
|
||||
-- Table last updated in 21/02_session.up.sql
|
||||
alter table session_connection
|
||||
drop constraint server_fkey;
|
||||
|
||||
alter table session_connection
|
||||
rename column server_id to worker_id;
|
||||
alter table session_connection
|
||||
drop column server_id,
|
||||
add column worker_id wt_public_id,
|
||||
add constraint server_worker_fkey
|
||||
foreign key (worker_id)
|
||||
references server_worker (private_id)
|
||||
references server_worker (public_id)
|
||||
on delete set null
|
||||
on update cascade;
|
||||
|
||||
-- Update job run table so that server id references controller id
|
||||
alter table job_run
|
||||
drop constraint server_fkey;
|
||||
alter table job_run
|
||||
drop constraint server_fkey,
|
||||
add constraint server_controller_fkey
|
||||
foreign key (server_id)
|
||||
references server_controller (private_id)
|
||||
on delete set null
|
||||
on update cascade;
|
||||
|
||||
-- Replaces the view created in 9/01 to include worker id instead of server id and server type
|
||||
-- Replaces the view created in 9/01 to remove references to the server/worker id.
|
||||
create view session_list as
|
||||
|
||||
select
|
||||
s.public_id, s.user_id, s.host_id, s.worker_id, s.target_id,
|
||||
s.public_id, s.user_id, s.host_id, s.target_id,
|
||||
s.host_set_id, s.auth_token_id, s.scope_id, s.certificate,s.expiration_time,
|
||||
s.connection_limit, s.tofu_token, s.key_id, s.termination_reason, s.version,
|
||||
s.create_time, s.update_time, s.endpoint, s.worker_filter,
|
||||
|
||||
@@ -4836,14 +4836,6 @@
|
||||
"description": "Output only. The current status of this Session.",
|
||||
"readOnly": true
|
||||
},
|
||||
"worker_info": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/controller.api.resources.sessions.v1.WorkerInfo"
|
||||
},
|
||||
"description": "Output only. Worker information given to the client.",
|
||||
"readOnly": true
|
||||
},
|
||||
"certificate": {
|
||||
"type": "string",
|
||||
"format": "byte",
|
||||
@@ -4895,15 +4887,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"controller.api.resources.sessions.v1.WorkerInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"address": {
|
||||
"type": "string",
|
||||
"description": "The address of the worker."
|
||||
}
|
||||
}
|
||||
},
|
||||
"controller.api.resources.targets.v1.CredentialLibrary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -6,6 +6,15 @@ deps:
|
||||
breaking:
|
||||
use:
|
||||
- WIRE_JSON
|
||||
ignore_only:
|
||||
FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED:
|
||||
# The proto files in controller/api are only exposed as json files so enforcing
|
||||
# proto backward compatability doesn't make sense, except for maybe the names.
|
||||
- controller/api
|
||||
# Storage protos are used by gorm. Gorm relies on go tags and the json
|
||||
# names to determine what columns to update so we don't care of the field
|
||||
# numbers remain the same.
|
||||
- controller/storage
|
||||
lint:
|
||||
use:
|
||||
- DEFAULT
|
||||
|
||||
@@ -7,11 +7,6 @@ import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/sessions;sessions";
|
||||
|
||||
message WorkerInfo {
|
||||
// The address of the worker.
|
||||
string address = 10; // @gotags: `class:"public"`
|
||||
}
|
||||
|
||||
message SessionState {
|
||||
// The status of the Session, e.g. "pending", "active", "canceling", "terminated".
|
||||
string status = 10; // @gotags: `class:"public"`
|
||||
@@ -49,6 +44,13 @@ message Connection {
|
||||
|
||||
// Session contains all fields related to a Session resource
|
||||
message Session {
|
||||
// Worker info previously contained only the worker's address but was never
|
||||
// populated either in the database or on the API. While worker id information
|
||||
// may become helpful on a session in the future, the worker id seems the most
|
||||
// relevant information since the address can change between the time the
|
||||
// session is created and a session connection is made through that worker.
|
||||
reserved "worker_info";
|
||||
|
||||
// Output only. The ID of the Session.
|
||||
string id = 10; // @gotags: `class:"public"`
|
||||
|
||||
@@ -97,9 +99,6 @@ message Session {
|
||||
// Output only. The current status of this Session.
|
||||
string status = 180; // @gotags: `class:"public"`
|
||||
|
||||
// Output only. Worker information given to the client.
|
||||
repeated WorkerInfo worker_info = 190 [json_name = "worker_info"];
|
||||
|
||||
// Output only. The certificate generated for the session. Raw DER bytes.
|
||||
bytes certificate = 200; // @gotags: `class:"public"`
|
||||
|
||||
|
||||
@@ -56,8 +56,6 @@ message JobStatus {
|
||||
Job job = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
message StatusRequest {
|
||||
// The worker info. We could use information from the TLS connection but this
|
||||
// is easier and going the other route doesn't provide much benefit -- if you
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.storage.servers.store.v1;
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
|
||||
import "controller/storage/timestamp/v1/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
|
||||
// Controller contains all fields related to a Controller resource
|
||||
message Controller {
|
||||
// Private ID of the resource
|
||||
@@ -22,4 +23,4 @@ message Controller {
|
||||
|
||||
// Last time there was an update
|
||||
storage.timestamp.v1.Timestamp update_time = 50;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.storage.servers.store.v1;
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
|
||||
import "controller/storage/timestamp/v1/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
|
||||
// Worker contains all fields related to a Worker resource
|
||||
message Worker {
|
||||
// Private ID of the resource
|
||||
string private_id = 10;
|
||||
// Public ID of the resource
|
||||
// @inject_tag: `gorm:"primary_key"`
|
||||
string public_id = 10;
|
||||
|
||||
// Name of the resource (optional)
|
||||
// Description of the resource (optional)
|
||||
|
||||
@@ -168,7 +168,7 @@ func (r *Repository) UpsertWorker(ctx context.Context, worker *store.Worker, opt
|
||||
func(read db.Reader, w db.Writer) error {
|
||||
var err error
|
||||
onConflict := &db.OnConflict{
|
||||
Target: db.Columns{"private_id"},
|
||||
Target: db.Columns{"public_id"},
|
||||
Action: append(db.SetColumns([]string{"description", "address"}), db.SetColumnValues(map[string]interface{}{"update_time": "now()"})...),
|
||||
}
|
||||
err = w.Create(ctx, worker, db.WithOnConflict(onConflict), db.WithReturnRowsAffected(&rowsUpdated))
|
||||
@@ -187,9 +187,9 @@ func (r *Repository) UpsertWorker(ctx context.Context, worker *store.Worker, opt
|
||||
// delete all tags for the given worker, then add the new ones
|
||||
// we've been sent.
|
||||
if opts.withUpdateTags {
|
||||
_, err = w.Delete(ctx, &WorkerTag{}, db.WithWhere(deleteTagsSql, worker.PrivateId))
|
||||
_, err = w.Delete(ctx, &WorkerTag{}, db.WithWhere(deleteTagsSql, worker.PublicId))
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op+":DeleteTags", errors.WithMsg(worker.PrivateId))
|
||||
return errors.Wrap(ctx, err, op+":DeleteTags", errors.WithMsg(worker.PublicId))
|
||||
}
|
||||
|
||||
// If tags were cleared out entirely, then we'll have nothing
|
||||
@@ -200,18 +200,18 @@ func (r *Repository) UpsertWorker(ctx context.Context, worker *store.Worker, opt
|
||||
tags := make([]interface{}, 0, len(worker.Tags))
|
||||
for k, v := range worker.Tags {
|
||||
if v == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op+":RangeTags", fmt.Sprintf("found nil tag value for worker %s and key %s", worker.PrivateId, k))
|
||||
return errors.New(ctx, errors.InvalidParameter, op+":RangeTags", fmt.Sprintf("found nil tag value for worker %s and key %s", worker.PublicId, k))
|
||||
}
|
||||
for _, val := range v.Values {
|
||||
tags = append(tags, WorkerTag{
|
||||
WorkerId: worker.PrivateId,
|
||||
WorkerId: worker.PublicId,
|
||||
Key: k,
|
||||
Value: val,
|
||||
})
|
||||
}
|
||||
}
|
||||
if err = w.CreateItems(ctx, tags); err != nil {
|
||||
return errors.Wrap(ctx, err, op+":CreateTags", errors.WithMsg(worker.PrivateId))
|
||||
return errors.Wrap(ctx, err, op+":CreateTags", errors.WithMsg(worker.PublicId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ func TestTagUpdatingListing(t *testing.T) {
|
||||
|
||||
repo := tc.ServersRepo()
|
||||
srv := &store.Worker{
|
||||
PrivateId: "test1",
|
||||
Address: "127.0.0.1",
|
||||
PublicId: "test_worker_1",
|
||||
Address: "127.0.0.1",
|
||||
Tags: map[string]*store.TagValues{
|
||||
"tag1": {
|
||||
Values: []string{"value1", "value2"},
|
||||
@@ -113,8 +113,8 @@ func TestTagUpdatingListing(t *testing.T) {
|
||||
require.NoError(err)
|
||||
|
||||
srv = &store.Worker{
|
||||
PrivateId: "test2",
|
||||
Address: "127.0.0.1",
|
||||
PublicId: "test_worker_2",
|
||||
Address: "127.0.0.1",
|
||||
Tags: map[string]*store.TagValues{
|
||||
"tag2": {
|
||||
Values: []string{"value1", "value2"},
|
||||
@@ -124,28 +124,28 @@ func TestTagUpdatingListing(t *testing.T) {
|
||||
_, _, err = repo.UpsertWorker(tc.Context(), srv, servers.WithUpdateTags(true))
|
||||
require.NoError(err)
|
||||
|
||||
tags, err := repo.ListTagsForWorkers(tc.Context(), []string{"test1", "test2"})
|
||||
tags, err := repo.ListTagsForWorkers(tc.Context(), []string{"test_worker_1", "test_worker_2"})
|
||||
require.NoError(err)
|
||||
|
||||
// Base case
|
||||
exp := []*servers.WorkerTag{
|
||||
{
|
||||
WorkerId: "test1",
|
||||
WorkerId: "test_worker_1",
|
||||
Key: "tag1",
|
||||
Value: "value1",
|
||||
},
|
||||
{
|
||||
WorkerId: "test1",
|
||||
WorkerId: "test_worker_1",
|
||||
Key: "tag1",
|
||||
Value: "value2",
|
||||
},
|
||||
{
|
||||
WorkerId: "test2",
|
||||
WorkerId: "test_worker_2",
|
||||
Key: "tag2",
|
||||
Value: "value1",
|
||||
},
|
||||
{
|
||||
WorkerId: "test2",
|
||||
WorkerId: "test_worker_2",
|
||||
Key: "tag2",
|
||||
Value: "value2",
|
||||
},
|
||||
@@ -154,8 +154,8 @@ func TestTagUpdatingListing(t *testing.T) {
|
||||
|
||||
// Update without saying to update tags
|
||||
srv = &store.Worker{
|
||||
PrivateId: "test2",
|
||||
Address: "192.168.1.1",
|
||||
PublicId: "test_worker_2",
|
||||
Address: "192.168.1.1",
|
||||
Tags: map[string]*store.TagValues{
|
||||
"tag22": {
|
||||
Values: []string{"value21", "value22"},
|
||||
@@ -164,24 +164,24 @@ func TestTagUpdatingListing(t *testing.T) {
|
||||
}
|
||||
_, _, err = repo.UpsertWorker(tc.Context(), srv)
|
||||
require.NoError(err)
|
||||
tags, err = repo.ListTagsForWorkers(tc.Context(), []string{"test1", "test2"})
|
||||
tags, err = repo.ListTagsForWorkers(tc.Context(), []string{"test_worker_1", "test_worker_2"})
|
||||
require.NoError(err)
|
||||
require.Equal(exp, tags)
|
||||
|
||||
// Update tags and test again
|
||||
_, _, err = repo.UpsertWorker(tc.Context(), srv, servers.WithUpdateTags(true))
|
||||
require.NoError(err)
|
||||
tags, err = repo.ListTagsForWorkers(tc.Context(), []string{"test1", "test2"})
|
||||
tags, err = repo.ListTagsForWorkers(tc.Context(), []string{"test_worker_1", "test_worker_2"})
|
||||
require.NoError(err)
|
||||
require.NotEqual(exp, tags)
|
||||
// Update and try again
|
||||
exp[2] = &servers.WorkerTag{
|
||||
WorkerId: "test2",
|
||||
WorkerId: "test_worker_2",
|
||||
Key: "tag22",
|
||||
Value: "value21",
|
||||
}
|
||||
exp[3] = &servers.WorkerTag{
|
||||
WorkerId: "test2",
|
||||
WorkerId: "test_worker_2",
|
||||
Key: "tag22",
|
||||
Value: "value22",
|
||||
}
|
||||
@@ -199,10 +199,10 @@ func TestListServersWithLiveness(t *testing.T) {
|
||||
require.NoError(err)
|
||||
ctx := context.Background()
|
||||
|
||||
newWorker := func(privateId string) *store.Worker {
|
||||
newWorker := func(publicId string) *store.Worker {
|
||||
result := &store.Worker{
|
||||
PrivateId: privateId,
|
||||
Address: "127.0.0.1",
|
||||
PublicId: publicId,
|
||||
Address: "127.0.0.1",
|
||||
}
|
||||
_, rowsUpdated, err := serversRepo.UpsertWorker(ctx, result)
|
||||
require.NoError(err)
|
||||
@@ -211,9 +211,9 @@ func TestListServersWithLiveness(t *testing.T) {
|
||||
return result
|
||||
}
|
||||
|
||||
server1 := newWorker("test1")
|
||||
server2 := newWorker("test2")
|
||||
server3 := newWorker("test3")
|
||||
server1 := newWorker("test_worker_1")
|
||||
server2 := newWorker("test_worker_2")
|
||||
server3 := newWorker("test_worker_3")
|
||||
|
||||
// Sleep the default liveness time (15sec currently) +1s
|
||||
time.Sleep(time.Second * 16)
|
||||
@@ -233,7 +233,7 @@ func TestListServersWithLiveness(t *testing.T) {
|
||||
|
||||
got := make(map[string]struct{})
|
||||
for _, v := range actual {
|
||||
got[v.PrivateId] = struct{}{}
|
||||
got[v.PublicId] = struct{}{}
|
||||
}
|
||||
|
||||
require.Equal(want, got)
|
||||
@@ -243,7 +243,7 @@ func TestListServersWithLiveness(t *testing.T) {
|
||||
result, err := serversRepo.ListWorkers(ctx)
|
||||
require.NoError(err)
|
||||
require.Len(result, 1)
|
||||
requireIds([]string{server1.PrivateId}, result)
|
||||
requireIds([]string{server1.PublicId}, result)
|
||||
|
||||
// Upsert second server.
|
||||
_, rowsUpdated, err = serversRepo.UpsertWorker(ctx, server2)
|
||||
@@ -255,11 +255,11 @@ func TestListServersWithLiveness(t *testing.T) {
|
||||
result, err = serversRepo.ListWorkers(ctx, servers.WithLiveness(time.Second*5))
|
||||
require.NoError(err)
|
||||
require.Len(result, 2)
|
||||
requireIds([]string{server1.PrivateId, server2.PrivateId}, result)
|
||||
requireIds([]string{server1.PublicId, server2.PublicId}, result)
|
||||
|
||||
// Liveness disabled, should get all three workers.
|
||||
result, err = serversRepo.ListWorkers(ctx, servers.WithLiveness(-1))
|
||||
require.NoError(err)
|
||||
require.Len(result, 3)
|
||||
requireIds([]string{server1.PrivateId, server2.PrivateId, server3.PrivateId}, result)
|
||||
requireIds([]string{server1.PublicId, server2.PublicId, server3.PublicId}, result)
|
||||
}
|
||||
@@ -27,8 +27,9 @@ type Worker struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Private ID of the resource
|
||||
PrivateId string `protobuf:"bytes,10,opt,name=private_id,json=privateId,proto3" json:"private_id,omitempty"`
|
||||
// Public ID of the resource
|
||||
// @inject_tag: `gorm:"primary_key"`
|
||||
PublicId string `protobuf:"bytes,10,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primary_key"`
|
||||
// Name of the resource (optional)
|
||||
// Description of the resource (optional)
|
||||
// @inject_tag: `gorm:"default:null"`
|
||||
@@ -78,9 +79,9 @@ func (*Worker) Descriptor() ([]byte, []int) {
|
||||
return file_controller_storage_servers_store_v1_worker_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Worker) GetPrivateId() string {
|
||||
func (x *Worker) GetPublicId() string {
|
||||
if x != nil {
|
||||
return x.PrivateId
|
||||
return x.PublicId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -187,42 +188,42 @@ var file_controller_storage_servers_store_v1_worker_proto_rawDesc = []byte{
|
||||
0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||
0x6c, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
|
||||
0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc5, 0x03, 0x0a, 0x06, 0x57, 0x6f, 0x72,
|
||||
0x6b, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x69,
|
||||
0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65,
|
||||
0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73,
|
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72,
|
||||
0x65, 0x73, 0x73, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
|
||||
0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,
|
||||
0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12,
|
||||
0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x3c,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65,
|
||||
0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
|
||||
0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
|
||||
0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x49, 0x0a, 0x04,
|
||||
0x74, 0x61, 0x67, 0x73, 0x18, 0x46, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31,
|
||||
0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x67, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45,
|
||||
0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
|
||||
0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x67, 0x56,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
|
||||
0x22, 0x23, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x73, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f,
|
||||
0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74,
|
||||
0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x03, 0x0a, 0x06, 0x57, 0x6f, 0x72,
|
||||
0x6b, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64,
|
||||
0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73,
|
||||
0x73, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
||||
0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18,
|
||||
0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
|
||||
0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
|
||||
0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a,
|
||||
0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x3c, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e,
|
||||
0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
|
||||
0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a,
|
||||
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x49, 0x0a, 0x04, 0x74, 0x61,
|
||||
0x67, 0x73, 0x18, 0x46, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72,
|
||||
0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57,
|
||||
0x6f, 0x72, 0x6b, 0x65, 0x72, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52,
|
||||
0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x67, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74,
|
||||
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73,
|
||||
0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x67, 0x56, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x23,
|
||||
0x0a, 0x09, 0x54, 0x61, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x73, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e,
|
||||
0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72,
|
||||
0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
+10
-19
@@ -21,18 +21,16 @@ type Option func(*options)
|
||||
|
||||
// options = how options are represented
|
||||
type options struct {
|
||||
withLimit int
|
||||
withOrderByCreateTime db.OrderBy
|
||||
withScopeIds []string
|
||||
withUserId string
|
||||
withExpirationTime *timestamp.Timestamp
|
||||
withTestTofu []byte
|
||||
withListingConvert bool
|
||||
withSessionIds []string
|
||||
withWorkerId string
|
||||
withDbOpts []db.Option
|
||||
withWorkerStateDelay time.Duration
|
||||
withDeadWorkerConnCloseMinGrace time.Duration
|
||||
withLimit int
|
||||
withOrderByCreateTime db.OrderBy
|
||||
withScopeIds []string
|
||||
withUserId string
|
||||
withExpirationTime *timestamp.Timestamp
|
||||
withTestTofu []byte
|
||||
withListingConvert bool
|
||||
withSessionIds []string
|
||||
withDbOpts []db.Option
|
||||
withWorkerStateDelay time.Duration
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
@@ -100,13 +98,6 @@ func withListingConvert(withListingConvert bool) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithWorkerId allows the specification of the worker id to use
|
||||
func WithWorkerId(id string) Option {
|
||||
return func(o *options) {
|
||||
o.withWorkerId = id
|
||||
}
|
||||
}
|
||||
|
||||
// WithDbOpts passes through given DB options to the DB layer
|
||||
func WithDbOpts(opts ...db.Option) Option {
|
||||
return func(o *options) {
|
||||
|
||||
@@ -75,11 +75,4 @@ func Test_GetOpts(t *testing.T) {
|
||||
testOpts.withSessionIds = []string{"s_1", "s_2", "s_3"}
|
||||
assert.Equal(opts, testOpts)
|
||||
})
|
||||
t.Run("WithWorkerId", func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
opts := getOpts(WithWorkerId("worker1"))
|
||||
testOpts := getDefaultOptions()
|
||||
testOpts.withWorkerId = "worker1"
|
||||
assert.Equal(opts, testOpts)
|
||||
})
|
||||
}
|
||||
@@ -324,7 +324,7 @@ where
|
||||
closeConnectionsForDeadServersCte = `
|
||||
with
|
||||
dead_workers (worker_id, last_update_time) as (
|
||||
select private_id, update_time
|
||||
select public_id, update_time
|
||||
from server_worker
|
||||
where update_time < wt_sub_seconds_from_now(@grace_period_seconds)
|
||||
),
|
||||
@@ -345,6 +345,16 @@ where
|
||||
order by closed_connections.worker_id;
|
||||
`
|
||||
|
||||
// closeWorkerlessConnections closes any open connections which has the
|
||||
// worker id set to null.
|
||||
closeWorkerlessConnections = `
|
||||
update session_connection
|
||||
set closed_reason = 'system error'
|
||||
where worker_id is null
|
||||
and closed_reason is null
|
||||
returning public_id;
|
||||
`
|
||||
|
||||
orphanedConnectionsCte = `
|
||||
-- Find connections that are not closed so we can reference those IDs
|
||||
with
|
||||
|
||||
@@ -110,7 +110,6 @@ func (r *Repository) convertToSessions(ctx context.Context, sessionList []*sessi
|
||||
PublicId: sv.PublicId,
|
||||
UserId: sv.UserId,
|
||||
HostId: sv.HostId,
|
||||
WorkerId: sv.WorkerId,
|
||||
TargetId: sv.TargetId,
|
||||
HostSetId: sv.HostSetId,
|
||||
AuthTokenId: sv.AuthTokenId,
|
||||
|
||||
@@ -345,59 +345,6 @@ func (r *ConnectionRepository) DeleteConnection(ctx context.Context, publicId st
|
||||
return rowsDeleted, nil
|
||||
}
|
||||
|
||||
type CloseConnectionsForDeadWorkersResult struct {
|
||||
WorkerId string
|
||||
LastUpdateTime time.Time
|
||||
NumberConnectionsClosed int
|
||||
}
|
||||
|
||||
// CloseConnectionsForDeadWorkers will run
|
||||
// closeConnectionsForDeadServersCte to look for connections that
|
||||
// should be marked because they are on a worker that is no longer
|
||||
// sending status updates to the controller(s).
|
||||
//
|
||||
// The only input to the method is the grace period, in seconds.
|
||||
func (r *ConnectionRepository) CloseConnectionsForDeadWorkers(ctx context.Context, gracePeriod time.Duration) ([]CloseConnectionsForDeadWorkersResult, error) {
|
||||
const op = "session.(ConnectionRepository).CloseConnectionsForDeadWorkers"
|
||||
if gracePeriod < deadWorkerConnCloseMinGrace {
|
||||
return nil, errors.New(ctx,
|
||||
errors.InvalidParameter, op, fmt.Sprintf("gracePeriod must be at least %s", deadWorkerConnCloseMinGrace))
|
||||
}
|
||||
|
||||
args := []interface{}{
|
||||
sql.Named("grace_period_seconds", gracePeriod.Seconds()),
|
||||
}
|
||||
results := make([]CloseConnectionsForDeadWorkersResult, 0)
|
||||
_, err := r.writer.DoTx(
|
||||
ctx,
|
||||
db.StdRetryCnt,
|
||||
db.ExpBackoff{},
|
||||
func(reader db.Reader, w db.Writer) error {
|
||||
rows, err := w.Query(ctx, closeConnectionsForDeadServersCte, args)
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var result CloseConnectionsForDeadWorkersResult
|
||||
if err := w.ScanRows(ctx, rows, &result); err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
results = append(results, result)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// closeOrphanedConnections looks for connections that are still active, but where not reported by the worker.
|
||||
func (r *ConnectionRepository) closeOrphanedConnections(ctx context.Context, workerId string, reportedConnections []string) ([]string, error) {
|
||||
const op = "session.(ConnectionRepository).closeOrphanedConnections"
|
||||
|
||||
@@ -6,9 +6,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
@@ -150,9 +147,8 @@ func TestRepository_ConnectConnection(t *testing.T) {
|
||||
|
||||
setupFn := func() ConnectWith {
|
||||
s := TestDefaultSession(t, conn, wrapper, iamRepo)
|
||||
srv := TestWorker(t, conn, wrapper)
|
||||
tofu := TestTofu(t)
|
||||
_, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, srv.PrivateId, tofu)
|
||||
_, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
c := TestConnection(t, conn, s.PublicId, "127.0.0.1", 22, "127.0.0.1", 2222, "127.0.0.1")
|
||||
return ConnectWith{
|
||||
@@ -362,20 +358,20 @@ func TestRepository_orphanedConnections(t *testing.T) {
|
||||
|
||||
// Create two "workers". One will remain untouched while the other "goes
|
||||
// away and comes back" (worker 2).
|
||||
worker1 := TestWorker(t, conn, wrapper, WithWorkerId("worker1"))
|
||||
worker2 := TestWorker(t, conn, wrapper, WithWorkerId("worker2"))
|
||||
worker1 := TestWorker(t, conn, wrapper)
|
||||
worker2 := TestWorker(t, conn, wrapper)
|
||||
|
||||
// Create a few sessions on each, activate, and authorize a connection
|
||||
var connIds []string
|
||||
var worker1ConnIds []string
|
||||
var worker2ConnIds []string
|
||||
for i := 0; i < numConns; i++ {
|
||||
serverId := worker1.PrivateId
|
||||
serverId := worker1.PublicId
|
||||
if i%2 == 0 {
|
||||
serverId = worker2.PrivateId
|
||||
serverId = worker2.PublicId
|
||||
}
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithWorkerId(serverId), WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, serverId, []byte("foo"))
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, []byte("foo"))
|
||||
require.NoError(err)
|
||||
c, cs, err := connRepo.AuthorizeConnection(ctx, sess.GetPublicId(), serverId)
|
||||
require.NoError(err)
|
||||
@@ -421,7 +417,7 @@ func TestRepository_orphanedConnections(t *testing.T) {
|
||||
// all connection IDs for worker 1 should be showing as non-closed, and
|
||||
// the ones for worker 2 not advertised should be closed.
|
||||
shouldStayOpen := worker2ConnIds[0:2]
|
||||
found, err := connRepo.closeOrphanedConnections(ctx, worker2.GetPrivateId(), shouldStayOpen)
|
||||
found, err := connRepo.closeOrphanedConnections(ctx, worker2.GetPublicId(), shouldStayOpen)
|
||||
require.NoError(err)
|
||||
fmt.Printf("shouldstate: %v\nfound: %v\n", shouldStayOpen, found)
|
||||
require.Equal(4, len(found))
|
||||
@@ -435,293 +431,12 @@ func TestRepository_orphanedConnections(t *testing.T) {
|
||||
// Now, advertise none of the connection IDs for worker 2. This is mainly to
|
||||
// test that handling the case where we do not include IDs works properly as
|
||||
// it changes the where clause.
|
||||
found, err = connRepo.closeOrphanedConnections(ctx, worker1.GetPrivateId(), nil)
|
||||
found, err = connRepo.closeOrphanedConnections(ctx, worker1.GetPublicId(), nil)
|
||||
require.NoError(err)
|
||||
assert.Equal(6, len(found))
|
||||
assert.ElementsMatch(found, worker1ConnIds)
|
||||
}
|
||||
|
||||
func TestRepository_CloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
require := require.New(t)
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
deadWorkerConnCloseMinGrace := 15 * time.Second
|
||||
connRepo, err := NewConnectionRepository(ctx, rw, rw, kms)
|
||||
require.NoError(err)
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
|
||||
// connection count = 6 * states(authorized, connected, closed = 3) * servers_with_open_connections(3)
|
||||
numConns := 54
|
||||
|
||||
// Create four "workers". This is similar to the setup in
|
||||
// TestRepository_CloseDeadConnectionsOnWorker, but a bit more complex;
|
||||
// firstly, the last worker will have no connections at all, and we will be
|
||||
// closing the others in stages to test multiple servers being closed at
|
||||
// once.
|
||||
worker1 := TestWorker(t, conn, wrapper, WithWorkerId("worker1"))
|
||||
worker2 := TestWorker(t, conn, wrapper, WithWorkerId("worker2"))
|
||||
worker3 := TestWorker(t, conn, wrapper, WithWorkerId("worker3"))
|
||||
worker4 := TestWorker(t, conn, wrapper, WithWorkerId("worker4"))
|
||||
|
||||
// Create sessions on the first three, activate, and authorize connections
|
||||
var worker1ConnIds, worker2ConnIds, worker3ConnIds []string
|
||||
for i := 0; i < numConns; i++ {
|
||||
var serverId string
|
||||
if i%3 == 0 {
|
||||
serverId = worker1.PrivateId
|
||||
} else if i%3 == 1 {
|
||||
serverId = worker2.PrivateId
|
||||
} else {
|
||||
serverId = worker3.PrivateId
|
||||
}
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithWorkerId(serverId), WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, serverId, []byte("foo"))
|
||||
require.NoError(err)
|
||||
c, cs, err := connRepo.AuthorizeConnection(ctx, sess.GetPublicId(), serverId)
|
||||
require.NoError(err)
|
||||
require.Len(cs, 1)
|
||||
require.Equal(StatusAuthorized, cs[0].Status)
|
||||
if i%3 == 0 {
|
||||
worker1ConnIds = append(worker1ConnIds, c.GetPublicId())
|
||||
} else if i%3 == 1 {
|
||||
worker2ConnIds = append(worker2ConnIds, c.GetPublicId())
|
||||
} else {
|
||||
worker3ConnIds = append(worker3ConnIds, c.GetPublicId())
|
||||
}
|
||||
}
|
||||
|
||||
// Mark a third of the connections connected, a third closed, and leave the
|
||||
// others authorized. This is just to ensure we have a spread when we test it
|
||||
// out.
|
||||
for i, connId := range func() []string {
|
||||
var s []string
|
||||
s = append(s, worker1ConnIds...)
|
||||
s = append(s, worker2ConnIds...)
|
||||
s = append(s, worker3ConnIds...)
|
||||
return s
|
||||
}() {
|
||||
if i%3 == 0 {
|
||||
_, cs, err := connRepo.ConnectConnection(ctx, ConnectWith{
|
||||
ConnectionId: connId,
|
||||
ClientTcpAddress: "127.0.0.1",
|
||||
ClientTcpPort: 22,
|
||||
EndpointTcpAddress: "127.0.0.1",
|
||||
EndpointTcpPort: 22,
|
||||
UserClientIp: "127.0.0.1",
|
||||
})
|
||||
require.NoError(err)
|
||||
require.Len(cs, 2)
|
||||
var foundAuthorized, foundConnected bool
|
||||
for _, status := range cs {
|
||||
if status.Status == StatusAuthorized {
|
||||
foundAuthorized = true
|
||||
}
|
||||
if status.Status == StatusConnected {
|
||||
foundConnected = true
|
||||
}
|
||||
}
|
||||
require.True(foundAuthorized)
|
||||
require.True(foundConnected)
|
||||
} else if i%3 == 1 {
|
||||
resp, err := connRepo.closeConnections(ctx, []CloseWith{
|
||||
{
|
||||
ConnectionId: connId,
|
||||
ClosedReason: ConnectionCanceled,
|
||||
},
|
||||
})
|
||||
require.NoError(err)
|
||||
require.Len(resp, 1)
|
||||
cs := resp[0].ConnectionStates
|
||||
require.Len(cs, 2)
|
||||
var foundAuthorized, foundClosed bool
|
||||
for _, status := range cs {
|
||||
if status.Status == StatusAuthorized {
|
||||
foundAuthorized = true
|
||||
}
|
||||
if status.Status == StatusClosed {
|
||||
foundClosed = true
|
||||
}
|
||||
}
|
||||
require.True(foundAuthorized)
|
||||
require.True(foundClosed)
|
||||
}
|
||||
}
|
||||
|
||||
// updateWorker is a helper for updating the update time for our
|
||||
// servers. The controller is read back so that we can reference
|
||||
// the most up-to-date fields.
|
||||
updateWorker := func(t *testing.T, w *store.Worker) *store.Worker {
|
||||
t.Helper()
|
||||
_, rowsUpdated, err := serversRepo.UpsertWorker(ctx, w)
|
||||
require.NoError(err)
|
||||
require.Equal(1, rowsUpdated)
|
||||
servers, err := serversRepo.ListWorkers(ctx)
|
||||
require.NoError(err)
|
||||
for _, server := range servers {
|
||||
if server.PrivateId == w.PrivateId {
|
||||
return server
|
||||
}
|
||||
}
|
||||
|
||||
require.FailNowf("server %q not found after updating", w.PrivateId)
|
||||
// Looks weird but needed to build, as we fail in testify instead
|
||||
// of returning an error
|
||||
return nil
|
||||
}
|
||||
|
||||
// requireConnectionStatus is a helper expecting all connections on a worker
|
||||
// to be closed.
|
||||
requireConnectionStatus := func(t *testing.T, connIds []string, expectAllClosed bool) {
|
||||
t.Helper()
|
||||
|
||||
var conns []*Connection
|
||||
require.NoError(repo.list(ctx, &conns, "", nil))
|
||||
for i, connId := range connIds {
|
||||
var expected ConnectionStatus
|
||||
switch {
|
||||
case expectAllClosed:
|
||||
expected = StatusClosed
|
||||
|
||||
case i%3 == 0:
|
||||
expected = StatusConnected
|
||||
|
||||
case i%3 == 1:
|
||||
expected = StatusClosed
|
||||
|
||||
case i%3 == 2:
|
||||
expected = StatusAuthorized
|
||||
}
|
||||
|
||||
_, states, err := connRepo.LookupConnection(ctx, connId)
|
||||
require.NoError(err)
|
||||
require.Equal(expected, states[0].Status, "expected latest status for %q (index %d) to be %v", connId, i, expected)
|
||||
}
|
||||
}
|
||||
|
||||
// We need this helper to fix the zone on protobuf timestamps
|
||||
// versus what gets reported in the
|
||||
// CloseConnectionsForDeadWorkersResult.
|
||||
timestampPbAsUTC := func(t *testing.T, tm time.Time) time.Time {
|
||||
t.Helper()
|
||||
// utcLoc, err := time.LoadLocation("Etc/UTC")
|
||||
// require.NoError(err)
|
||||
return tm.In(time.Local)
|
||||
}
|
||||
|
||||
// Now try some scenarios.
|
||||
{
|
||||
// First, test the error/validation case.
|
||||
result, err := connRepo.CloseConnectionsForDeadWorkers(ctx, -1)
|
||||
require.Equal(err, errors.E(ctx,
|
||||
errors.WithCode(errors.InvalidParameter),
|
||||
errors.WithOp("session.(ConnectionRepository).CloseConnectionsForDeadWorkers"),
|
||||
errors.WithMsg(fmt.Sprintf("gracePeriod must be at least %s", deadWorkerConnCloseMinGrace)),
|
||||
))
|
||||
require.Nil(result)
|
||||
}
|
||||
|
||||
{
|
||||
// Now, try the basis, or where all workers are reporting in.
|
||||
worker1 = updateWorker(t, worker1)
|
||||
worker2 = updateWorker(t, worker2)
|
||||
worker3 = updateWorker(t, worker3)
|
||||
updateWorker(t, worker4) // no re-assignment here because we never reference the server again
|
||||
|
||||
result, err := connRepo.CloseConnectionsForDeadWorkers(ctx, deadWorkerConnCloseMinGrace)
|
||||
require.NoError(err)
|
||||
require.Empty(result)
|
||||
// Expect appropriate split connection state on worker1
|
||||
requireConnectionStatus(t, worker1ConnIds, false)
|
||||
// Expect appropriate split connection state on worker2
|
||||
requireConnectionStatus(t, worker2ConnIds, false)
|
||||
// Expect appropriate split connection state on worker3
|
||||
requireConnectionStatus(t, worker3ConnIds, false)
|
||||
}
|
||||
|
||||
{
|
||||
// Now try a zero case - similar to the basis, but only in that no results
|
||||
// are expected to be returned for workers with no connections, even if
|
||||
// they are dead. Here, the server with no connections is worker #4.
|
||||
time.Sleep(deadWorkerConnCloseMinGrace)
|
||||
worker1 = updateWorker(t, worker1)
|
||||
worker2 = updateWorker(t, worker2)
|
||||
worker3 = updateWorker(t, worker3)
|
||||
|
||||
result, err := connRepo.CloseConnectionsForDeadWorkers(ctx, deadWorkerConnCloseMinGrace)
|
||||
require.NoError(err)
|
||||
require.Empty(result)
|
||||
// Expect appropriate split connection state on worker1
|
||||
requireConnectionStatus(t, worker1ConnIds, false)
|
||||
// Expect appropriate split connection state on worker2
|
||||
requireConnectionStatus(t, worker2ConnIds, false)
|
||||
// Expect appropriate split connection state on worker3
|
||||
requireConnectionStatus(t, worker3ConnIds, false)
|
||||
}
|
||||
|
||||
{
|
||||
// The first induction is letting the first worker "die" by not updating it
|
||||
// too. All of its authorized and connected connections should be dead.
|
||||
time.Sleep(deadWorkerConnCloseMinGrace)
|
||||
worker2 = updateWorker(t, worker2)
|
||||
worker3 = updateWorker(t, worker3)
|
||||
|
||||
result, err := connRepo.CloseConnectionsForDeadWorkers(ctx, deadWorkerConnCloseMinGrace)
|
||||
require.NoError(err)
|
||||
// Assert that we have one result with the appropriate ID and
|
||||
// number of connections closed. Due to how things are
|
||||
require.Equal([]CloseConnectionsForDeadWorkersResult{
|
||||
{
|
||||
WorkerId: worker1.PrivateId,
|
||||
LastUpdateTime: timestampPbAsUTC(t, worker1.UpdateTime.AsTime()),
|
||||
NumberConnectionsClosed: 12, // 18 per server, with 6 closed already
|
||||
},
|
||||
}, result)
|
||||
// Expect all connections closed on worker1
|
||||
requireConnectionStatus(t, worker1ConnIds, true)
|
||||
// Expect appropriate split connection state on worker2
|
||||
requireConnectionStatus(t, worker2ConnIds, false)
|
||||
// Expect appropriate split connection state on worker3
|
||||
requireConnectionStatus(t, worker3ConnIds, false)
|
||||
}
|
||||
|
||||
{
|
||||
// The final case is having the other two workers die. After
|
||||
// this, we should have all connections closed with the
|
||||
// appropriate message from the next two servers acted on.
|
||||
time.Sleep(deadWorkerConnCloseMinGrace)
|
||||
|
||||
result, err := connRepo.CloseConnectionsForDeadWorkers(ctx, deadWorkerConnCloseMinGrace)
|
||||
require.NoError(err)
|
||||
// Assert that we have one result with the appropriate ID and number of connections closed.
|
||||
require.Equal([]CloseConnectionsForDeadWorkersResult{
|
||||
{
|
||||
WorkerId: worker2.PrivateId,
|
||||
LastUpdateTime: timestampPbAsUTC(t, worker2.UpdateTime.AsTime()),
|
||||
NumberConnectionsClosed: 12, // 18 per server, with 6 closed already
|
||||
},
|
||||
{
|
||||
WorkerId: worker3.PrivateId,
|
||||
LastUpdateTime: timestampPbAsUTC(t, worker3.UpdateTime.AsTime()),
|
||||
NumberConnectionsClosed: 12, // 18 per server, with 6 closed already
|
||||
},
|
||||
}, result)
|
||||
// Expect all connections closed on worker1
|
||||
requireConnectionStatus(t, worker1ConnIds, true)
|
||||
// Expect all connections closed on worker2
|
||||
requireConnectionStatus(t, worker2ConnIds, true)
|
||||
// Expect all connections closed on worker3
|
||||
requireConnectionStatus(t, worker3ConnIds, true)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepository_CloseConnections(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
@@ -737,9 +452,8 @@ func TestRepository_CloseConnections(t *testing.T) {
|
||||
|
||||
setupFn := func(cnt int) []CloseWith {
|
||||
s := TestDefaultSession(t, conn, wrapper, iamRepo)
|
||||
srv := TestWorker(t, conn, wrapper)
|
||||
tofu := TestTofu(t)
|
||||
s, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, srv.PrivateId, tofu)
|
||||
s, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
cw := make([]CloseWith, 0, cnt)
|
||||
for i := 0; i < cnt; i++ {
|
||||
|
||||
@@ -49,9 +49,6 @@ func (r *Repository) CreateSession(ctx context.Context, sessionWrapper wrapping.
|
||||
if newSession.ScopeId == "" {
|
||||
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing scope id")
|
||||
}
|
||||
if newSession.WorkerId != "" {
|
||||
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "worker id is not empty")
|
||||
}
|
||||
if newSession.CtTofuToken != nil {
|
||||
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "ct is not empty")
|
||||
}
|
||||
@@ -248,7 +245,7 @@ func (r *Repository) FetchAuthzProtectedEntitiesByScope(ctx context.Context, sco
|
||||
return sessionsMap, nil
|
||||
}
|
||||
|
||||
// ListSessions lists sessions. Supports the WithLimit, WithScopeId, WithSessionIds, and WithWorkerId options.
|
||||
// ListSessions lists sessions. Supports the WithLimit, WithScopeId, and WithSessionIds options.
|
||||
func (r *Repository) ListSessions(ctx context.Context, opt ...Option) ([]*Session, error) {
|
||||
const op = "session.(Repository).ListSessions"
|
||||
opts := getOpts(opt...)
|
||||
@@ -289,11 +286,6 @@ func (r *Repository) ListSessions(ctx context.Context, opt ...Option) ([]*Sessio
|
||||
where = append(where, fmt.Sprintf("s.public_id in (%s)", strings.Join(idsInClause, ",")))
|
||||
}
|
||||
|
||||
if opts.withWorkerId != "" {
|
||||
inClauseCnt += 1
|
||||
where, args = append(where, fmt.Sprintf("worker_id = @%d", inClauseCnt)), append(args, sql.Named(fmt.Sprintf("%d", inClauseCnt), opts.withWorkerId))
|
||||
}
|
||||
|
||||
var limit string
|
||||
switch {
|
||||
case opts.withLimit < 0: // any negative number signals unlimited results
|
||||
@@ -492,7 +484,7 @@ func (r *Repository) sessionAuthzSummary(ctx context.Context, sessionId string)
|
||||
// activated. States are ordered by start time descending. Returns an
|
||||
// InvalidSessionState error code if a connection cannot be made because the session
|
||||
// was canceled or terminated.
|
||||
func (r *Repository) ActivateSession(ctx context.Context, sessionId string, sessionVersion uint32, workerId string, tofuToken []byte) (*Session, []*State, error) {
|
||||
func (r *Repository) ActivateSession(ctx context.Context, sessionId string, sessionVersion uint32, tofuToken []byte) (*Session, []*State, error) {
|
||||
const op = "session.(Repository).ActivateSession"
|
||||
if sessionId == "" {
|
||||
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing session id")
|
||||
@@ -500,9 +492,6 @@ func (r *Repository) ActivateSession(ctx context.Context, sessionId string, sess
|
||||
if sessionVersion == 0 {
|
||||
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing version")
|
||||
}
|
||||
if workerId == "" {
|
||||
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing worker id")
|
||||
}
|
||||
if len(tofuToken) == 0 {
|
||||
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing tofu token")
|
||||
}
|
||||
@@ -539,7 +528,6 @@ func (r *Repository) ActivateSession(ctx context.Context, sessionId string, sess
|
||||
}
|
||||
|
||||
updatedSession.TofuToken = tofuToken
|
||||
updatedSession.WorkerId = workerId
|
||||
if err := updatedSession.encrypt(ctx, databaseWrapper); err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -210,32 +209,6 @@ func TestRepository_ListSession(t *testing.T) {
|
||||
assert.Equal(StatusActive, got[0].States[0].Status)
|
||||
assert.Equal(StatusPending, got[0].States[1].Status)
|
||||
})
|
||||
t.Run("withServerId", func(t *testing.T) {
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
db.TestDeleteWhere(t, conn, func() interface{} { i := AllocSession(); return &i }(), "1=1")
|
||||
for i := 0; i < 6; i++ {
|
||||
if i%2 == 0 {
|
||||
TestWorker(t, conn, wrapper, WithWorkerId(fmt.Sprintf("server-%d", i/2)))
|
||||
}
|
||||
_ = TestSession(t, conn, wrapper, composedOf,
|
||||
WithWorkerId(fmt.Sprintf("server-%d", i/2)),
|
||||
WithDbOpts(db.WithSkipVetForWrite(true)),
|
||||
)
|
||||
}
|
||||
got, err := repo.ListSessions(context.Background())
|
||||
require.NoError(err)
|
||||
assert.Equal(6, len(got))
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
serverId := fmt.Sprintf("server-%d", i)
|
||||
got, err = repo.ListSessions(context.Background(), WithWorkerId(serverId))
|
||||
require.NoError(err)
|
||||
assert.Equal(2, len(got))
|
||||
for _, item := range got {
|
||||
assert.Equal(serverId, item.WorkerId)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestRepository_ListSessions_Multiple_Scopes(t *testing.T) {
|
||||
@@ -574,7 +547,6 @@ func TestRepository_transitionState(t *testing.T) {
|
||||
repo, err := NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
tofu := TestTofu(t)
|
||||
srv := TestWorker(t, conn, wrapper)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -642,7 +614,7 @@ func TestRepository_transitionState(t *testing.T) {
|
||||
var ss []*State
|
||||
var err error
|
||||
if status == StatusActive {
|
||||
s, ss, err = repo.ActivateSession(context.Background(), id, version, srv.PrivateId, tofu)
|
||||
s, ss, err = repo.ActivateSession(context.Background(), id, version, tofu)
|
||||
} else {
|
||||
s, ss, err = repo.updateState(context.Background(), id, version, status)
|
||||
}
|
||||
@@ -681,9 +653,8 @@ func TestRepository_TerminateCompletedSessions(t *testing.T) {
|
||||
composedOf.ExpirationTime = ×tamp.Timestamp{Timestamp: exp}
|
||||
s := TestSession(t, conn, wrapper, composedOf)
|
||||
|
||||
srv := TestWorker(t, conn, wrapper)
|
||||
tofu := TestTofu(t)
|
||||
s, _, err = repo.ActivateSession(context.Background(), s.PublicId, s.Version, srv.PrivateId, tofu)
|
||||
s, _, err = repo.ActivateSession(context.Background(), s.PublicId, s.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
c := TestConnection(t, conn, s.PublicId, "127.0.0.1", 22, "127.0.0.1", 222, "127.0.0.1")
|
||||
if !leaveOpen {
|
||||
@@ -1227,7 +1198,6 @@ func TestRepository_ActivateSession(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
worker := TestWorker(t, conn, wrapper)
|
||||
|
||||
tofu := TestTofu(t)
|
||||
tests := []struct {
|
||||
@@ -1247,7 +1217,7 @@ func TestRepository_ActivateSession(t *testing.T) {
|
||||
name: "already-active",
|
||||
session: func() *Session {
|
||||
s := TestDefaultSession(t, conn, wrapper, iamRepo)
|
||||
activeSession, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, worker.PrivateId, tofu)
|
||||
activeSession, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
return activeSession
|
||||
}(),
|
||||
@@ -1310,7 +1280,7 @@ func TestRepository_ActivateSession(t *testing.T) {
|
||||
default:
|
||||
version = tt.session.Version
|
||||
}
|
||||
s, ss, err := repo.ActivateSession(context.Background(), id, version, worker.PrivateId, tofu)
|
||||
s, ss, err := repo.ActivateSession(context.Background(), id, version, tofu)
|
||||
if tt.wantErr {
|
||||
require.Error(err)
|
||||
assert.Truef(errors.Match(errors.T(tt.wantIsError), err), "unexpected error %s", err.Error())
|
||||
@@ -1326,17 +1296,17 @@ func TestRepository_ActivateSession(t *testing.T) {
|
||||
t.Run("already active", func(t *testing.T) {
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
session := TestDefaultSession(t, conn, wrapper, iamRepo)
|
||||
s, ss, err := repo.ActivateSession(context.Background(), session.PublicId, 1, worker.PrivateId, tofu)
|
||||
s, ss, err := repo.ActivateSession(context.Background(), session.PublicId, 1, tofu)
|
||||
require.NoError(err)
|
||||
require.NotNil(s)
|
||||
require.NotNil(ss)
|
||||
assert.Equal(2, len(ss))
|
||||
assert.Equal(StatusActive, ss[0].Status)
|
||||
|
||||
_, _, err = repo.ActivateSession(context.Background(), session.PublicId, 1, worker.PrivateId, tofu)
|
||||
_, _, err = repo.ActivateSession(context.Background(), session.PublicId, 1, tofu)
|
||||
require.Error(err)
|
||||
|
||||
_, _, err = repo.ActivateSession(context.Background(), session.PublicId, 2, worker.PrivateId, tofu)
|
||||
_, _, err = repo.ActivateSession(context.Background(), session.PublicId, 2, tofu)
|
||||
require.Error(err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ func TestService_AuthorizeConnection(t *testing.T) {
|
||||
}
|
||||
s := TestSession(t, conn, wrapper, composedOf)
|
||||
srv := TestWorker(t, conn, wrapper)
|
||||
testServer = srv.PrivateId
|
||||
testServer = srv.PublicId
|
||||
tofu := TestTofu(t)
|
||||
_, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, srv.PrivateId, tofu)
|
||||
_, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -30,9 +30,8 @@ func TestServiceCloseConnections(t *testing.T) {
|
||||
|
||||
setupFn := func(cnt int, addtlConn int) sessionAndCloseWiths {
|
||||
s := TestDefaultSession(t, conn, wrapper, iamRepo)
|
||||
srv := TestWorker(t, conn, wrapper)
|
||||
tofu := TestTofu(t)
|
||||
s, _, err = repo.ActivateSession(context.Background(), s.PublicId, s.Version, srv.PrivateId, tofu)
|
||||
s, _, err = repo.ActivateSession(context.Background(), s.PublicId, s.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -33,8 +33,8 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
serverRepo.UpsertWorker(ctx, &store.Worker{
|
||||
PrivateId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
PublicId: "test_worker1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
|
||||
repo, err := session.NewRepository(rw, rw, kms)
|
||||
@@ -91,11 +91,11 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, _, err = connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PrivateId)
|
||||
_, _, err = connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = repo.CancelSession(ctx, sess.PublicId, sess.Version)
|
||||
@@ -123,11 +123,11 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
return testCase{
|
||||
worker: worker,
|
||||
@@ -157,9 +157,9 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
_, err = repo.CancelSession(ctx, sess.PublicId, sess.Version)
|
||||
require.NoError(t, err)
|
||||
@@ -197,9 +197,9 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
_, err = repo.CancelSession(ctx, sess.PublicId, sess.Version)
|
||||
require.NoError(t, err)
|
||||
@@ -215,9 +215,9 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu2 := session.TestTofu(t)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, worker.PrivateId, tofu2)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
||||
require.NoError(t, err)
|
||||
connection2, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PrivateId)
|
||||
connection2, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
_, err = repo.CancelSession(ctx, sess2.PublicId, sess2.Version)
|
||||
require.NoError(t, err)
|
||||
@@ -264,9 +264,9 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
|
||||
sess2 := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
@@ -280,9 +280,9 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu2 := session.TestTofu(t)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, worker.PrivateId, tofu2)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
||||
require.NoError(t, err)
|
||||
connection2, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PrivateId)
|
||||
connection2, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
require.NotEqual(t, connection.PublicId, connection2.PublicId)
|
||||
|
||||
@@ -315,9 +315,9 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu := session.TestTofu(t)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, worker.PrivateId, tofu)
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.PublicId, sess.Version, tofu)
|
||||
require.NoError(t, err)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PrivateId)
|
||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
_, err = repo.CancelSession(ctx, sess.PublicId, sess.Version)
|
||||
require.NoError(t, err)
|
||||
@@ -333,11 +333,11 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
ConnectionLimit: 10,
|
||||
})
|
||||
tofu2 := session.TestTofu(t)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, worker.PrivateId, tofu2)
|
||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
||||
require.NoError(t, err)
|
||||
connection2, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PrivateId)
|
||||
connection2, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
connection3, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PrivateId)
|
||||
connection3, _, err := connRepo.AuthorizeConnection(ctx, sess2.PublicId, worker.PublicId)
|
||||
require.NoError(t, err)
|
||||
_, err = repo.CancelSession(ctx, sess2.PublicId, sess2.Version)
|
||||
require.NoError(t, err)
|
||||
@@ -378,7 +378,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
|
||||
tc := tt.caseFn(t)
|
||||
|
||||
got, err := session.WorkerStatusReport(ctx, repo, connRepo, tc.worker.PrivateId, tc.req)
|
||||
got, err := session.WorkerStatusReport(ctx, repo, connRepo, tc.worker.PublicId, tc.req)
|
||||
require.NoError(err)
|
||||
assert.ElementsMatch(tc.want, got)
|
||||
for _, dc := range tc.orphanedConnections {
|
||||
|
||||
@@ -64,8 +64,6 @@ type Session struct {
|
||||
UserId string `json:"user_id,omitempty" gorm:"default:null"`
|
||||
// HostId of the session
|
||||
HostId string `json:"host_id,omitempty" gorm:"default:null"`
|
||||
// WorkerId that proxied the session
|
||||
WorkerId string `json:"worker_id,omitempty" gorm:"default:null"`
|
||||
// TargetId for the session
|
||||
TargetId string `json:"target_id,omitempty" gorm:"default:null"`
|
||||
// HostSetId for the session
|
||||
@@ -169,7 +167,6 @@ func (s *Session) Clone() interface{} {
|
||||
PublicId: s.PublicId,
|
||||
UserId: s.UserId,
|
||||
HostId: s.HostId,
|
||||
WorkerId: s.WorkerId,
|
||||
TargetId: s.TargetId,
|
||||
HostSetId: s.HostSetId,
|
||||
AuthTokenId: s.AuthTokenId,
|
||||
@@ -334,9 +331,6 @@ func (s *Session) validateNewSession() error {
|
||||
if s.TerminationReason != "" {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "termination reason must be empty")
|
||||
}
|
||||
if s.WorkerId != "" {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "worker id must be empty")
|
||||
}
|
||||
if s.TofuToken != nil {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "tofu token must be empty")
|
||||
}
|
||||
@@ -443,7 +437,6 @@ type sessionListView struct {
|
||||
PublicId string `json:"public_id,omitempty" gorm:"primary_key"`
|
||||
UserId string `json:"user_id,omitempty" gorm:"default:null"`
|
||||
HostId string `json:"host_id,omitempty" gorm:"default:null"`
|
||||
WorkerId string `json:"worker_id,omitempty" gorm:"default:null"`
|
||||
TargetId string `json:"target_id,omitempty" gorm:"default:null"`
|
||||
HostSetId string `json:"host_set_id,omitempty" gorm:"default:null"`
|
||||
AuthTokenId string `json:"auth_token_id,omitempty" gorm:"default:null"`
|
||||
|
||||
@@ -107,7 +107,7 @@ func (j *sessionConnectionCleanupJob) Run(ctx context.Context) error {
|
||||
for _, result := range results {
|
||||
event.WriteError(ctx, op, stderrors.New("worker has not reported status within acceptable grace period, all connections closed"),
|
||||
event.WithInfo(
|
||||
"private_id", result.WorkerId,
|
||||
"public_id", result.WorkerId,
|
||||
"update_time", result.LastUpdateTime,
|
||||
"grace_period_seconds", j.gracePeriod.Seconds(),
|
||||
"number_connections_closed", result.NumberConnectionsClosed,
|
||||
@@ -116,9 +116,48 @@ func (j *sessionConnectionCleanupJob) Run(ctx context.Context) error {
|
||||
j.totalClosed += result.NumberConnectionsClosed
|
||||
}
|
||||
|
||||
{
|
||||
count, err := j.closeWorkerlessConnections(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if count > 0 {
|
||||
event.WriteError(ctx, op, stderrors.New("connections with no worker closed"),
|
||||
event.WithInfo(
|
||||
"number_connections_closed", count,
|
||||
))
|
||||
j.totalClosed += count
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// closeWorkerlessConnections will close all connections which do not have a
|
||||
// worker id associated with them.
|
||||
func (j *sessionConnectionCleanupJob) closeWorkerlessConnections(ctx context.Context) (int, error) {
|
||||
const op = "session.(sessionConnectionCleanupJob).closeWorkerlessConnections"
|
||||
count := 0
|
||||
_, err := j.writer.DoTx(
|
||||
ctx,
|
||||
db.StdRetryCnt,
|
||||
db.ExpBackoff{},
|
||||
func(reader db.Reader, w db.Writer) error {
|
||||
var err error
|
||||
count, err = w.Exec(ctx, closeWorkerlessConnections, []interface{}{})
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return count, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// closeConnectionsForDeadWorkers will run
|
||||
// closeConnectionsForDeadServersCte to look for connections that
|
||||
// should be marked because they are on a server that is no longer
|
||||
|
||||
@@ -45,19 +45,19 @@ func TestSessionConnectionCleanupJob(t *testing.T) {
|
||||
|
||||
// Create two "workers". One will remain untouched while the other "goes
|
||||
// away and comes back" (worker 2).
|
||||
worker1 := TestWorker(t, conn, wrapper, WithWorkerId("worker1"))
|
||||
worker2 := TestWorker(t, conn, wrapper, WithWorkerId("worker2"))
|
||||
worker1 := TestWorker(t, conn, wrapper)
|
||||
worker2 := TestWorker(t, conn, wrapper)
|
||||
|
||||
// Create a few sessions on each, activate, and authorize a connection
|
||||
var connIds []string
|
||||
connIdsByWorker := make(map[string][]string)
|
||||
for i := 0; i < numConns; i++ {
|
||||
serverId := worker1.PrivateId
|
||||
serverId := worker1.PublicId
|
||||
if i%2 == 0 {
|
||||
serverId = worker2.PrivateId
|
||||
serverId = worker2.PublicId
|
||||
}
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithWorkerId(serverId), WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = sessionRepo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, serverId, []byte("foo"))
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = sessionRepo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, []byte("foo"))
|
||||
require.NoError(err)
|
||||
c, cs, _, err := AuthorizeConnection(ctx, sessionRepo, connectionRepo, sess.GetPublicId(), serverId)
|
||||
require.NoError(err)
|
||||
@@ -65,9 +65,9 @@ func TestSessionConnectionCleanupJob(t *testing.T) {
|
||||
require.Equal(StatusAuthorized, cs[0].Status)
|
||||
connIds = append(connIds, c.GetPublicId())
|
||||
if i%2 == 0 {
|
||||
connIdsByWorker[worker2.PrivateId] = append(connIdsByWorker[worker2.PrivateId], c.GetPublicId())
|
||||
connIdsByWorker[worker2.PublicId] = append(connIdsByWorker[worker2.PublicId], c.GetPublicId())
|
||||
} else {
|
||||
connIdsByWorker[worker1.PrivateId] = append(connIdsByWorker[worker1.PrivateId], c.GetPublicId())
|
||||
connIdsByWorker[worker1.PublicId] = append(connIdsByWorker[worker1.PublicId], c.GetPublicId())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func TestSessionConnectionCleanupJob(t *testing.T) {
|
||||
|
||||
// Push an upsert to the first worker so that its status has been
|
||||
// updated.
|
||||
_, rowsUpdated, err := serversRepo.UpsertWorker(ctx, worker1, []servers.Option{}...)
|
||||
_, rowsUpdated, err := serversRepo.UpsertWorker(ctx, worker1)
|
||||
require.NoError(err)
|
||||
require.Equal(1, rowsUpdated)
|
||||
|
||||
@@ -136,9 +136,9 @@ func TestSessionConnectionCleanupJob(t *testing.T) {
|
||||
}
|
||||
|
||||
// Assert that all connections on the second worker are closed
|
||||
assertConnections(worker2.PrivateId, true)
|
||||
assertConnections(worker2.PublicId, true)
|
||||
// Assert that all connections on the first worker are still open
|
||||
assertConnections(worker1.PrivateId, false)
|
||||
assertConnections(worker1.PublicId, false)
|
||||
}
|
||||
|
||||
func TestSessionConnectionCleanupJobNewJobErr(t *testing.T) {
|
||||
@@ -197,24 +197,24 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
// firstly, the last worker will have no connections at all, and we will be
|
||||
// closing the others in stages to test multiple servers being closed at
|
||||
// once.
|
||||
worker1 := TestWorker(t, conn, wrapper, WithWorkerId("worker1"))
|
||||
worker2 := TestWorker(t, conn, wrapper, WithWorkerId("worker2"))
|
||||
worker3 := TestWorker(t, conn, wrapper, WithWorkerId("worker3"))
|
||||
worker4 := TestWorker(t, conn, wrapper, WithWorkerId("worker4"))
|
||||
worker1 := TestWorker(t, conn, wrapper)
|
||||
worker2 := TestWorker(t, conn, wrapper)
|
||||
worker3 := TestWorker(t, conn, wrapper)
|
||||
worker4 := TestWorker(t, conn, wrapper)
|
||||
|
||||
// Create sessions on the first three, activate, and authorize connections
|
||||
var worker1ConnIds, worker2ConnIds, worker3ConnIds []string
|
||||
for i := 0; i < numConns; i++ {
|
||||
var serverId string
|
||||
if i%3 == 0 {
|
||||
serverId = worker1.PrivateId
|
||||
serverId = worker1.PublicId
|
||||
} else if i%3 == 1 {
|
||||
serverId = worker2.PrivateId
|
||||
serverId = worker2.PublicId
|
||||
} else {
|
||||
serverId = worker3.PrivateId
|
||||
serverId = worker3.PublicId
|
||||
}
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithWorkerId(serverId), WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, serverId, []byte("foo"))
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, []byte("foo"))
|
||||
require.NoError(err)
|
||||
c, cs, err := connRepo.AuthorizeConnection(ctx, sess.GetPublicId(), serverId)
|
||||
require.NoError(err)
|
||||
@@ -297,12 +297,12 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
servers, err := serversRepo.ListWorkers(ctx)
|
||||
require.NoError(err)
|
||||
for _, server := range servers {
|
||||
if server.PrivateId == w.PrivateId {
|
||||
if server.PublicId == w.PublicId {
|
||||
return server
|
||||
}
|
||||
}
|
||||
|
||||
require.FailNowf("server %q not found after updating", w.PrivateId)
|
||||
require.FailNowf("server %q not found after updating", w.PublicId)
|
||||
// Looks weird but needed to build, as we fail in testify instead
|
||||
// of returning an error
|
||||
return nil
|
||||
@@ -399,7 +399,7 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
// number of connections closed. Due to how things are
|
||||
require.Equal([]closeConnectionsForDeadWorkersResult{
|
||||
{
|
||||
WorkerId: worker1.PrivateId,
|
||||
WorkerId: worker1.PublicId,
|
||||
LastUpdateTime: timestampPbAsUTC(t, worker1.UpdateTime.AsTime()),
|
||||
NumberConnectionsClosed: 12, // 18 per server, with 6 closed already
|
||||
},
|
||||
@@ -421,14 +421,14 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
result, err := job.closeConnectionsForDeadWorkers(ctx, gracePeriod)
|
||||
require.NoError(err)
|
||||
// Assert that we have one result with the appropriate ID and number of connections closed.
|
||||
require.Equal([]closeConnectionsForDeadWorkersResult{
|
||||
require.ElementsMatch([]closeConnectionsForDeadWorkersResult{
|
||||
{
|
||||
WorkerId: worker2.PrivateId,
|
||||
WorkerId: worker2.PublicId,
|
||||
LastUpdateTime: timestampPbAsUTC(t, worker2.UpdateTime.AsTime()),
|
||||
NumberConnectionsClosed: 12, // 18 per server, with 6 closed already
|
||||
},
|
||||
{
|
||||
WorkerId: worker3.PrivateId,
|
||||
WorkerId: worker3.PublicId,
|
||||
LastUpdateTime: timestampPbAsUTC(t, worker3.UpdateTime.AsTime()),
|
||||
NumberConnectionsClosed: 12, // 18 per server, with 6 closed already
|
||||
},
|
||||
@@ -441,3 +441,95 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
requireConnectionStatus(t, worker3ConnIds, true)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloseWorkerlessConnections(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
require := require.New(t)
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
connRepo, err := NewConnectionRepository(ctx, rw, rw, kms)
|
||||
require.NoError(err)
|
||||
|
||||
job, err := newSessionConnectionCleanupJob(rw, time.Hour)
|
||||
require.NoError(err)
|
||||
|
||||
createConnection := func(workerId string) *Connection {
|
||||
sess := TestDefaultSession(t, conn, wrapper, iamRepo, WithDbOpts(db.WithSkipVetForWrite(true)))
|
||||
sess, _, err = repo.ActivateSession(ctx, sess.GetPublicId(), sess.Version, []byte("foo"))
|
||||
require.NoError(err)
|
||||
|
||||
conn, cs, err := connRepo.AuthorizeConnection(ctx, sess.GetPublicId(), workerId)
|
||||
require.NoError(err)
|
||||
require.Len(cs, 1)
|
||||
require.Equal(StatusAuthorized, cs[0].Status)
|
||||
return conn
|
||||
}
|
||||
|
||||
// Setup deleted worker connections
|
||||
deletedWorker := TestWorker(t, conn, wrapper)
|
||||
dActiveConn := createConnection(deletedWorker.GetPublicId())
|
||||
dClosedConn := createConnection(deletedWorker.GetPublicId())
|
||||
connRepo.closeConnections(ctx, []CloseWith{{
|
||||
ConnectionId: dClosedConn.PublicId,
|
||||
BytesUp: 1,
|
||||
BytesDown: 2,
|
||||
ClosedReason: ConnectionClosedByUser,
|
||||
}})
|
||||
_, err = rw.Delete(ctx, deletedWorker)
|
||||
require.NoError(err)
|
||||
|
||||
// Non deleted worker case
|
||||
activeWorker := TestWorker(t, conn, wrapper)
|
||||
activeConn := createConnection(activeWorker.GetPublicId())
|
||||
closedConn := createConnection(activeWorker.GetPublicId())
|
||||
connRepo.closeConnections(ctx, []CloseWith{{
|
||||
ConnectionId: closedConn.PublicId,
|
||||
BytesUp: 1,
|
||||
BytesDown: 2,
|
||||
ClosedReason: ConnectionClosedByUser,
|
||||
}})
|
||||
|
||||
_, st, err := connRepo.LookupConnection(ctx, dActiveConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusAuthorized, st[0].Status)
|
||||
|
||||
_, st, err = connRepo.LookupConnection(ctx, dClosedConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusClosed, st[0].Status)
|
||||
|
||||
_, st, err = connRepo.LookupConnection(ctx, activeConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusAuthorized, st[0].Status)
|
||||
|
||||
_, st, err = connRepo.LookupConnection(ctx, closedConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusClosed, st[0].Status)
|
||||
|
||||
// Run the job
|
||||
numClosed, err := job.closeWorkerlessConnections(ctx)
|
||||
require.NoError(err)
|
||||
assert.Equal(t, 1, numClosed)
|
||||
|
||||
// This is the only one that the job should have actually closed.
|
||||
_, st, err = connRepo.LookupConnection(ctx, dActiveConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusClosed, st[0].Status)
|
||||
|
||||
_, st, err = connRepo.LookupConnection(ctx, dClosedConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusClosed, st[0].Status)
|
||||
|
||||
_, st, err = connRepo.LookupConnection(ctx, activeConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusAuthorized, st[0].Status)
|
||||
|
||||
_, st, err = connRepo.LookupConnection(ctx, closedConn.GetPublicId())
|
||||
require.NoError(err)
|
||||
require.Equal(StatusClosed, st[0].Status)
|
||||
}
|
||||
@@ -90,8 +90,6 @@ func TestSession(t testing.TB, conn *db.DB, wrapper wrapping.Wrapper, c Composed
|
||||
_, certBytes, err := newCert(ctx, wrapper, c.UserId, id, []string{"127.0.0.1", "localhost"}, c.ExpirationTime.Timestamp.AsTime())
|
||||
require.NoError(err)
|
||||
s.Certificate = certBytes
|
||||
s.WorkerId = opts.withWorkerId
|
||||
|
||||
if len(s.TofuToken) != 0 {
|
||||
err = s.encrypt(ctx, wrapper)
|
||||
}
|
||||
@@ -190,18 +188,15 @@ func TestWorker(t *testing.T, conn *db.DB, wrapper wrapping.Wrapper, opt ...Opti
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
|
||||
opts := getOpts(opt...)
|
||||
id := opts.withWorkerId
|
||||
if id == "" {
|
||||
id, err = uuid.GenerateUUID()
|
||||
require.NoError(t, err)
|
||||
id = "test-session-worker-" + id
|
||||
}
|
||||
id, err := uuid.GenerateUUID()
|
||||
require.NoError(t, err)
|
||||
id = "test_session_worker-" + id
|
||||
|
||||
name := "test-worker-" + id
|
||||
worker := &store.Worker{
|
||||
PrivateId: id,
|
||||
Name: name,
|
||||
Address: "127.0.0.1",
|
||||
PublicId: id,
|
||||
Name: name,
|
||||
Address: "127.0.0.1",
|
||||
}
|
||||
_, _, err = serversRepo.UpsertWorker(context.Background(), worker)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -66,12 +66,7 @@ func TestSessions(t *testing.T) {
|
||||
EndTime: pbNow,
|
||||
},
|
||||
},
|
||||
Status: "status",
|
||||
WorkerInfo: []*pb.WorkerInfo{
|
||||
{
|
||||
Address: "worker-address",
|
||||
},
|
||||
},
|
||||
Status: "status",
|
||||
Certificate: []byte("certificate"),
|
||||
TerminationReason: "termination_reason",
|
||||
AuthorizedActions: []string{"action-1"},
|
||||
@@ -119,12 +114,7 @@ func TestSessions(t *testing.T) {
|
||||
EndTime: pbNow,
|
||||
},
|
||||
},
|
||||
Status: "status",
|
||||
WorkerInfo: []*pb.WorkerInfo{
|
||||
{
|
||||
Address: "worker-address",
|
||||
},
|
||||
},
|
||||
Status: "status",
|
||||
Certificate: []byte("certificate"),
|
||||
TerminationReason: "termination_reason",
|
||||
AuthorizedActions: []string{"action-1"},
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestWorkerTagging(t *testing.T) {
|
||||
// Worker 1
|
||||
conf, err = config.DevWorker()
|
||||
require.NoError(t, err)
|
||||
conf.Worker.Name = "w1"
|
||||
conf.Worker.Name = "test_worker_1"
|
||||
conf.Worker.Tags = map[string][]string{
|
||||
"region": {"east"},
|
||||
"foo": {"bar"},
|
||||
@@ -64,7 +64,7 @@ func TestWorkerTagging(t *testing.T) {
|
||||
// Worker 2
|
||||
conf, err = config.DevWorker()
|
||||
require.NoError(t, err)
|
||||
conf.Worker.Name = "w2"
|
||||
conf.Worker.Name = "test_worker_2"
|
||||
conf.Worker.Tags = map[string][]string{
|
||||
"region": {"west"},
|
||||
"az": {"one", "two", "three"},
|
||||
@@ -81,7 +81,7 @@ func TestWorkerTagging(t *testing.T) {
|
||||
// Worker 3
|
||||
conf, err = config.DevWorker()
|
||||
require.NoError(t, err)
|
||||
conf.Worker.Name = "w3"
|
||||
conf.Worker.Name = "test_worker_3"
|
||||
conf.Worker.Tags = map[string][]string{
|
||||
"region": {"west"},
|
||||
"az": {"one", "three"},
|
||||
@@ -109,12 +109,12 @@ func TestWorkerTagging(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "name and region",
|
||||
filter: `"/name" matches "w[13]" and "west" in "/tags/region"`,
|
||||
filter: `"/name" matches "test_worker_[13]" and "west" in "/tags/region"`,
|
||||
expWorkers: []string{w3Addr},
|
||||
},
|
||||
{
|
||||
name: "name and az",
|
||||
filter: `"/name" matches "w[23]" and "three" in "/tags/az"`,
|
||||
filter: `"/name" matches "test_worker_[23]" and "three" in "/tags/az"`,
|
||||
expWorkers: []string{w2Addr, w3Addr},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ func NewTestSession(
|
||||
) *TestSession {
|
||||
t.Helper()
|
||||
require := require.New(t)
|
||||
sar, err := tcl.AuthorizeSession(ctx, "ttcp_1234567890")
|
||||
sar, err := tcl.AuthorizeSession(ctx, targetId)
|
||||
require.NoError(err)
|
||||
require.NotNil(sar)
|
||||
|
||||
|
||||
@@ -22,54 +22,6 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type WorkerInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// The address of the worker.
|
||||
Address string `protobuf:"bytes,10,opt,name=address,proto3" json:"address,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
}
|
||||
|
||||
func (x *WorkerInfo) Reset() {
|
||||
*x = WorkerInfo{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *WorkerInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*WorkerInfo) ProtoMessage() {}
|
||||
|
||||
func (x *WorkerInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use WorkerInfo.ProtoReflect.Descriptor instead.
|
||||
func (*WorkerInfo) Descriptor() ([]byte, []int) {
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *WorkerInfo) GetAddress() string {
|
||||
if x != nil {
|
||||
return x.Address
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SessionState struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -86,7 +38,7 @@ type SessionState struct {
|
||||
func (x *SessionState) Reset() {
|
||||
*x = SessionState{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[1]
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -99,7 +51,7 @@ func (x *SessionState) String() string {
|
||||
func (*SessionState) ProtoMessage() {}
|
||||
|
||||
func (x *SessionState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[1]
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -112,7 +64,7 @@ func (x *SessionState) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SessionState.ProtoReflect.Descriptor instead.
|
||||
func (*SessionState) Descriptor() ([]byte, []int) {
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP(), []int{1}
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *SessionState) GetStatus() string {
|
||||
@@ -161,7 +113,7 @@ type Connection struct {
|
||||
func (x *Connection) Reset() {
|
||||
*x = Connection{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[2]
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -174,7 +126,7 @@ func (x *Connection) String() string {
|
||||
func (*Connection) ProtoMessage() {}
|
||||
|
||||
func (x *Connection) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[2]
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -187,7 +139,7 @@ func (x *Connection) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Connection.ProtoReflect.Descriptor instead.
|
||||
func (*Connection) Descriptor() ([]byte, []int) {
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP(), []int{2}
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Connection) GetClientTcpAddress() string {
|
||||
@@ -277,8 +229,6 @@ type Session struct {
|
||||
States []*SessionState `protobuf:"bytes,170,rep,name=states,proto3" json:"states,omitempty"`
|
||||
// Output only. The current status of this Session.
|
||||
Status string `protobuf:"bytes,180,opt,name=status,proto3" json:"status,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Output only. Worker information given to the client.
|
||||
WorkerInfo []*WorkerInfo `protobuf:"bytes,190,rep,name=worker_info,proto3" json:"worker_info,omitempty"`
|
||||
// Output only. The certificate generated for the session. Raw DER bytes.
|
||||
Certificate []byte `protobuf:"bytes,200,opt,name=certificate,proto3" json:"certificate,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Output only. If the session is terminated, this provides a short description as to why.
|
||||
@@ -292,7 +242,7 @@ type Session struct {
|
||||
func (x *Session) Reset() {
|
||||
*x = Session{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[3]
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -305,7 +255,7 @@ func (x *Session) String() string {
|
||||
func (*Session) ProtoMessage() {}
|
||||
|
||||
func (x *Session) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[3]
|
||||
mi := &file_controller_api_resources_sessions_v1_session_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -318,7 +268,7 @@ func (x *Session) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Session.ProtoReflect.Descriptor instead.
|
||||
func (*Session) Descriptor() ([]byte, []int) {
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP(), []int{3}
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Session) GetId() string {
|
||||
@@ -433,13 +383,6 @@ func (x *Session) GetStatus() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Session) GetWorkerInfo() []*WorkerInfo {
|
||||
if x != nil {
|
||||
return x.WorkerInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Session) GetCertificate() []byte {
|
||||
if x != nil {
|
||||
return x.Certificate
|
||||
@@ -481,98 +424,91 @@ var file_controller_api_resources_sessions_v1_session_proto_rawDesc = []byte{
|
||||
0x72, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x73,
|
||||
0x63, 0x6f, 0x70, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x26, 0x0a, 0x0a, 0x57,
|
||||
0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64,
|
||||
0x72, 0x65, 0x73, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72,
|
||||
0x65, 0x73, 0x73, 0x22, 0x9a, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53,
|
||||
0x74, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3a, 0x0a, 0x0a,
|
||||
0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x73, 0x74,
|
||||
0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d,
|
||||
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x22, 0x9f, 0x02, 0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12,
|
||||
0x2c, 0x0a, 0x12, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x61, 0x64,
|
||||
0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6c, 0x69,
|
||||
0x65, 0x6e, 0x74, 0x54, 0x63, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x26, 0x0a,
|
||||
0x0f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x70, 0x6f, 0x72, 0x74,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x63,
|
||||
0x70, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x30, 0x0a, 0x14, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e,
|
||||
0x74, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x12, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x63, 0x70,
|
||||
0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x65, 0x6e, 0x64, 0x70, 0x6f,
|
||||
0x69, 0x6e, 0x74, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01,
|
||||
0x28, 0x0d, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x63, 0x70, 0x50,
|
||||
0x6f, 0x72, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x75, 0x70, 0x18,
|
||||
0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, 0x79, 0x74, 0x65, 0x73, 0x55, 0x70, 0x12, 0x1d,
|
||||
0x0a, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x18, 0x08, 0x20, 0x01,
|
||||
0x28, 0x04, 0x52, 0x09, 0x62, 0x79, 0x74, 0x65, 0x73, 0x44, 0x6f, 0x77, 0x6e, 0x12, 0x23, 0x0a,
|
||||
0x0d, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x09,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73,
|
||||
0x6f, 0x6e, 0x22, 0xbd, 0x07, 0x0a, 0x07, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x43, 0x0a, 0x05,
|
||||
0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73,
|
||||
0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31,
|
||||
0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70,
|
||||
0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x18, 0x3c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,
|
||||
0x61, 0x6d, 0x70, 0x52, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x18, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,
|
||||
0x61, 0x6d, 0x70, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x50, 0x20, 0x01,
|
||||
0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x18, 0x5a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
|
||||
0x44, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9a, 0x01, 0x0a, 0x0c,
|
||||
0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x52, 0x0f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x74, 0x6f,
|
||||
0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x6e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x75,
|
||||
0x74, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x75,
|
||||
0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x78, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73,
|
||||
0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0b, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65,
|
||||
0x74, 0x5f, 0x69, 0x64, 0x18, 0x82, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x68, 0x6f, 0x73,
|
||||
0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x07, 0x68, 0x6f, 0x73, 0x74,
|
||||
0x5f, 0x69, 0x64, 0x18, 0x8c, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x68, 0x6f, 0x73, 0x74,
|
||||
0x5f, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18,
|
||||
0x96, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64,
|
||||
0x12, 0x1b, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xa0, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x4b, 0x0a,
|
||||
0x06, 0x73, 0x74, 0x61, 0x74, 0x65, 0x73, 0x18, 0xaa, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32,
|
||||
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x65, 0x73, 0x12, 0x17, 0x0a, 0x06, 0x73, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x18, 0xb4, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x12, 0x53, 0x0a, 0x0b, 0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x5f, 0x69, 0x6e,
|
||||
0x66, 0x6f, 0x18, 0xbe, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75,
|
||||
0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31,
|
||||
0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x77, 0x6f, 0x72,
|
||||
0x6b, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74,
|
||||
0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b,
|
||||
0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x0a, 0x12, 0x74,
|
||||
0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f,
|
||||
0x6e, 0x18, 0xd2, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x12,
|
||||
0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x18, 0xac, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x61, 0x75, 0x74, 0x68, 0x6f,
|
||||
0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x53, 0x0a,
|
||||
0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb6, 0x02, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x12, 0x36, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x1e, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08,
|
||||
0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x9f, 0x02, 0x0a, 0x0a, 0x43, 0x6f, 0x6e,
|
||||
0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x12, 0x63, 0x6c, 0x69, 0x65, 0x6e,
|
||||
0x74, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x63, 0x70, 0x41, 0x64,
|
||||
0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f,
|
||||
0x74, 0x63, 0x70, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d,
|
||||
0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x63, 0x70, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x30, 0x0a,
|
||||
0x14, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x61, 0x64,
|
||||
0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x65, 0x6e, 0x64,
|
||||
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x63, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12,
|
||||
0x2a, 0x0a, 0x11, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x74, 0x63, 0x70, 0x5f,
|
||||
0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70,
|
||||
0x6f, 0x69, 0x6e, 0x74, 0x54, 0x63, 0x70, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62,
|
||||
0x79, 0x74, 0x65, 0x73, 0x5f, 0x75, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62,
|
||||
0x79, 0x74, 0x65, 0x73, 0x55, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f,
|
||||
0x64, 0x6f, 0x77, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x62, 0x79, 0x74, 0x65,
|
||||
0x73, 0x44, 0x6f, 0x77, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x5f,
|
||||
0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c,
|
||||
0x6f, 0x73, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0xf5, 0x06, 0x0a, 0x07, 0x53,
|
||||
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
|
||||
0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65,
|
||||
0x74, 0x5f, 0x69, 0x64, 0x12, 0x43, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x1e, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73,
|
||||
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65,
|
||||
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x42, 0x52, 0x5a, 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x6e,
|
||||
0x66, 0x6f, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x63, 0x72, 0x65,
|
||||
0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x3c, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x63, 0x72, 0x65,
|
||||
0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x75, 0x70, 0x64,
|
||||
0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x75, 0x70, 0x64,
|
||||
0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x18, 0x50, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x5a, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x44, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x69, 0x72,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0f, 0x65, 0x78,
|
||||
0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x24, 0x0a,
|
||||
0x0d, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x6e,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
|
||||
0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x78,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x21, 0x0a,
|
||||
0x0b, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x82, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0b, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64,
|
||||
0x12, 0x19, 0x0a, 0x07, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x8c, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x07, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x08, 0x73,
|
||||
0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x96, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70,
|
||||
0x6f, 0x69, 0x6e, 0x74, 0x18, 0xa0, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64,
|
||||
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x4b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x65, 0x73, 0x18,
|
||||
0xaa, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||
0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
|
||||
0x73, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74,
|
||||
0x65, 0x73, 0x12, 0x17, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0xb4, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, 0x0b, 0x63,
|
||||
0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2f,
|
||||
0x0a, 0x12, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65,
|
||||
0x61, 0x73, 0x6f, 0x6e, 0x18, 0xd2, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x74, 0x65, 0x72,
|
||||
0x6d, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12,
|
||||
0x2f, 0x0a, 0x12, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x61, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xac, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x61, 0x75,
|
||||
0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x12, 0x53, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18,
|
||||
0xb6, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||
0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
|
||||
0x73, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x0b, 0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x5f, 0x69, 0x6e,
|
||||
0x66, 0x6f, 0x42, 0x52, 0x5a, 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x61, 0x72, 0x79, 0x2f, 0x73, 0x64, 0x6b, 0x2f, 0x70, 0x62, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75,
|
||||
@@ -592,30 +528,28 @@ func file_controller_api_resources_sessions_v1_session_proto_rawDescGZIP() []byt
|
||||
return file_controller_api_resources_sessions_v1_session_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_controller_api_resources_sessions_v1_session_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_controller_api_resources_sessions_v1_session_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_controller_api_resources_sessions_v1_session_proto_goTypes = []interface{}{
|
||||
(*WorkerInfo)(nil), // 0: controller.api.resources.sessions.v1.WorkerInfo
|
||||
(*SessionState)(nil), // 1: controller.api.resources.sessions.v1.SessionState
|
||||
(*Connection)(nil), // 2: controller.api.resources.sessions.v1.Connection
|
||||
(*Session)(nil), // 3: controller.api.resources.sessions.v1.Session
|
||||
(*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp
|
||||
(*scopes.ScopeInfo)(nil), // 5: controller.api.resources.scopes.v1.ScopeInfo
|
||||
(*SessionState)(nil), // 0: controller.api.resources.sessions.v1.SessionState
|
||||
(*Connection)(nil), // 1: controller.api.resources.sessions.v1.Connection
|
||||
(*Session)(nil), // 2: controller.api.resources.sessions.v1.Session
|
||||
(*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp
|
||||
(*scopes.ScopeInfo)(nil), // 4: controller.api.resources.scopes.v1.ScopeInfo
|
||||
}
|
||||
var file_controller_api_resources_sessions_v1_session_proto_depIdxs = []int32{
|
||||
4, // 0: controller.api.resources.sessions.v1.SessionState.start_time:type_name -> google.protobuf.Timestamp
|
||||
4, // 1: controller.api.resources.sessions.v1.SessionState.end_time:type_name -> google.protobuf.Timestamp
|
||||
5, // 2: controller.api.resources.sessions.v1.Session.scope:type_name -> controller.api.resources.scopes.v1.ScopeInfo
|
||||
4, // 3: controller.api.resources.sessions.v1.Session.created_time:type_name -> google.protobuf.Timestamp
|
||||
4, // 4: controller.api.resources.sessions.v1.Session.updated_time:type_name -> google.protobuf.Timestamp
|
||||
4, // 5: controller.api.resources.sessions.v1.Session.expiration_time:type_name -> google.protobuf.Timestamp
|
||||
1, // 6: controller.api.resources.sessions.v1.Session.states:type_name -> controller.api.resources.sessions.v1.SessionState
|
||||
0, // 7: controller.api.resources.sessions.v1.Session.worker_info:type_name -> controller.api.resources.sessions.v1.WorkerInfo
|
||||
2, // 8: controller.api.resources.sessions.v1.Session.connections:type_name -> controller.api.resources.sessions.v1.Connection
|
||||
9, // [9:9] is the sub-list for method output_type
|
||||
9, // [9:9] is the sub-list for method input_type
|
||||
9, // [9:9] is the sub-list for extension type_name
|
||||
9, // [9:9] is the sub-list for extension extendee
|
||||
0, // [0:9] is the sub-list for field type_name
|
||||
3, // 0: controller.api.resources.sessions.v1.SessionState.start_time:type_name -> google.protobuf.Timestamp
|
||||
3, // 1: controller.api.resources.sessions.v1.SessionState.end_time:type_name -> google.protobuf.Timestamp
|
||||
4, // 2: controller.api.resources.sessions.v1.Session.scope:type_name -> controller.api.resources.scopes.v1.ScopeInfo
|
||||
3, // 3: controller.api.resources.sessions.v1.Session.created_time:type_name -> google.protobuf.Timestamp
|
||||
3, // 4: controller.api.resources.sessions.v1.Session.updated_time:type_name -> google.protobuf.Timestamp
|
||||
3, // 5: controller.api.resources.sessions.v1.Session.expiration_time:type_name -> google.protobuf.Timestamp
|
||||
0, // 6: controller.api.resources.sessions.v1.Session.states:type_name -> controller.api.resources.sessions.v1.SessionState
|
||||
1, // 7: controller.api.resources.sessions.v1.Session.connections:type_name -> controller.api.resources.sessions.v1.Connection
|
||||
8, // [8:8] is the sub-list for method output_type
|
||||
8, // [8:8] is the sub-list for method input_type
|
||||
8, // [8:8] is the sub-list for extension type_name
|
||||
8, // [8:8] is the sub-list for extension extendee
|
||||
0, // [0:8] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_controller_api_resources_sessions_v1_session_proto_init() }
|
||||
@@ -625,18 +559,6 @@ func file_controller_api_resources_sessions_v1_session_proto_init() {
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_controller_api_resources_sessions_v1_session_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*WorkerInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_controller_api_resources_sessions_v1_session_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SessionState); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -648,7 +570,7 @@ func file_controller_api_resources_sessions_v1_session_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_controller_api_resources_sessions_v1_session_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_controller_api_resources_sessions_v1_session_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Connection); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -660,7 +582,7 @@ func file_controller_api_resources_sessions_v1_session_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_controller_api_resources_sessions_v1_session_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_controller_api_resources_sessions_v1_session_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Session); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -679,7 +601,7 @@ func file_controller_api_resources_sessions_v1_session_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_controller_api_resources_sessions_v1_session_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@@ -133,8 +133,8 @@ func TestGenerateSessionBenchmarkTemplateDumps(t *testing.T) {
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
worker := &store.Worker{
|
||||
PrivateId: "test1",
|
||||
Address: "127.0.0.1",
|
||||
PublicId: "test_worker_1",
|
||||
Address: "127.0.0.1",
|
||||
}
|
||||
_, _, err = serversRepo.UpsertWorker(ctx, worker)
|
||||
require.NoError(err)
|
||||
@@ -221,7 +221,7 @@ func TestGenerateSessionBenchmarkTemplateDumps(t *testing.T) {
|
||||
}
|
||||
|
||||
func cycleSessionStates(t testing.TB, ctx context.Context, sess *session.Session, sessRepo *session.Repository, connRepo *session.ConnectionRepository, conn *db.DB, worker *store.Worker, numConns int) {
|
||||
sess, _, err := sessRepo.ActivateSession(ctx, sess.PublicId, sess.Version, worker.PrivateId, []byte(`tofu`))
|
||||
sess, _, err := sessRepo.ActivateSession(ctx, sess.PublicId, sess.Version, []byte(`tofu`))
|
||||
require.NoError(t, err)
|
||||
var closeWiths []session.CloseWith
|
||||
for i := 0; i < numConns; i++ {
|
||||
|
||||
Reference in new issue
Block a user