summaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go')
-rw-r--r--vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go29
1 files changed, 25 insertions, 4 deletions
diff --git a/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go b/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
index 2fc0a71f9..113181e6b 100644
--- a/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
+++ b/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
@@ -54,9 +54,18 @@ func init() {
balancer.Register(pickfirstBuilder{})
}
-// enableHealthListenerKeyType is a unique key type used in resolver attributes
-// to indicate whether the health listener usage is enabled.
-type enableHealthListenerKeyType struct{}
+type (
+ // enableHealthListenerKeyType is a unique key type used in resolver
+ // 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 (
logger = grpclog.Component("pick-first-leaf-lb")
@@ -111,7 +120,7 @@ func (pickfirstBuilder) Build(cc balancer.ClientConn, bo balancer.BuildOptions)
b := &pickfirstBalancer{
cc: cc,
target: bo.Target.String(),
- metricsRecorder: bo.MetricsRecorder, // ClientConn will always create a Metrics Recorder.
+ metricsRecorder: cc.MetricsRecorder(),
subConns: resolver.NewAddressMap(),
state: connectivity.Connecting,
@@ -140,6 +149,17 @@ func EnableHealthListener(state resolver.State) resolver.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 {
serviceconfig.LoadBalancingConfig `json:"-"`
@@ -166,6 +186,7 @@ type scData struct {
}
func (b *pickfirstBalancer) newSCData(addr resolver.Address) (*scData, error) {
+ addr.BalancerAttributes = addr.BalancerAttributes.WithValue(managedByPickfirstKeyType{}, true)
sd := &scData{
rawConnectivityState: connectivity.Idle,
effectiveState: connectivity.Idle,