Bump google.golang.org/grpc from 1.69.4 to 1.70.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.69.4 to 1.70.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.69.4...v1.70.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
@@ -107,7 +107,7 @@ require (
|
|||||||
golang.org/x/term v0.28.0
|
golang.org/x/term v0.28.0
|
||||||
golang.org/x/text v0.21.0
|
golang.org/x/text v0.21.0
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f
|
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f
|
||||||
google.golang.org/grpc v1.69.4
|
google.golang.org/grpc v1.70.0
|
||||||
google.golang.org/protobuf v1.36.3
|
google.golang.org/protobuf v1.36.3
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
gotest.tools/v3 v3.5.1
|
gotest.tools/v3 v3.5.1
|
||||||
|
|||||||
@@ -1613,8 +1613,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji
|
|||||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||||
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
|
google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ=
|
||||||
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
|
google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw=
|
||||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e h1:m7aQHHqd0q89mRwhwS9Bx2rjyl/hsFAeta+uGrHsQaU=
|
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e h1:m7aQHHqd0q89mRwhwS9Bx2rjyl/hsFAeta+uGrHsQaU=
|
||||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e/go.mod h1:gID3PKrg7pWKntu9Ss6zTLJ0ttC0X9IHgREOCZwbCVU=
|
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e/go.mod h1:gID3PKrg7pWKntu9Ss6zTLJ0ttC0X9IHgREOCZwbCVU=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
|||||||
+24
-3
@@ -54,9 +54,18 @@ func init() {
|
|||||||
balancer.Register(pickfirstBuilder{})
|
balancer.Register(pickfirstBuilder{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// enableHealthListenerKeyType is a unique key type used in resolver attributes
|
type (
|
||||||
// to indicate whether the health listener usage is enabled.
|
// enableHealthListenerKeyType is a unique key type used in resolver
|
||||||
type enableHealthListenerKeyType struct{}
|
// attributes to indicate whether the health listener usage is enabled.
|
||||||
|
enableHealthListenerKeyType struct{}
|
||||||
|
// managedByPickfirstKeyType is an attribute key type to inform Outlier
|
||||||
|
// Detection that the generic health listener is being used.
|
||||||
|
// TODO: https://github.com/grpc/grpc-go/issues/7915 - Remove this when
|
||||||
|
// implementing the dualstack design. This is a hack. Once Dualstack is
|
||||||
|
// completed, outlier detection will stop sending ejection updates through
|
||||||
|
// the connectivity listener.
|
||||||
|
managedByPickfirstKeyType struct{}
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logger = grpclog.Component("pick-first-leaf-lb")
|
logger = grpclog.Component("pick-first-leaf-lb")
|
||||||
@@ -140,6 +149,17 @@ func EnableHealthListener(state resolver.State) resolver.State {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsManagedByPickfirst returns whether an address belongs to a SubConn
|
||||||
|
// managed by the pickfirst LB policy.
|
||||||
|
// TODO: https://github.com/grpc/grpc-go/issues/7915 - This is a hack to disable
|
||||||
|
// outlier_detection via the with connectivity listener when using pick_first.
|
||||||
|
// Once Dualstack changes are complete, all SubConns will be created by
|
||||||
|
// pick_first and outlier detection will only use the health listener for
|
||||||
|
// ejection. This hack can then be removed.
|
||||||
|
func IsManagedByPickfirst(addr resolver.Address) bool {
|
||||||
|
return addr.BalancerAttributes.Value(managedByPickfirstKeyType{}) != nil
|
||||||
|
}
|
||||||
|
|
||||||
type pfConfig struct {
|
type pfConfig struct {
|
||||||
serviceconfig.LoadBalancingConfig `json:"-"`
|
serviceconfig.LoadBalancingConfig `json:"-"`
|
||||||
|
|
||||||
@@ -166,6 +186,7 @@ type scData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *pickfirstBalancer) newSCData(addr resolver.Address) (*scData, error) {
|
func (b *pickfirstBalancer) newSCData(addr resolver.Address) (*scData, error) {
|
||||||
|
addr.BalancerAttributes = addr.BalancerAttributes.WithValue(managedByPickfirstKeyType{}, true)
|
||||||
sd := &scData{
|
sd := &scData{
|
||||||
rawConnectivityState: connectivity.Idle,
|
rawConnectivityState: connectivity.Idle,
|
||||||
effectiveState: connectivity.Idle,
|
effectiveState: connectivity.Idle,
|
||||||
|
|||||||
+68
-5
@@ -34,7 +34,15 @@ import (
|
|||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
var setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
|
var (
|
||||||
|
setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
|
||||||
|
// noOpRegisterHealthListenerFn is used when client side health checking is
|
||||||
|
// disabled. It sends a single READY update on the registered listener.
|
||||||
|
noOpRegisterHealthListenerFn = func(_ context.Context, listener func(balancer.SubConnState)) func() {
|
||||||
|
listener(balancer.SubConnState{ConnectivityState: connectivity.Ready})
|
||||||
|
return func() {}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// ccBalancerWrapper sits between the ClientConn and the Balancer.
|
// ccBalancerWrapper sits between the ClientConn and the Balancer.
|
||||||
//
|
//
|
||||||
@@ -277,10 +285,17 @@ type healthData struct {
|
|||||||
// to the LB policy. This is stored to avoid sending updates when the
|
// to the LB policy. This is stored to avoid sending updates when the
|
||||||
// SubConn has already exited connectivity state READY.
|
// SubConn has already exited connectivity state READY.
|
||||||
connectivityState connectivity.State
|
connectivityState connectivity.State
|
||||||
|
// closeHealthProducer stores function to close the ref counted health
|
||||||
|
// producer. The health producer is automatically closed when the SubConn
|
||||||
|
// state changes.
|
||||||
|
closeHealthProducer func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHealthData(s connectivity.State) *healthData {
|
func newHealthData(s connectivity.State) *healthData {
|
||||||
return &healthData{connectivityState: s}
|
return &healthData{
|
||||||
|
connectivityState: s,
|
||||||
|
closeHealthProducer: func() {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateState is invoked by grpc to push a subConn state update to the
|
// updateState is invoked by grpc to push a subConn state update to the
|
||||||
@@ -413,6 +428,37 @@ func (acbw *acBalancerWrapper) closeProducers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// healthProducerRegisterFn is a type alias for the health producer's function
|
||||||
|
// for registering listeners.
|
||||||
|
type healthProducerRegisterFn = func(context.Context, balancer.SubConn, string, func(balancer.SubConnState)) func()
|
||||||
|
|
||||||
|
// healthListenerRegFn returns a function to register a listener for health
|
||||||
|
// updates. If client side health checks are disabled, the registered listener
|
||||||
|
// will get a single READY (raw connectivity state) update.
|
||||||
|
//
|
||||||
|
// Client side health checking is enabled when all the following
|
||||||
|
// conditions are satisfied:
|
||||||
|
// 1. Health checking is not disabled using the dial option.
|
||||||
|
// 2. The health package is imported.
|
||||||
|
// 3. The health check config is present in the service config.
|
||||||
|
func (acbw *acBalancerWrapper) healthListenerRegFn() func(context.Context, func(balancer.SubConnState)) func() {
|
||||||
|
if acbw.ccb.cc.dopts.disableHealthCheck {
|
||||||
|
return noOpRegisterHealthListenerFn
|
||||||
|
}
|
||||||
|
regHealthLisFn := internal.RegisterClientHealthCheckListener
|
||||||
|
if regHealthLisFn == nil {
|
||||||
|
// The health package is not imported.
|
||||||
|
return noOpRegisterHealthListenerFn
|
||||||
|
}
|
||||||
|
cfg := acbw.ac.cc.healthCheckConfig()
|
||||||
|
if cfg == nil {
|
||||||
|
return noOpRegisterHealthListenerFn
|
||||||
|
}
|
||||||
|
return func(ctx context.Context, listener func(balancer.SubConnState)) func() {
|
||||||
|
return regHealthLisFn.(healthProducerRegisterFn)(ctx, acbw, cfg.ServiceName, listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterHealthListener accepts a health listener from the LB policy. It sends
|
// RegisterHealthListener accepts a health listener from the LB policy. It sends
|
||||||
// updates to the health listener as long as the SubConn's connectivity state
|
// updates to the health listener as long as the SubConn's connectivity state
|
||||||
// doesn't change and a new health listener is not registered. To invalidate
|
// doesn't change and a new health listener is not registered. To invalidate
|
||||||
@@ -421,6 +467,7 @@ func (acbw *acBalancerWrapper) closeProducers() {
|
|||||||
func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.SubConnState)) {
|
func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.SubConnState)) {
|
||||||
acbw.healthMu.Lock()
|
acbw.healthMu.Lock()
|
||||||
defer acbw.healthMu.Unlock()
|
defer acbw.healthMu.Unlock()
|
||||||
|
acbw.healthData.closeHealthProducer()
|
||||||
// listeners should not be registered when the connectivity state
|
// listeners should not be registered when the connectivity state
|
||||||
// isn't Ready. This may happen when the balancer registers a listener
|
// isn't Ready. This may happen when the balancer registers a listener
|
||||||
// after the connectivityState is updated, but before it is notified
|
// after the connectivityState is updated, but before it is notified
|
||||||
@@ -436,6 +483,7 @@ func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.Sub
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerFn := acbw.healthListenerRegFn()
|
||||||
acbw.ccb.serializer.TrySchedule(func(ctx context.Context) {
|
acbw.ccb.serializer.TrySchedule(func(ctx context.Context) {
|
||||||
if ctx.Err() != nil || acbw.ccb.balancer == nil {
|
if ctx.Err() != nil || acbw.ccb.balancer == nil {
|
||||||
return
|
return
|
||||||
@@ -443,10 +491,25 @@ func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.Sub
|
|||||||
// Don't send updates if a new listener is registered.
|
// Don't send updates if a new listener is registered.
|
||||||
acbw.healthMu.Lock()
|
acbw.healthMu.Lock()
|
||||||
defer acbw.healthMu.Unlock()
|
defer acbw.healthMu.Unlock()
|
||||||
curHD := acbw.healthData
|
if acbw.healthData != hd {
|
||||||
if curHD != hd {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
listener(balancer.SubConnState{ConnectivityState: connectivity.Ready})
|
// Serialize the health updates from the health producer with
|
||||||
|
// other calls into the LB policy.
|
||||||
|
listenerWrapper := func(scs balancer.SubConnState) {
|
||||||
|
acbw.ccb.serializer.TrySchedule(func(ctx context.Context) {
|
||||||
|
if ctx.Err() != nil || acbw.ccb.balancer == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
acbw.healthMu.Lock()
|
||||||
|
defer acbw.healthMu.Unlock()
|
||||||
|
if acbw.healthData != hd {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
listener(scs)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
hd.closeHealthProducer = registerFn(ctx, listenerWrapper)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.35.1
|
// protoc-gen-go v1.35.2
|
||||||
// protoc v5.27.1
|
// protoc v5.27.1
|
||||||
// source: grpc/binlog/v1/binarylog.proto
|
// source: grpc/binlog/v1/binarylog.proto
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -32,6 +32,8 @@ import (
|
|||||||
"google.golang.org/grpc/internal/envconfig"
|
"google.golang.org/grpc/internal/envconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const alpnFailureHelpMessage = "If you upgraded from a grpc-go version earlier than 1.67, your TLS connections may have stopped working due to ALPN enforcement. For more details, see: https://github.com/grpc/grpc-go/issues/434"
|
||||||
|
|
||||||
var logger = grpclog.Component("credentials")
|
var logger = grpclog.Component("credentials")
|
||||||
|
|
||||||
// TLSInfo contains the auth information for a TLS authenticated connection.
|
// TLSInfo contains the auth information for a TLS authenticated connection.
|
||||||
@@ -128,7 +130,7 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, authority string, rawCon
|
|||||||
if np == "" {
|
if np == "" {
|
||||||
if envconfig.EnforceALPNEnabled {
|
if envconfig.EnforceALPNEnabled {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property")
|
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property. %s", alpnFailureHelpMessage)
|
||||||
}
|
}
|
||||||
logger.Warningf("Allowing TLS connection to server %q with ALPN disabled. TLS connections to servers with ALPN disabled will be disallowed in future grpc-go releases", cfg.ServerName)
|
logger.Warningf("Allowing TLS connection to server %q with ALPN disabled. TLS connections to servers with ALPN disabled will be disallowed in future grpc-go releases", cfg.ServerName)
|
||||||
}
|
}
|
||||||
@@ -158,7 +160,7 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error)
|
|||||||
if cs.NegotiatedProtocol == "" {
|
if cs.NegotiatedProtocol == "" {
|
||||||
if envconfig.EnforceALPNEnabled {
|
if envconfig.EnforceALPNEnabled {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property")
|
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property. %s", alpnFailureHelpMessage)
|
||||||
} else if logger.V(2) {
|
} else if logger.V(2) {
|
||||||
logger.Info("Allowing TLS connection from client with ALPN disabled. TLS connections with ALPN disabled will be disallowed in future grpc-go releases")
|
logger.Info("Allowing TLS connection from client with ALPN disabled. TLS connections with ALPN disabled will be disallowed in future grpc-go releases")
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -428,6 +428,11 @@ func WithTimeout(d time.Duration) DialOption {
|
|||||||
// returned by f, gRPC checks the error's Temporary() method to decide if it
|
// returned by f, gRPC checks the error's Temporary() method to decide if it
|
||||||
// should try to reconnect to the network address.
|
// should try to reconnect to the network address.
|
||||||
//
|
//
|
||||||
|
// Note that gRPC by default performs name resolution on the target passed to
|
||||||
|
// NewClient. To bypass name resolution and cause the target string to be
|
||||||
|
// passed directly to the dialer here instead, use the "passthrough" resolver
|
||||||
|
// by specifying it in the target string, e.g. "passthrough:target".
|
||||||
|
//
|
||||||
// Note: All supported releases of Go (as of December 2023) override the OS
|
// Note: All supported releases of Go (as of December 2023) override the OS
|
||||||
// defaults for TCP keepalive time and interval to 15s. To enable TCP keepalive
|
// defaults for TCP keepalive time and interval to 15s. To enable TCP keepalive
|
||||||
// with OS defaults for keepalive time and interval, use a net.Dialer that sets
|
// with OS defaults for keepalive time and interval, use a net.Dialer that sets
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.35.1
|
// protoc-gen-go v1.35.2
|
||||||
// protoc v5.27.1
|
// protoc v5.27.1
|
||||||
// source: grpc/health/v1/health.proto
|
// source: grpc/health/v1/health.proto
|
||||||
|
|
||||||
|
|||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package health
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/balancer"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/connectivity"
|
||||||
|
"google.golang.org/grpc/internal"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
producerBuilderSingleton = &producerBuilder{}
|
||||||
|
internal.RegisterClientHealthCheckListener = registerClientSideHealthCheckListener
|
||||||
|
}
|
||||||
|
|
||||||
|
type producerBuilder struct{}
|
||||||
|
|
||||||
|
var producerBuilderSingleton *producerBuilder
|
||||||
|
|
||||||
|
// Build constructs and returns a producer and its cleanup function.
|
||||||
|
func (*producerBuilder) Build(cci any) (balancer.Producer, func()) {
|
||||||
|
p := &healthServiceProducer{
|
||||||
|
cc: cci.(grpc.ClientConnInterface),
|
||||||
|
cancel: func() {},
|
||||||
|
}
|
||||||
|
return p, func() {
|
||||||
|
p.mu.Lock()
|
||||||
|
defer p.mu.Unlock()
|
||||||
|
p.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type healthServiceProducer struct {
|
||||||
|
// The following fields are initialized at build time and read-only after
|
||||||
|
// that and therefore do not need to be guarded by a mutex.
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
|
||||||
|
mu sync.Mutex
|
||||||
|
cancel func()
|
||||||
|
}
|
||||||
|
|
||||||
|
// registerClientSideHealthCheckListener accepts a listener to provide server
|
||||||
|
// health state via the health service.
|
||||||
|
func registerClientSideHealthCheckListener(ctx context.Context, sc balancer.SubConn, serviceName string, listener func(balancer.SubConnState)) func() {
|
||||||
|
pr, closeFn := sc.GetOrBuildProducer(producerBuilderSingleton)
|
||||||
|
p := pr.(*healthServiceProducer)
|
||||||
|
p.mu.Lock()
|
||||||
|
defer p.mu.Unlock()
|
||||||
|
p.cancel()
|
||||||
|
if listener == nil {
|
||||||
|
return closeFn
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
p.cancel = cancel
|
||||||
|
|
||||||
|
go p.startHealthCheck(ctx, sc, serviceName, listener)
|
||||||
|
return closeFn
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *healthServiceProducer) startHealthCheck(ctx context.Context, sc balancer.SubConn, serviceName string, listener func(balancer.SubConnState)) {
|
||||||
|
newStream := func(method string) (any, error) {
|
||||||
|
return p.cc.NewStream(ctx, &grpc.StreamDesc{ServerStreams: true}, method)
|
||||||
|
}
|
||||||
|
|
||||||
|
setConnectivityState := func(state connectivity.State, err error) {
|
||||||
|
listener(balancer.SubConnState{
|
||||||
|
ConnectivityState: state,
|
||||||
|
ConnectionError: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the function through the internal variable as tests use it for
|
||||||
|
// mocking.
|
||||||
|
err := internal.HealthCheckFunc(ctx, newStream, setConnectivityState, serviceName)
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if status.Code(err) == codes.Unimplemented {
|
||||||
|
logger.Errorf("Subchannel health check is unimplemented at server side, thus health check is disabled for SubConn %p", sc)
|
||||||
|
} else {
|
||||||
|
logger.Errorf("Health checking failed for SubConn %p: %v", sc, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -49,7 +49,7 @@ var (
|
|||||||
// XDSFallbackSupport is the env variable that controls whether support for
|
// XDSFallbackSupport is the env variable that controls whether support for
|
||||||
// xDS fallback is turned on. If this is unset or is false, only the first
|
// xDS fallback is turned on. If this is unset or is false, only the first
|
||||||
// xDS server in the list of server configs will be used.
|
// xDS server in the list of server configs will be used.
|
||||||
XDSFallbackSupport = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FALLBACK", false)
|
XDSFallbackSupport = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FALLBACK", true)
|
||||||
// NewPickFirstEnabled is set if the new pickfirst leaf policy is to be used
|
// NewPickFirstEnabled is set if the new pickfirst leaf policy is to be used
|
||||||
// instead of the exiting pickfirst implementation. This can be enabled by
|
// instead of the exiting pickfirst implementation. This can be enabled by
|
||||||
// setting the environment variable "GRPC_EXPERIMENTAL_ENABLE_NEW_PICK_FIRST"
|
// setting the environment variable "GRPC_EXPERIMENTAL_ENABLE_NEW_PICK_FIRST"
|
||||||
|
|||||||
+6
@@ -53,4 +53,10 @@ var (
|
|||||||
|
|
||||||
// C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing.
|
// C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing.
|
||||||
C2PResolverTestOnlyTrafficDirectorURI = os.Getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI")
|
C2PResolverTestOnlyTrafficDirectorURI = os.Getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI")
|
||||||
|
|
||||||
|
// XDSDualstackEndpointsEnabled is true if gRPC should read the
|
||||||
|
// "additional addresses" in the xDS endpoint resource.
|
||||||
|
// TODO: https://github.com/grpc/grpc-go/issues/7866 - Control this using
|
||||||
|
// an env variable when all LB policies handle endpoints.
|
||||||
|
XDSDualstackEndpointsEnabled = false
|
||||||
)
|
)
|
||||||
|
|||||||
+4
@@ -31,6 +31,10 @@ import (
|
|||||||
var (
|
var (
|
||||||
// HealthCheckFunc is used to provide client-side LB channel health checking
|
// HealthCheckFunc is used to provide client-side LB channel health checking
|
||||||
HealthCheckFunc HealthChecker
|
HealthCheckFunc HealthChecker
|
||||||
|
// RegisterClientHealthCheckListener is used to provide a listener for
|
||||||
|
// updates from the client-side health checking service. It returns a
|
||||||
|
// function that can be called to stop the health producer.
|
||||||
|
RegisterClientHealthCheckListener any // func(ctx context.Context, sc balancer.SubConn, serviceName string, listener func(balancer.SubConnState)) func()
|
||||||
// BalancerUnregister is exported by package balancer to unregister a balancer.
|
// BalancerUnregister is exported by package balancer to unregister a balancer.
|
||||||
BalancerUnregister func(name string)
|
BalancerUnregister func(name string)
|
||||||
// KeepaliveMinPingTime is the minimum ping interval. This must be 10s by
|
// KeepaliveMinPingTime is the minimum ping interval. This must be 10s by
|
||||||
|
|||||||
+1
-1
@@ -498,5 +498,5 @@ func mapRecvMsgError(err error) error {
|
|||||||
if strings.Contains(err.Error(), "body closed by handler") {
|
if strings.Contains(err.Error(), "body closed by handler") {
|
||||||
return status.Error(codes.Canceled, err.Error())
|
return status.Error(codes.Canceled, err.Error())
|
||||||
}
|
}
|
||||||
return connectionErrorf(true, err, err.Error())
|
return connectionErrorf(true, err, "%s", err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -564,7 +564,7 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade
|
|||||||
t.logger.Infof("Aborting the stream early: %v", errMsg)
|
t.logger.Infof("Aborting the stream early: %v", errMsg)
|
||||||
}
|
}
|
||||||
t.controlBuf.put(&earlyAbortStream{
|
t.controlBuf.put(&earlyAbortStream{
|
||||||
httpStatus: 405,
|
httpStatus: http.StatusMethodNotAllowed,
|
||||||
streamID: streamID,
|
streamID: streamID,
|
||||||
contentSubtype: s.contentSubtype,
|
contentSubtype: s.contentSubtype,
|
||||||
status: status.New(codes.Internal, errMsg),
|
status: status.New(codes.Internal, errMsg),
|
||||||
@@ -585,7 +585,7 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade
|
|||||||
stat = status.New(codes.PermissionDenied, err.Error())
|
stat = status.New(codes.PermissionDenied, err.Error())
|
||||||
}
|
}
|
||||||
t.controlBuf.put(&earlyAbortStream{
|
t.controlBuf.put(&earlyAbortStream{
|
||||||
httpStatus: 200,
|
httpStatus: http.StatusOK,
|
||||||
streamID: s.id,
|
streamID: s.id,
|
||||||
contentSubtype: s.contentSubtype,
|
contentSubtype: s.contentSubtype,
|
||||||
status: stat,
|
status: stat,
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.35.1
|
// protoc-gen-go v1.35.2
|
||||||
// protoc v5.27.1
|
// protoc v5.27.1
|
||||||
// source: grpc/reflection/v1/reflection.proto
|
// source: grpc/reflection/v1/reflection.proto
|
||||||
|
|
||||||
|
|||||||
Generated
Vendored
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.35.1
|
// protoc-gen-go v1.35.2
|
||||||
// protoc v5.27.1
|
// protoc v5.27.1
|
||||||
// grpc/reflection/v1alpha/reflection.proto is a deprecated file.
|
// grpc/reflection/v1alpha/reflection.proto is a deprecated file.
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -1360,8 +1360,16 @@ func (s *Server) processUnaryRPC(ctx context.Context, stream *transport.ServerSt
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer d.Free()
|
freed := false
|
||||||
|
dataFree := func() {
|
||||||
|
if !freed {
|
||||||
|
d.Free()
|
||||||
|
freed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defer dataFree()
|
||||||
df := func(v any) error {
|
df := func(v any) error {
|
||||||
|
defer dataFree()
|
||||||
if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil {
|
if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil {
|
||||||
return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err)
|
return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-7
@@ -268,18 +268,21 @@ func parseServiceConfig(js string, maxAttempts int) *serviceconfig.ParseResult {
|
|||||||
return &serviceconfig.ParseResult{Config: &sc}
|
return &serviceconfig.ParseResult{Config: &sc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isValidRetryPolicy(jrp *jsonRetryPolicy) bool {
|
||||||
|
return jrp.MaxAttempts > 1 &&
|
||||||
|
jrp.InitialBackoff > 0 &&
|
||||||
|
jrp.MaxBackoff > 0 &&
|
||||||
|
jrp.BackoffMultiplier > 0 &&
|
||||||
|
len(jrp.RetryableStatusCodes) > 0
|
||||||
|
}
|
||||||
|
|
||||||
func convertRetryPolicy(jrp *jsonRetryPolicy, maxAttempts int) (p *internalserviceconfig.RetryPolicy, err error) {
|
func convertRetryPolicy(jrp *jsonRetryPolicy, maxAttempts int) (p *internalserviceconfig.RetryPolicy, err error) {
|
||||||
if jrp == nil {
|
if jrp == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if jrp.MaxAttempts <= 1 ||
|
if !isValidRetryPolicy(jrp) {
|
||||||
jrp.InitialBackoff <= 0 ||
|
return nil, fmt.Errorf("invalid retry policy (%+v): ", jrp)
|
||||||
jrp.MaxBackoff <= 0 ||
|
|
||||||
jrp.BackoffMultiplier <= 0 ||
|
|
||||||
len(jrp.RetryableStatusCodes) == 0 {
|
|
||||||
logger.Warningf("grpc: ignoring retry policy %v due to illegal configuration", jrp)
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if jrp.MaxAttempts < maxAttempts {
|
if jrp.MaxAttempts < maxAttempts {
|
||||||
|
|||||||
+1
-1
@@ -1766,7 +1766,7 @@ func (ss *serverStream) RecvMsg(m any) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err == io.ErrUnexpectedEOF {
|
if err == io.ErrUnexpectedEOF {
|
||||||
err = status.Errorf(codes.Internal, io.ErrUnexpectedEOF.Error())
|
err = status.Error(codes.Internal, io.ErrUnexpectedEOF.Error())
|
||||||
}
|
}
|
||||||
return toRPCErr(err)
|
return toRPCErr(err)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,4 +19,4 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
// Version is the current grpc version.
|
// Version is the current grpc version.
|
||||||
const Version = "1.69.4"
|
const Version = "1.70.0"
|
||||||
|
|||||||
Vendored
+1
-1
@@ -2281,7 +2281,7 @@ google.golang.org/genproto/googleapis/api/httpbody
|
|||||||
## explicit; go 1.22
|
## explicit; go 1.22
|
||||||
google.golang.org/genproto/googleapis/rpc/errdetails
|
google.golang.org/genproto/googleapis/rpc/errdetails
|
||||||
google.golang.org/genproto/googleapis/rpc/status
|
google.golang.org/genproto/googleapis/rpc/status
|
||||||
# google.golang.org/grpc v1.69.4
|
# google.golang.org/grpc v1.70.0
|
||||||
## explicit; go 1.22
|
## explicit; go 1.22
|
||||||
google.golang.org/grpc
|
google.golang.org/grpc
|
||||||
google.golang.org/grpc/attributes
|
google.golang.org/grpc/attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user