Merge pull request #2102 from hashicorp/irindos-move-worker-apis
refact(api): move worker handlers
This commit is contained in:
8 files changed
+21
-21
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package workers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package workers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
+5
-5
@@ -1,4 +1,4 @@
|
|||||||
package workers_test
|
package handlers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/hashicorp/boundary/internal/authtoken"
|
"github.com/hashicorp/boundary/internal/authtoken"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/workers"
|
"github.com/hashicorp/boundary/internal/daemon/cluster/handlers"
|
||||||
"github.com/hashicorp/boundary/internal/db"
|
"github.com/hashicorp/boundary/internal/db"
|
||||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||||
"github.com/hashicorp/boundary/internal/host/static"
|
"github.com/hashicorp/boundary/internal/host/static"
|
||||||
@@ -85,7 +85,7 @@ func TestStatus(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
s := handlers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
||||||
require.NotNil(t, s)
|
require.NotNil(t, s)
|
||||||
|
|
||||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
||||||
@@ -264,7 +264,7 @@ func TestStatusSessionClosed(t *testing.T) {
|
|||||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
s := handlers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
||||||
require.NotNil(t, s)
|
require.NotNil(t, s)
|
||||||
|
|
||||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
||||||
@@ -445,7 +445,7 @@ func TestStatusDeadConnection(t *testing.T) {
|
|||||||
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
sess2, _, err = repo.ActivateSession(ctx, sess2.PublicId, sess2.Version, tofu2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
s := handlers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connRepoFn, new(sync.Map), kms)
|
||||||
require.NotNil(t, s)
|
require.NotNil(t, s)
|
||||||
|
|
||||||
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
connection, _, err := connRepo.AuthorizeConnection(ctx, sess.PublicId, worker1.PublicId)
|
||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package workers_test
|
package handlers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/hashicorp/boundary/internal/authtoken"
|
"github.com/hashicorp/boundary/internal/authtoken"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/workers"
|
"github.com/hashicorp/boundary/internal/daemon/cluster/handlers"
|
||||||
"github.com/hashicorp/boundary/internal/db"
|
"github.com/hashicorp/boundary/internal/db"
|
||||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||||
"github.com/hashicorp/boundary/internal/host/static"
|
"github.com/hashicorp/boundary/internal/host/static"
|
||||||
@@ -100,7 +100,7 @@ func TestLookupSession(t *testing.T) {
|
|||||||
err = repo.AddSessionCredentials(ctx, egressSess.ScopeId, egressSess.GetPublicId(), workerCreds)
|
err = repo.AddSessionCredentials(ctx, egressSess.ScopeId, egressSess.GetPublicId(), workerCreds)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, new(sync.Map), kms)
|
s := handlers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, new(sync.Map), kms)
|
||||||
require.NotNil(t, s)
|
require.NotNil(t, s)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
@@ -16,11 +16,11 @@ import (
|
|||||||
"github.com/hashicorp/boundary/internal/authtoken"
|
"github.com/hashicorp/boundary/internal/authtoken"
|
||||||
"github.com/hashicorp/boundary/internal/credential"
|
"github.com/hashicorp/boundary/internal/credential"
|
||||||
"github.com/hashicorp/boundary/internal/credential/vault"
|
"github.com/hashicorp/boundary/internal/credential/vault"
|
||||||
|
cluster "github.com/hashicorp/boundary/internal/daemon/cluster/handlers"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/credentiallibraries"
|
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/credentiallibraries"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets"
|
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/workers"
|
|
||||||
"github.com/hashicorp/boundary/internal/db"
|
"github.com/hashicorp/boundary/internal/db"
|
||||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||||
authpb "github.com/hashicorp/boundary/internal/gen/controller/auth"
|
authpb "github.com/hashicorp/boundary/internal/gen/controller/auth"
|
||||||
@@ -2787,7 +2787,7 @@ func TestAuthorizeSession(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Tell our DB that there is a worker ready to serve the data
|
// Tell our DB that there is a worker ready to serve the data
|
||||||
workerService := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
workerService := cluster.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
||||||
_, err = workerService.Status(ctx, &spbs.StatusRequest{
|
_, err = workerService.Status(ctx, &spbs.StatusRequest{
|
||||||
Worker: &spb.Server{
|
Worker: &spb.Server{
|
||||||
PrivateId: "w_1234567890",
|
PrivateId: "w_1234567890",
|
||||||
@@ -3075,7 +3075,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Tell our DB that there is a worker ready to serve the data
|
// Tell our DB that there is a worker ready to serve the data
|
||||||
workerService := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
workerService := cluster.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
||||||
_, err = workerService.Status(ctx, &spbs.StatusRequest{
|
_, err = workerService.Status(ctx, &spbs.StatusRequest{
|
||||||
Worker: &spb.Server{
|
Worker: &spb.Server{
|
||||||
PrivateId: "w_1234567890",
|
PrivateId: "w_1234567890",
|
||||||
@@ -3206,7 +3206,7 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
|||||||
store := vault.TestCredentialStore(t, conn, wrapper, proj.GetPublicId(), v.Addr, tok, sec.Auth.Accessor)
|
store := vault.TestCredentialStore(t, conn, wrapper, proj.GetPublicId(), v.Addr, tok, sec.Auth.Accessor)
|
||||||
|
|
||||||
workerExists := func(tar target.Target) (version uint32) {
|
workerExists := func(tar target.Target) (version uint32) {
|
||||||
workerService := workers.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
workerService := cluster.NewWorkerServiceServer(serversRepoFn, sessionRepoFn, connectionRepoFn, &sync.Map{}, kms)
|
||||||
_, err := workerService.Status(context.Background(), &spbs.StatusRequest{
|
_, err := workerService.Status(context.Background(), &spbs.StatusRequest{
|
||||||
Worker: &spb.Server{
|
Worker: &spb.Server{
|
||||||
PrivateId: "w_1234567890",
|
PrivateId: "w_1234567890",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
||||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/workers"
|
"github.com/hashicorp/boundary/internal/daemon/cluster/handlers"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/internal/metric"
|
"github.com/hashicorp/boundary/internal/daemon/controller/internal/metric"
|
||||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
@@ -140,12 +140,12 @@ func (c *Controller) configureForCluster(ln *base.ServerListener) (func(), error
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
workerService := workers.NewWorkerServiceServer(c.ServersRepoFn, c.SessionRepoFn, c.ConnectionRepoFn,
|
workerService := handlers.NewWorkerServiceServer(c.ServersRepoFn, c.SessionRepoFn, c.ConnectionRepoFn,
|
||||||
c.workerStatusUpdateTimes, c.kms)
|
c.workerStatusUpdateTimes, c.kms)
|
||||||
pbs.RegisterServerCoordinationServiceServer(workerServer, workerService)
|
pbs.RegisterServerCoordinationServiceServer(workerServer, workerService)
|
||||||
pbs.RegisterSessionServiceServer(workerServer, workerService)
|
pbs.RegisterSessionServiceServer(workerServer, workerService)
|
||||||
|
|
||||||
multihopService := workers.NewMultihopServiceServer(
|
multihopService := handlers.NewMultihopServiceServer(
|
||||||
nodeauth.MakeCurrentParametersFactory(c.baseContext, nodee.NopTransactionStorage(c.NodeeFileStorage)),
|
nodeauth.MakeCurrentParametersFactory(c.baseContext, nodee.NopTransactionStorage(c.NodeeFileStorage)),
|
||||||
)
|
)
|
||||||
multihop.RegisterMultihopServiceServer(workerServer, multihopService)
|
multihop.RegisterMultihopServiceServer(workerServer, multihopService)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/workers"
|
"github.com/hashicorp/boundary/internal/daemon/cluster/handlers"
|
||||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||||
"github.com/hashicorp/boundary/internal/observability/event"
|
"github.com/hashicorp/boundary/internal/observability/event"
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
@@ -136,11 +136,11 @@ func (w *Worker) configureForWorker(ln *base.ServerListener, logger *log.Logger)
|
|||||||
grpc.MaxRecvMsgSize(math.MaxInt32),
|
grpc.MaxRecvMsgSize(math.MaxInt32),
|
||||||
grpc.MaxSendMsgSize(math.MaxInt32),
|
grpc.MaxSendMsgSize(math.MaxInt32),
|
||||||
)
|
)
|
||||||
multihopService := workers.NewMultihopServiceServer(
|
multihopService := handlers.NewMultihopServiceServer(
|
||||||
nodeauth.MakeCurrentParametersFactory(w.baseContext, nodee.NopTransactionStorage(w.NodeeFileStorage)),
|
nodeauth.MakeCurrentParametersFactory(w.baseContext, nodee.NopTransactionStorage(w.NodeeFileStorage)),
|
||||||
)
|
)
|
||||||
multihop.RegisterMultihopServiceServer(downstreamServer, multihopService)
|
multihop.RegisterMultihopServiceServer(downstreamServer, multihopService)
|
||||||
statusSessionService := workers.NewWorkerProxyServiceServer(w.controllerStatusConn, w.controllerSessionConn)
|
statusSessionService := NewWorkerProxyServiceServer(w.controllerStatusConn, w.controllerSessionConn)
|
||||||
pbs.RegisterServerCoordinationServiceServer(downstreamServer, statusSessionService)
|
pbs.RegisterServerCoordinationServiceServer(downstreamServer, statusSessionService)
|
||||||
pbs.RegisterSessionServiceServer(downstreamServer, statusSessionService)
|
pbs.RegisterSessionServiceServer(downstreamServer, statusSessionService)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package workers
|
package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
Reference in new issue
Block a user