Skip to content

Commit cc6c6e3

Browse files
committed
review comments
1 parent 06cd475 commit cc6c6e3

5 files changed

Lines changed: 17 additions & 19 deletions

File tree

balancer/pickfirst/pickfirst_ext_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,8 +2024,7 @@ func (s) TestPickFirstLeaf_HappyEyeballs_TriggerConnectionDelay(t *testing.T) {
20242024

20252025
func waitForMetric(ctx context.Context, t *testing.T, tmr *stats.TestMetricsRecorder, metricName string) {
20262026
for {
2027-
_, ok := tmr.Metric(metricName)
2028-
if ok {
2027+
if _, ok := tmr.Metric(metricName); ok {
20292028
break
20302029
}
20312030
select {

clientconn.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,11 @@ func (ac *addrConn) resetTransportAndUnlock() {
13361336
if !errors.Is(err, context.Canceled) {
13371337
connectionAttemptsFailedMetric.Record(ac.cc.metricsRecorderList, 1, ac.cc.target, ac.backendServiceLabel, ac.localityLabel)
13381338
} else {
1339-
// This records cancelled connection attempts which can be later replaced by a metric.
1340-
logger.Infof("Context cancellation detected; not recording this as a failed connection attempt.")
1339+
if logger.V(2) {
1340+
// This records cancelled connection attempts which can be later
1341+
// replaced by a metric.
1342+
logger.Infof("Context cancellation detected; not recording this as a failed connection attempt.")
1343+
}
13411344
}
13421345
// TODO: #7534 - Move re-resolution requests into the pick_first LB policy
13431346
// to ensure one resolution request per pass instead of per subconn failure.
@@ -1387,11 +1390,11 @@ func (ac *addrConn) resetTransportAndUnlock() {
13871390
// updateTelemetryLabelsLocked calculates and caches the telemetry labels based on the
13881391
// first address in addrConn.
13891392
func (ac *addrConn) updateTelemetryLabelsLocked() {
1390-
// Reset defaults
1391-
ac.localityLabel = ""
1392-
ac.backendServiceLabel = ""
13931393
labelsFunc, ok := internal.AddressToTelemetryLabels.(func(resolver.Address) map[string]string)
13941394
if !ok || len(ac.addrs) == 0 {
1395+
// Reset defaults
1396+
ac.localityLabel = ""
1397+
ac.backendServiceLabel = ""
13951398
return
13961399
}
13971400
labels := labelsFunc(ac.addrs[0])
@@ -1409,7 +1412,7 @@ func (ac *addrConn) securityLevelLocked() string {
14091412
secLevel, _ = ac.curAddr.Attributes.Value(securityLevelKey{}).(string)
14101413
return secLevel
14111414
}
1412-
authInfo := ac.transport.GetPeer().AuthInfo
1415+
authInfo := ac.transport.Peer().AuthInfo
14131416
if ci, ok := authInfo.(interface {
14141417
GetCommonAuthInfo() credentials.CommonAuthInfo
14151418
}); ok {

internal/transport/http2_client.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func NewHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
370370
})
371371
t.logger = prefixLoggerForClientTransport(t)
372372
// Add peer information to the http2client context.
373-
t.ctx = peer.NewContext(t.ctx, t.GetPeer())
373+
t.ctx = peer.NewContext(t.ctx, t.Peer())
374374

375375
if md, ok := addr.Metadata.(*metadata.MD); ok {
376376
t.md = *md
@@ -510,7 +510,7 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *ClientSt
510510
return s
511511
}
512512

513-
func (t *http2Client) GetPeer() *peer.Peer {
513+
func (t *http2Client) Peer() *peer.Peer {
514514
return &peer.Peer{
515515
Addr: t.remoteAddr,
516516
AuthInfo: t.authInfo, // Can be nil
@@ -742,7 +742,7 @@ func (e NewStreamError) Error() string {
742742
// NewStream creates a stream and registers it into the transport as "active"
743743
// streams. All non-nil errors returned will be *NewStreamError.
744744
func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*ClientStream, error) {
745-
ctx = peer.NewContext(ctx, t.GetPeer())
745+
ctx = peer.NewContext(ctx, t.Peer())
746746

747747
// ServerName field of the resolver returned address takes precedence over
748748
// Host field of CallHdr to determine the :authority header. This is because,
@@ -1807,10 +1807,6 @@ func (t *http2Client) socketMetrics() *channelz.EphemeralSocketMetrics {
18071807
}
18081808
}
18091809

1810-
func (t *http2Client) RemoteAddr() net.Addr { return t.remoteAddr }
1811-
1812-
func (t *http2Client) AuthInfo() credentials.AuthInfo { return t.authInfo }
1813-
18141810
func (t *http2Client) incrMsgSent() {
18151811
if channelz.IsOn() {
18161812
t.channelz.SocketMetrics.MessagesSent.Add(1)

internal/transport/transport.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,9 @@ type ClientTransport interface {
608608
// with a human readable string with debug info.
609609
GetGoAwayReason() (GoAwayReason, string)
610610

611-
// GetPeer return peer information that includes auth information and remote
612-
// network address
613-
GetPeer() *peer.Peer
611+
// Peer returns information about the peer associated with the Transport.
612+
// The returned information includes authentication and network address details.
613+
Peer() *peer.Peer
614614
}
615615

616616
// ServerTransport is the common interface for all gRPC server-side transport

stream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (a *csAttempt) getTransport() error {
484484
return err
485485
}
486486
if a.trInfo != nil {
487-
a.trInfo.firstLine.SetRemoteAddr(a.transport.GetPeer().Addr)
487+
a.trInfo.firstLine.SetRemoteAddr(a.transport.Peer().Addr)
488488
}
489489
if pick.blocked && a.statsHandler != nil {
490490
a.statsHandler.HandleRPC(a.ctx, &stats.DelayedPickComplete{})

0 commit comments

Comments
 (0)