Skip to content

Commit

Permalink
xds/internal/balancer/outlierdetection: Change string to String (#6222)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq authored Apr 26, 2023
1 parent de11139 commit 497436c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions xds/internal/balancer/outlierdetection/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,8 +828,7 @@ func (b *outlierDetectionBalancer) successRateAlgorithm() {
successRate := float64(bucket.numSuccesses) / float64(bucket.numSuccesses+bucket.numFailures)
requiredSuccessRate := mean - stddev*(float64(ejectionCfg.StdevFactor)/1000)
if successRate < requiredSuccessRate {
channelz.Infof(logger, b.channelzParentID, "SuccessRate algorithm detected outlier: %s. Parameters: successRate=%f, mean=%f, stddev=%f, requiredSuccessRate=%f",
addrInfo.string(), successRate, mean, stddev, requiredSuccessRate)
channelz.Infof(logger, b.channelzParentID, "SuccessRate algorithm detected outlier: %s. Parameters: successRate=%f, mean=%f, stddev=%f, requiredSuccessRate=%f", addrInfo, successRate, mean, stddev, requiredSuccessRate)
if uint32(grpcrand.Int31n(100)) < ejectionCfg.EnforcementPercentage {
b.ejectAddress(addrInfo)
}
Expand All @@ -856,8 +855,7 @@ func (b *outlierDetectionBalancer) failurePercentageAlgorithm() {
}
failurePercentage := (float64(bucket.numFailures) / float64(bucket.numSuccesses+bucket.numFailures)) * 100
if failurePercentage > float64(b.cfg.FailurePercentageEjection.Threshold) {
channelz.Infof(logger, b.channelzParentID, "FailurePercentage algorithm detected outlier: %s, failurePercentage=%f",
addrInfo.string(), failurePercentage)
channelz.Infof(logger, b.channelzParentID, "FailurePercentage algorithm detected outlier: %s, failurePercentage=%f", addrInfo, failurePercentage)
if uint32(grpcrand.Int31n(100)) < ejectionCfg.EnforcementPercentage {
b.ejectAddress(addrInfo)
}
Expand All @@ -872,7 +870,7 @@ func (b *outlierDetectionBalancer) ejectAddress(addrInfo *addressInfo) {
addrInfo.ejectionTimeMultiplier++
for _, sbw := range addrInfo.sws {
sbw.eject()
channelz.Infof(logger, b.channelzParentID, "Subchannel ejected: %s", sbw.string())
channelz.Infof(logger, b.channelzParentID, "Subchannel ejected: %s", sbw)
}

}
Expand All @@ -883,7 +881,7 @@ func (b *outlierDetectionBalancer) unejectAddress(addrInfo *addressInfo) {
addrInfo.latestEjectionTimestamp = time.Time{}
for _, sbw := range addrInfo.sws {
sbw.uneject()
channelz.Infof(logger, b.channelzParentID, "Subchannel unejected: %s", sbw.string())
channelz.Infof(logger, b.channelzParentID, "Subchannel unejected: %s", sbw)
}
}

Expand All @@ -908,11 +906,11 @@ type addressInfo struct {
sws []*subConnWrapper
}

func (a *addressInfo) string() string {
func (a *addressInfo) String() string {
var res strings.Builder
res.WriteString("[")
for _, sw := range a.sws {
res.WriteString(sw.string())
res.WriteString(sw.String())
}
res.WriteString("]")
return res.String()
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/outlierdetection/subconn_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ func (scw *subConnWrapper) uneject() {
})
}

func (scw *subConnWrapper) string() string {
func (scw *subConnWrapper) String() string {
return fmt.Sprintf("%+v", scw.addresses)
}

0 comments on commit 497436c

Please sign in to comment.