Rename proto service stuff and change log levels for some messages
This commit is contained in:
parent
bdcfe05517
commit
b7acf5b5ab
|
@ -274,12 +274,12 @@ func (c *Core) startClusterListener() error {
|
|||
}
|
||||
|
||||
if c.clusterAddr == "" {
|
||||
c.logger.Printf("[TRACE] core/startClusterListener: clustering disabled, not starting listeners")
|
||||
c.logger.Printf("[INFO] core/startClusterListener: clustering disabled, not starting listeners")
|
||||
return nil
|
||||
}
|
||||
|
||||
if c.clusterListenerAddrs == nil || len(c.clusterListenerAddrs) == 0 {
|
||||
c.logger.Printf("[TRACE] core/startClusterListener: clustering not disabled but no addresses to listen on")
|
||||
c.logger.Printf("[WARN] core/startClusterListener: clustering not disabled but no addresses to listen on")
|
||||
return fmt.Errorf("cluster addresses not found")
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ func (c *Core) stopClusterListener() {
|
|||
return
|
||||
}
|
||||
|
||||
c.logger.Printf("[TRACE] core/stopClusterListener: stopping listeners")
|
||||
c.logger.Printf("[INFO] core/stopClusterListener: stopping listeners")
|
||||
|
||||
// Tell the goroutine managing the listeners to perform the shutdown
|
||||
// process
|
||||
|
@ -312,7 +312,7 @@ func (c *Core) stopClusterListener() {
|
|||
// bind errors. This ensures proper ordering.
|
||||
c.logger.Printf("[TRACE] core/stopClusterListener: waiting for success notification")
|
||||
<-c.clusterListenerShutdownSuccessCh
|
||||
c.logger.Printf("[TRACE] core/stopClusterListener: success")
|
||||
c.logger.Printf("[INFO] core/stopClusterListener: success")
|
||||
}
|
||||
|
||||
// ClusterTLSConfig generates a TLS configuration based on the local cluster
|
||||
|
@ -373,7 +373,7 @@ func WrapHandlerForClustering(handler http.Handler, logger *log.Logger) func() (
|
|||
freq, err := forwarding.ParseForwardedHTTPRequest(req)
|
||||
if err != nil {
|
||||
if logger != nil {
|
||||
logger.Printf("[ERR] http/ForwardedRequestHandler: error parsing forwarded request: %v", err)
|
||||
logger.Printf("[ERR] http/forwarded-request-server: error parsing forwarded request: %v", err)
|
||||
}
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
|
|
@ -282,7 +282,7 @@ type Core struct {
|
|||
// The grpc ClientConn for RPC calls
|
||||
rpcClientConn *grpc.ClientConn
|
||||
// The grpc forwarding client
|
||||
rpcForwardingClient ForwardedRequestHandlerClient
|
||||
rpcForwardingClient RequestForwardingClient
|
||||
}
|
||||
|
||||
// CoreConfig is used to parameterize a core
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
// Code generated by protoc-gen-go.
|
||||
// source: forwarding_service.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package vault is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
forwarding_service.proto
|
||||
|
||||
It has these top-level messages:
|
||||
*/
|
||||
package vault
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import forwarding "github.com/hashicorp/vault/helper/forwarding"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion3
|
||||
|
||||
// Client API for ForwardedRequestHandler service
|
||||
|
||||
type ForwardedRequestHandlerClient interface {
|
||||
HandleRequest(ctx context.Context, in *forwarding.Request, opts ...grpc.CallOption) (*forwarding.Response, error)
|
||||
}
|
||||
|
||||
type forwardedRequestHandlerClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewForwardedRequestHandlerClient(cc *grpc.ClientConn) ForwardedRequestHandlerClient {
|
||||
return &forwardedRequestHandlerClient{cc}
|
||||
}
|
||||
|
||||
func (c *forwardedRequestHandlerClient) HandleRequest(ctx context.Context, in *forwarding.Request, opts ...grpc.CallOption) (*forwarding.Response, error) {
|
||||
out := new(forwarding.Response)
|
||||
err := grpc.Invoke(ctx, "/vault.ForwardedRequestHandler/HandleRequest", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for ForwardedRequestHandler service
|
||||
|
||||
type ForwardedRequestHandlerServer interface {
|
||||
HandleRequest(context.Context, *forwarding.Request) (*forwarding.Response, error)
|
||||
}
|
||||
|
||||
func RegisterForwardedRequestHandlerServer(s *grpc.Server, srv ForwardedRequestHandlerServer) {
|
||||
s.RegisterService(&_ForwardedRequestHandler_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _ForwardedRequestHandler_HandleRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(forwarding.Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ForwardedRequestHandlerServer).HandleRequest(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/vault.ForwardedRequestHandler/HandleRequest",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ForwardedRequestHandlerServer).HandleRequest(ctx, req.(*forwarding.Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _ForwardedRequestHandler_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "vault.ForwardedRequestHandler",
|
||||
HandlerType: (*ForwardedRequestHandlerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "HandleRequest",
|
||||
Handler: _ForwardedRequestHandler_HandleRequest_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: fileDescriptor0,
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("forwarding_service.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 156 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x48, 0xcb, 0x2f, 0x2a,
|
||||
0x4f, 0x2c, 0x4a, 0xc9, 0xcc, 0x4b, 0x8f, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b,
|
||||
0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2d, 0x4b, 0x2c, 0xcd, 0x29, 0x91, 0xb2, 0x48, 0xcf, 0x2c,
|
||||
0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0x48, 0x2c, 0xce, 0xc8, 0x4c, 0xce, 0x2f,
|
||||
0x2a, 0xd0, 0x07, 0xcb, 0xe9, 0x67, 0xa4, 0xe6, 0x14, 0xa4, 0x16, 0xe9, 0x23, 0x8c, 0xd0, 0x2f,
|
||||
0xa9, 0x2c, 0x48, 0x2d, 0x86, 0x18, 0x60, 0x14, 0xce, 0x25, 0xee, 0x06, 0x91, 0x49, 0x4d, 0x09,
|
||||
0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0xf1, 0x48, 0xcc, 0x4b, 0xc9, 0x49, 0x2d, 0x12, 0xb2, 0xe1,
|
||||
0xe2, 0x85, 0x30, 0xa1, 0xe2, 0x42, 0xc2, 0x7a, 0x08, 0x43, 0xf4, 0xa0, 0x82, 0x52, 0x22, 0xa8,
|
||||
0x82, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x4a, 0x0c, 0x49, 0x6c, 0x60, 0xf3, 0x8d, 0x01, 0x01,
|
||||
0x00, 0x00, 0xff, 0xff, 0x4e, 0x32, 0x79, 0x01, 0xbc, 0x00, 0x00, 0x00,
|
||||
}
|
|
@ -52,7 +52,7 @@ func (c *Core) startForwarding() error {
|
|||
|
||||
// Create our RPC server and register the request handler server
|
||||
c.rpcServer = grpc.NewServer()
|
||||
RegisterForwardedRequestHandlerServer(c.rpcServer, &forwardedRequestRPCServer{
|
||||
RegisterRequestForwardingServer(c.rpcServer, &forwardedRequestRPCServer{
|
||||
core: c,
|
||||
handler: baseHandler,
|
||||
})
|
||||
|
@ -77,20 +77,20 @@ func (c *Core) startForwarding() error {
|
|||
go func() {
|
||||
defer shutdownWg.Done()
|
||||
|
||||
c.logger.Printf("[TRACE] core/startClusterListener: starting listener")
|
||||
c.logger.Printf("[INFO] core/startClusterListener: starting listener")
|
||||
|
||||
// Create a TCP listener. We do this separately and specifically
|
||||
// with TCP so that we can set deadlines.
|
||||
tcpLn, err := net.ListenTCP("tcp", laddr)
|
||||
if err != nil {
|
||||
c.logger.Printf("[TRACE] core/startClusterListener: error starting listener: %v", err)
|
||||
c.logger.Printf("[ERROR] core/startClusterListener: error starting listener: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Wrap the listener with TLS
|
||||
tlsLn := tls.NewListener(tcpLn, tlsConfig)
|
||||
|
||||
c.logger.Printf("[TRACE] core/startClusterListener: serving cluster requests on %s", tlsLn.Addr())
|
||||
c.logger.Printf("[INFO] core/startClusterListener: serving cluster requests on %s", tlsLn.Addr())
|
||||
|
||||
for {
|
||||
if atomic.LoadUint32(&shutdown) > 0 {
|
||||
|
@ -117,7 +117,7 @@ func (c *Core) startForwarding() error {
|
|||
tlsConn := conn.(*tls.Conn)
|
||||
err = tlsConn.Handshake()
|
||||
if err != nil {
|
||||
c.logger.Printf("[TRACE] core/startClusterListener/Accept: error handshaking: %v", err)
|
||||
c.logger.Printf("[DEBUG] core/startClusterListener/Accept: error handshaking: %v", err)
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
}
|
||||
|
@ -126,19 +126,19 @@ func (c *Core) startForwarding() error {
|
|||
|
||||
switch tlsConn.ConnectionState().NegotiatedProtocol {
|
||||
case "h2":
|
||||
c.logger.Printf("[TRACE] core/startClusterListener/Accept: got h2 connection")
|
||||
c.logger.Printf("[DEBUG] core/startClusterListener/Accept: got h2 connection")
|
||||
go fws.ServeConn(conn, &http2.ServeConnOpts{
|
||||
Handler: wrappedHandler,
|
||||
})
|
||||
|
||||
case "req_fw_sb-act_v1":
|
||||
c.logger.Printf("[TRACE] core/startClusterListener/Accept: got req_fw_sb-act_v1 connection")
|
||||
c.logger.Printf("[DEBUG] core/startClusterListener/Accept: got req_fw_sb-act_v1 connection")
|
||||
go fws.ServeConn(conn, &http2.ServeConnOpts{
|
||||
Handler: c.rpcServer,
|
||||
})
|
||||
|
||||
default:
|
||||
c.logger.Printf("[TRACE] core/startClusterListener/Accept: unknown negotiated protocol")
|
||||
c.logger.Printf("[DEBUG] core/startClusterListener/Accept: unknown negotiated protocol")
|
||||
conn.Close()
|
||||
continue
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func (c *Core) startForwarding() error {
|
|||
|
||||
// Stop the RPC server
|
||||
c.rpcServer.Stop()
|
||||
c.logger.Printf("[TRACE] core/startClusterListener: shutting down listeners")
|
||||
c.logger.Printf("[INFO] core/startClusterListener: shutting down listeners")
|
||||
|
||||
// Set the shutdown flag. This will cause the listeners to shut down
|
||||
// within the deadline in clusterListenerAcceptDeadline
|
||||
|
@ -162,7 +162,7 @@ func (c *Core) startForwarding() error {
|
|||
|
||||
// Wait for them all to shut down
|
||||
shutdownWg.Wait()
|
||||
c.logger.Printf("[TRACE] core/startClusterListener: listeners successfully shut down")
|
||||
c.logger.Printf("[INFO] core/startClusterListener: listeners successfully shut down")
|
||||
|
||||
// Tell the main thread that shutdown is done.
|
||||
c.clusterListenerShutdownSuccessCh <- struct{}{}
|
||||
|
@ -238,7 +238,7 @@ func (c *Core) refreshRequestForwardingConnection(clusterAddr string) error {
|
|||
c.logger.Printf("[ERR] core/refreshRequestForwardingConnection: err setting up rpc client: %v", err)
|
||||
return err
|
||||
}
|
||||
c.rpcForwardingClient = NewForwardedRequestHandlerClient(c.rpcClientConn)
|
||||
c.rpcForwardingClient = NewRequestForwardingClient(c.rpcClientConn)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
// Code generated by protoc-gen-go.
|
||||
// source: request_forwarding_service.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package vault is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
request_forwarding_service.proto
|
||||
|
||||
It has these top-level messages:
|
||||
*/
|
||||
package vault
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import forwarding "github.com/hashicorp/vault/helper/forwarding"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion3
|
||||
|
||||
// Client API for RequestForwarding service
|
||||
|
||||
type RequestForwardingClient interface {
|
||||
HandleRequest(ctx context.Context, in *forwarding.Request, opts ...grpc.CallOption) (*forwarding.Response, error)
|
||||
}
|
||||
|
||||
type requestForwardingClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewRequestForwardingClient(cc *grpc.ClientConn) RequestForwardingClient {
|
||||
return &requestForwardingClient{cc}
|
||||
}
|
||||
|
||||
func (c *requestForwardingClient) HandleRequest(ctx context.Context, in *forwarding.Request, opts ...grpc.CallOption) (*forwarding.Response, error) {
|
||||
out := new(forwarding.Response)
|
||||
err := grpc.Invoke(ctx, "/vault.RequestForwarding/HandleRequest", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for RequestForwarding service
|
||||
|
||||
type RequestForwardingServer interface {
|
||||
HandleRequest(context.Context, *forwarding.Request) (*forwarding.Response, error)
|
||||
}
|
||||
|
||||
func RegisterRequestForwardingServer(s *grpc.Server, srv RequestForwardingServer) {
|
||||
s.RegisterService(&_RequestForwarding_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _RequestForwarding_HandleRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(forwarding.Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RequestForwardingServer).HandleRequest(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/vault.RequestForwarding/HandleRequest",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RequestForwardingServer).HandleRequest(ctx, req.(*forwarding.Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _RequestForwarding_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "vault.RequestForwarding",
|
||||
HandlerType: (*RequestForwardingServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "HandleRequest",
|
||||
Handler: _RequestForwarding_HandleRequest_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: fileDescriptor0,
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("request_forwarding_service.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 155 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x4a, 0x2d, 0x2c,
|
||||
0x4d, 0x2d, 0x2e, 0x89, 0x4f, 0xcb, 0x2f, 0x2a, 0x4f, 0x2c, 0x4a, 0xc9, 0xcc, 0x4b, 0x8f, 0x2f,
|
||||
0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2d, 0x4b,
|
||||
0x2c, 0xcd, 0x29, 0x91, 0xb2, 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5,
|
||||
0xcf, 0x48, 0x2c, 0xce, 0xc8, 0x4c, 0xce, 0x2f, 0x2a, 0xd0, 0x07, 0xcb, 0xe9, 0x67, 0xa4, 0xe6,
|
||||
0x14, 0xa4, 0x16, 0xe9, 0x23, 0x8c, 0xd0, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x86, 0x18, 0x60, 0x14,
|
||||
0xc8, 0x25, 0x18, 0x04, 0xb1, 0xc4, 0x0d, 0xae, 0x40, 0xc8, 0x86, 0x8b, 0xd7, 0x23, 0x31, 0x2f,
|
||||
0x25, 0x27, 0x15, 0x2a, 0x25, 0x24, 0xac, 0x87, 0xd0, 0xae, 0x07, 0x15, 0x94, 0x12, 0x41, 0x15,
|
||||
0x2c, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0x62, 0x48, 0x62, 0x03, 0x9b, 0x6c, 0x0c, 0x08, 0x00,
|
||||
0x00, 0xff, 0xff, 0xc9, 0x1b, 0xdb, 0x52, 0xbe, 0x00, 0x00, 0x00,
|
||||
}
|
|
@ -4,6 +4,6 @@ import "github.com/hashicorp/vault/helper/forwarding/types.proto";
|
|||
|
||||
package vault;
|
||||
|
||||
service ForwardedRequestHandler {
|
||||
service RequestForwarding {
|
||||
rpc HandleRequest(forwarding.Request) returns (forwarding.Response) {}
|
||||
}
|
Loading…
Reference in New Issue