revert merge llb-multihop-sessions (#2628)

This commit is contained in:
Irena Rindos authored and GitHub committed 2022-11-17 14:51:29 -05:00
1 parent edd323b73a
commit 70e20b5cf5
10 files changed
+34 -58

No files matched your search

+4 -4
View File
@@ -16,9 +16,9 @@ func noopAddressReceivers(context.Context, *Worker) ([]addressReceiver, error) {
type receiverType uint
const (
UnknownReceiverType receiverType = iota
grpcResolverReceiverType
secondaryConnectionReceiverType
UnknownReceiverType receiverType = 0
grpcResolverReceiverType receiverType = 1
dialingListenerReceiverType receiverType = 2
)
// String returns a string representation of the receiverType
@@ -26,7 +26,7 @@ func (s receiverType) String() string {
return [...]string{
"unknown",
"grpcResolver",
"secondaryConnections",
"dialingListener",
}[s]
}
@@ -33,7 +33,6 @@ import (
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/resolver"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
)
const hcpbUrlSuffix = ".proxy.boundary.hashicorp.cloud:9202"
@@ -78,14 +77,8 @@ func (w *Worker) StartControllerConnections() error {
return nil
}
// upstreamDialerFunc dials an upstream server. extraAlpnProtos can be provided
// to kms and pki connections and are used for identifying, on the server side,
// the intended purpose of the connection. upstreamDialerFunc takes an optional
// state struct which, if the connection is made using the node enrolment
// library, sends the state to the server and can be retrieved from the
// resulting protocol.Conn.
func (w *Worker) upstreamDialerFunc(state *structpb.Struct, extraAlpnProtos ...string) func(context.Context, string) (net.Conn, error) {
const op = "worker.(Worker).upstreamDialerFunc"
func (w *Worker) controllerDialerFunc(extraAlpnProtos ...string) func(context.Context, string) (net.Conn, error) {
const op = "worker.(Worker).controllerDialerFunc"
return func(ctx context.Context, addr string) (net.Conn, error) {
var conn net.Conn
var err error
@@ -97,7 +90,6 @@ func (w *Worker) upstreamDialerFunc(state *structpb.Struct, extraAlpnProtos ...s
ctx,
w.WorkerAuthStorage,
addr,
nodeenrollment.WithState(state),
nodeenrollment.WithWrapper(w.conf.WorkerAuthStorageKms),
nodeenrollment.WithExtraAlpnProtos(extraAlpnProtos),
// If the activation token hasn't been populated, this won't do
@@ -210,7 +202,7 @@ func (w *Worker) createClientConn(addr string) error {
grpc.WithUnaryInterceptor(metric.InstrumentClusterClient()),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(math.MaxInt32)),
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(math.MaxInt32)),
grpc.WithContextDialer(w.upstreamDialerFunc(nil)),
grpc.WithContextDialer(w.controllerDialerFunc()),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(defServiceConfig),
// Don't have the resolver reach out for a service config from the
+5 -15
View File
@@ -32,12 +32,9 @@ import (
// the function that handles a secondary connection over a provided listener
var handleSecondaryConnection = closeListener
func closeListener(_ context.Context, l, l2 net.Listener, _ any) error {
func closeListener(_ context.Context, l net.Listener, _ any, _ int) error {
if l != nil {
l.Close()
}
if l2 != nil {
l2.Close()
return l.Close()
}
return nil
}
@@ -171,16 +168,9 @@ func (w *Worker) configureForWorker(ln *base.ServerListener, logger *log.Logger,
// Connections coming in here are authed by nodeenrollment and are for the
// reverse grpc purpose
reverseGrpcListener, err := w.workerAuthSplitListener.GetListener(common.ReverseGrpcConnectionAlpnValue, nodee.WithNativeConns(true))
reverseGrpcListener, err := w.workerAuthSplitListener.GetListener(common.ReverseGrpcConnectionAlpnValue)
if err != nil {
return nil, fmt.Errorf("error instantiating reverse grpc split listener: %w", err)
}
// Connections coming in here are authed by nodeenrollment and are for the
// multi-hop session-proxying
websocketProxyingListener, err := w.workerAuthSplitListener.GetListener(common.WebsocketProxyingAlpnValue, nodee.WithNativeConns(true))
if err != nil {
return nil, fmt.Errorf("error instantiating websocket proxying split listener: %w", err)
return nil, fmt.Errorf("error instantiating non-worker split listener: %w", err)
}
// This wraps the reverse grpc pki worker connections with a listener which
@@ -223,10 +213,10 @@ func (w *Worker) configureForWorker(ln *base.ServerListener, logger *log.Logger,
}
return func() {
handleSecondaryConnection(cancelCtx, revPkiWorkerTrackingListener, websocketProxyingListener, w.downstreamRoutes)
go w.workerAuthSplitListener.Start()
go httpServer.Serve(proxyListener)
go ln.GrpcServer.Serve(pkiWorkerTrackingListener)
go handleSecondaryConnection(cancelCtx, revPkiWorkerTrackingListener, w.downstreamRoutes, -1)
}, nil
}
+4 -4
View File
@@ -20,7 +20,7 @@ import (
var firstStatusCheckPostHooks []func(context.Context, *Worker) error
var downstreamWorkersFactory func(ctx context.Context, workerId string, ver string) (downstreamers, error)
var downstreamWorkersFactory func(ctx context.Context, workerId string) (downstreamers, error)
type LastStatusInformation struct {
*pbs.StatusResponse
@@ -261,10 +261,10 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context, sessionManager sess
}
// regardless of whether or not it's a new address, we need to set
// them for secondaryConnections
// them for dialingListeners
for _, as := range *addressReceivers {
switch {
case as.Type() == secondaryConnectionReceiverType:
case as.Type() == dialingListenerReceiverType:
tmpAddrs := make([]string, len(addrs))
copy(tmpAddrs, addrs)
if len(tmpAddrs) == 0 {
@@ -308,7 +308,7 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context, sessionManager sess
// If we have post hooks for after the first status check, run them now
if w.everAuthenticated.CAS(authenticationStatusFirstAuthentication, authenticationStatusFirstStatusRpcSuccessful) {
if downstreamWorkersFactory != nil {
w.downstreamWorkers, err = downstreamWorkersFactory(cancelCtx, w.LastStatusSuccess().WorkerId, versionInfo.VersionNumber())
w.downstreamWorkers, err = downstreamWorkersFactory(cancelCtx, w.LastStatusSuccess().WorkerId)
if err != nil {
event.WriteError(cancelCtx, op, err)
w.conf.ServerSideShutdownCh <- struct{}{}
+2 -4
View File
@@ -53,7 +53,7 @@ type downstreamRouter interface {
// ProcessPendingConnections starts a function that continually processes
// incoming client connections. This only returns when the provided context
// is done.
StartProcessingPendingConnections(context.Context, func() string) error
StartProcessingPendingConnections(context.Context, func() string)
}
// downstreamers provides at least a minimum interface that must be met by a
@@ -447,9 +447,7 @@ func (w *Worker) Start() error {
}
go func() {
defer w.tickerWg.Done()
if err := w.downstreamRoutes.StartProcessingPendingConnections(w.baseContext, servNameFn); err != nil {
errors.Wrap(w.baseContext, err, op)
}
w.downstreamRoutes.StartProcessingPendingConnections(w.baseContext, servNameFn)
}()
go func() {
defer w.tickerWg.Done()