update kubernetes dependencies to v1.25.0
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
186
vendor/google.golang.org/grpc/server.go
generated
vendored
186
vendor/google.golang.org/grpc/server.go
generated
vendored
@@ -134,7 +134,7 @@ type Server struct {
|
||||
channelzRemoveOnce sync.Once
|
||||
serveWG sync.WaitGroup // counts active Serve goroutines for GracefulStop
|
||||
|
||||
channelzID int64 // channelz unique identification number
|
||||
channelzID *channelz.Identifier
|
||||
czData *channelzData
|
||||
|
||||
serverWorkerChannels []chan *serverWorkerData
|
||||
@@ -584,9 +584,8 @@ func NewServer(opt ...ServerOption) *Server {
|
||||
s.initServerWorkers()
|
||||
}
|
||||
|
||||
if channelz.IsOn() {
|
||||
s.channelzID = channelz.RegisterServer(&channelzServer{s}, "")
|
||||
}
|
||||
s.channelzID = channelz.RegisterServer(&channelzServer{s}, "")
|
||||
channelz.Info(logger, s.channelzID, "Server created")
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -710,16 +709,9 @@ func (s *Server) GetServiceInfo() map[string]ServiceInfo {
|
||||
// the server being stopped.
|
||||
var ErrServerStopped = errors.New("grpc: the server has been stopped")
|
||||
|
||||
func (s *Server) useTransportAuthenticator(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
|
||||
if s.opts.creds == nil {
|
||||
return rawConn, nil, nil
|
||||
}
|
||||
return s.opts.creds.ServerHandshake(rawConn)
|
||||
}
|
||||
|
||||
type listenSocket struct {
|
||||
net.Listener
|
||||
channelzID int64
|
||||
channelzID *channelz.Identifier
|
||||
}
|
||||
|
||||
func (l *listenSocket) ChannelzMetric() *channelz.SocketInternalMetric {
|
||||
@@ -731,9 +723,8 @@ func (l *listenSocket) ChannelzMetric() *channelz.SocketInternalMetric {
|
||||
|
||||
func (l *listenSocket) Close() error {
|
||||
err := l.Listener.Close()
|
||||
if channelz.IsOn() {
|
||||
channelz.RemoveEntry(l.channelzID)
|
||||
}
|
||||
channelz.RemoveEntry(l.channelzID)
|
||||
channelz.Info(logger, l.channelzID, "ListenSocket deleted")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -766,11 +757,6 @@ func (s *Server) Serve(lis net.Listener) error {
|
||||
ls := &listenSocket{Listener: lis}
|
||||
s.lis[ls] = true
|
||||
|
||||
if channelz.IsOn() {
|
||||
ls.channelzID = channelz.RegisterListenSocket(ls, s.channelzID, lis.Addr().String())
|
||||
}
|
||||
s.mu.Unlock()
|
||||
|
||||
defer func() {
|
||||
s.mu.Lock()
|
||||
if s.lis != nil && s.lis[ls] {
|
||||
@@ -780,8 +766,16 @@ func (s *Server) Serve(lis net.Listener) error {
|
||||
s.mu.Unlock()
|
||||
}()
|
||||
|
||||
var tempDelay time.Duration // how long to sleep on accept failure
|
||||
var err error
|
||||
ls.channelzID, err = channelz.RegisterListenSocket(ls, s.channelzID, lis.Addr().String())
|
||||
if err != nil {
|
||||
s.mu.Unlock()
|
||||
return err
|
||||
}
|
||||
s.mu.Unlock()
|
||||
channelz.Info(logger, ls.channelzID, "ListenSocket created")
|
||||
|
||||
var tempDelay time.Duration // how long to sleep on accept failure
|
||||
for {
|
||||
rawConn, err := lis.Accept()
|
||||
if err != nil {
|
||||
@@ -839,35 +833,14 @@ func (s *Server) handleRawConn(lisAddr string, rawConn net.Conn) {
|
||||
return
|
||||
}
|
||||
rawConn.SetDeadline(time.Now().Add(s.opts.connectionTimeout))
|
||||
conn, authInfo, err := s.useTransportAuthenticator(rawConn)
|
||||
if err != nil {
|
||||
// ErrConnDispatched means that the connection was dispatched away from
|
||||
// gRPC; those connections should be left open.
|
||||
if err != credentials.ErrConnDispatched {
|
||||
// In deployments where a gRPC server runs behind a cloud load
|
||||
// balancer which performs regular TCP level health checks, the
|
||||
// connection is closed immediately by the latter. Skipping the
|
||||
// error here will help reduce log clutter.
|
||||
if err != io.EOF {
|
||||
s.mu.Lock()
|
||||
s.errorf("ServerHandshake(%q) failed: %v", rawConn.RemoteAddr(), err)
|
||||
s.mu.Unlock()
|
||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.Serve failed to complete security handshake from %q: %v", rawConn.RemoteAddr(), err)
|
||||
}
|
||||
rawConn.Close()
|
||||
}
|
||||
rawConn.SetDeadline(time.Time{})
|
||||
return
|
||||
}
|
||||
|
||||
// Finish handshaking (HTTP2)
|
||||
st := s.newHTTP2Transport(conn, authInfo)
|
||||
st := s.newHTTP2Transport(rawConn)
|
||||
rawConn.SetDeadline(time.Time{})
|
||||
if st == nil {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
rawConn.SetDeadline(time.Time{})
|
||||
if !s.addConn(lisAddr, st) {
|
||||
return
|
||||
}
|
||||
@@ -888,10 +861,11 @@ func (s *Server) drainServerTransports(addr string) {
|
||||
|
||||
// newHTTP2Transport sets up a http/2 transport (using the
|
||||
// gRPC http2 server transport in transport/http2_server.go).
|
||||
func (s *Server) newHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) transport.ServerTransport {
|
||||
func (s *Server) newHTTP2Transport(c net.Conn) transport.ServerTransport {
|
||||
config := &transport.ServerConfig{
|
||||
MaxStreams: s.opts.maxConcurrentStreams,
|
||||
AuthInfo: authInfo,
|
||||
ConnectionTimeout: s.opts.connectionTimeout,
|
||||
Credentials: s.opts.creds,
|
||||
InTapHandle: s.opts.inTapHandle,
|
||||
StatsHandler: s.opts.statsHandler,
|
||||
KeepaliveParams: s.opts.keepaliveParams,
|
||||
@@ -909,8 +883,15 @@ func (s *Server) newHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) tr
|
||||
s.mu.Lock()
|
||||
s.errorf("NewServerTransport(%q) failed: %v", c.RemoteAddr(), err)
|
||||
s.mu.Unlock()
|
||||
c.Close()
|
||||
channelz.Warning(logger, s.channelzID, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
||||
// ErrConnDispatched means that the connection was dispatched away from
|
||||
// gRPC; those connections should be left open.
|
||||
if err != credentials.ErrConnDispatched {
|
||||
// Don't log on ErrConnDispatched and io.EOF to prevent log spam.
|
||||
if err != io.EOF {
|
||||
channelz.Warning(logger, s.channelzID, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
||||
}
|
||||
c.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1124,16 +1105,21 @@ func chainUnaryServerInterceptors(s *Server) {
|
||||
|
||||
func chainUnaryInterceptors(interceptors []UnaryServerInterceptor) UnaryServerInterceptor {
|
||||
return func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (interface{}, error) {
|
||||
var i int
|
||||
var next UnaryHandler
|
||||
next = func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
if i == len(interceptors)-1 {
|
||||
return interceptors[i](ctx, req, info, handler)
|
||||
}
|
||||
i++
|
||||
return interceptors[i-1](ctx, req, info, next)
|
||||
// the struct ensures the variables are allocated together, rather than separately, since we
|
||||
// know they should be garbage collected together. This saves 1 allocation and decreases
|
||||
// time/call by about 10% on the microbenchmark.
|
||||
var state struct {
|
||||
i int
|
||||
next UnaryHandler
|
||||
}
|
||||
return next(ctx, req)
|
||||
state.next = func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
if state.i == len(interceptors)-1 {
|
||||
return interceptors[state.i](ctx, req, info, handler)
|
||||
}
|
||||
state.i++
|
||||
return interceptors[state.i-1](ctx, req, info, state.next)
|
||||
}
|
||||
return state.next(ctx, req)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1298,9 +1284,10 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
||||
if appErr != nil {
|
||||
appStatus, ok := status.FromError(appErr)
|
||||
if !ok {
|
||||
// Convert appErr if it is not a grpc status error.
|
||||
appErr = status.Error(codes.Unknown, appErr.Error())
|
||||
appStatus, _ = status.FromError(appErr)
|
||||
// Convert non-status application error to a status error with code
|
||||
// Unknown, but handle context errors specifically.
|
||||
appStatus = status.FromContextError(appErr)
|
||||
appErr = appStatus.Err()
|
||||
}
|
||||
if trInfo != nil {
|
||||
trInfo.tr.LazyLog(stringer(appStatus.Message()), true)
|
||||
@@ -1409,16 +1396,21 @@ func chainStreamServerInterceptors(s *Server) {
|
||||
|
||||
func chainStreamInterceptors(interceptors []StreamServerInterceptor) StreamServerInterceptor {
|
||||
return func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error {
|
||||
var i int
|
||||
var next StreamHandler
|
||||
next = func(srv interface{}, ss ServerStream) error {
|
||||
if i == len(interceptors)-1 {
|
||||
return interceptors[i](srv, ss, info, handler)
|
||||
}
|
||||
i++
|
||||
return interceptors[i-1](srv, ss, info, next)
|
||||
// the struct ensures the variables are allocated together, rather than separately, since we
|
||||
// know they should be garbage collected together. This saves 1 allocation and decreases
|
||||
// time/call by about 10% on the microbenchmark.
|
||||
var state struct {
|
||||
i int
|
||||
next StreamHandler
|
||||
}
|
||||
return next(srv, ss)
|
||||
state.next = func(srv interface{}, ss ServerStream) error {
|
||||
if state.i == len(interceptors)-1 {
|
||||
return interceptors[state.i](srv, ss, info, handler)
|
||||
}
|
||||
state.i++
|
||||
return interceptors[state.i-1](srv, ss, info, state.next)
|
||||
}
|
||||
return state.next(srv, ss)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1559,7 +1551,9 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
|
||||
if appErr != nil {
|
||||
appStatus, ok := status.FromError(appErr)
|
||||
if !ok {
|
||||
appStatus = status.New(codes.Unknown, appErr.Error())
|
||||
// Convert non-status application error to a status error with code
|
||||
// Unknown, but handle context errors specifically.
|
||||
appStatus = status.FromContextError(appErr)
|
||||
appErr = appStatus.Err()
|
||||
}
|
||||
if trInfo != nil {
|
||||
@@ -1716,11 +1710,7 @@ func (s *Server) Stop() {
|
||||
s.done.Fire()
|
||||
}()
|
||||
|
||||
s.channelzRemoveOnce.Do(func() {
|
||||
if channelz.IsOn() {
|
||||
channelz.RemoveEntry(s.channelzID)
|
||||
}
|
||||
})
|
||||
s.channelzRemoveOnce.Do(func() { channelz.RemoveEntry(s.channelzID) })
|
||||
|
||||
s.mu.Lock()
|
||||
listeners := s.lis
|
||||
@@ -1758,11 +1748,7 @@ func (s *Server) GracefulStop() {
|
||||
s.quit.Fire()
|
||||
defer s.done.Fire()
|
||||
|
||||
s.channelzRemoveOnce.Do(func() {
|
||||
if channelz.IsOn() {
|
||||
channelz.RemoveEntry(s.channelzID)
|
||||
}
|
||||
})
|
||||
s.channelzRemoveOnce.Do(func() { channelz.RemoveEntry(s.channelzID) })
|
||||
s.mu.Lock()
|
||||
if s.conns == nil {
|
||||
s.mu.Unlock()
|
||||
@@ -1815,12 +1801,26 @@ func (s *Server) getCodec(contentSubtype string) baseCodec {
|
||||
return codec
|
||||
}
|
||||
|
||||
// SetHeader sets the header metadata.
|
||||
// When called multiple times, all the provided metadata will be merged.
|
||||
// All the metadata will be sent out when one of the following happens:
|
||||
// - grpc.SendHeader() is called;
|
||||
// - The first response is sent out;
|
||||
// - An RPC status is sent out (error or success).
|
||||
// SetHeader sets the header metadata to be sent from the server to the client.
|
||||
// The context provided must be the context passed to the server's handler.
|
||||
//
|
||||
// Streaming RPCs should prefer the SetHeader method of the ServerStream.
|
||||
//
|
||||
// When called multiple times, all the provided metadata will be merged. All
|
||||
// the metadata will be sent out when one of the following happens:
|
||||
//
|
||||
// - grpc.SendHeader is called, or for streaming handlers, stream.SendHeader.
|
||||
// - The first response message is sent. For unary handlers, this occurs when
|
||||
// the handler returns; for streaming handlers, this can happen when stream's
|
||||
// SendMsg method is called.
|
||||
// - An RPC status is sent out (error or success). This occurs when the handler
|
||||
// returns.
|
||||
//
|
||||
// SetHeader will fail if called after any of the events above.
|
||||
//
|
||||
// The error returned is compatible with the status package. However, the
|
||||
// status code will often not match the RPC status as seen by the client
|
||||
// application, and therefore, should not be relied upon for this purpose.
|
||||
func SetHeader(ctx context.Context, md metadata.MD) error {
|
||||
if md.Len() == 0 {
|
||||
return nil
|
||||
@@ -1832,8 +1832,14 @@ func SetHeader(ctx context.Context, md metadata.MD) error {
|
||||
return stream.SetHeader(md)
|
||||
}
|
||||
|
||||
// SendHeader sends header metadata. It may be called at most once.
|
||||
// The provided md and headers set by SetHeader() will be sent.
|
||||
// SendHeader sends header metadata. It may be called at most once, and may not
|
||||
// be called after any event that causes headers to be sent (see SetHeader for
|
||||
// a complete list). The provided md and headers set by SetHeader() will be
|
||||
// sent.
|
||||
//
|
||||
// The error returned is compatible with the status package. However, the
|
||||
// status code will often not match the RPC status as seen by the client
|
||||
// application, and therefore, should not be relied upon for this purpose.
|
||||
func SendHeader(ctx context.Context, md metadata.MD) error {
|
||||
stream := ServerTransportStreamFromContext(ctx)
|
||||
if stream == nil {
|
||||
@@ -1847,6 +1853,10 @@ func SendHeader(ctx context.Context, md metadata.MD) error {
|
||||
|
||||
// SetTrailer sets the trailer metadata that will be sent when an RPC returns.
|
||||
// When called more than once, all the provided metadata will be merged.
|
||||
//
|
||||
// The error returned is compatible with the status package. However, the
|
||||
// status code will often not match the RPC status as seen by the client
|
||||
// application, and therefore, should not be relied upon for this purpose.
|
||||
func SetTrailer(ctx context.Context, md metadata.MD) error {
|
||||
if md.Len() == 0 {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user