xds/internal/balancer/outlierdetection: Change string to String (#6222)

This commit is contained in:
Zach Reyes 2023-04-26 12:56:27 -04:00 committed by GitHub
parent de11139ae6
commit 497436cef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -828,8 +828,7 @@ func (b *outlierDetectionBalancer) successRateAlgorithm() {
successRate := float64(bucket.numSuccesses) / float64(bucket.numSuccesses+bucket.numFailures) successRate := float64(bucket.numSuccesses) / float64(bucket.numSuccesses+bucket.numFailures)
requiredSuccessRate := mean - stddev*(float64(ejectionCfg.StdevFactor)/1000) requiredSuccessRate := mean - stddev*(float64(ejectionCfg.StdevFactor)/1000)
if successRate < requiredSuccessRate { if successRate < requiredSuccessRate {
channelz.Infof(logger, b.channelzParentID, "SuccessRate algorithm detected outlier: %s. Parameters: successRate=%f, mean=%f, stddev=%f, requiredSuccessRate=%f", channelz.Infof(logger, b.channelzParentID, "SuccessRate algorithm detected outlier: %s. Parameters: successRate=%f, mean=%f, stddev=%f, requiredSuccessRate=%f", addrInfo, successRate, mean, stddev, requiredSuccessRate)
addrInfo.string(), successRate, mean, stddev, requiredSuccessRate)
if uint32(grpcrand.Int31n(100)) < ejectionCfg.EnforcementPercentage { if uint32(grpcrand.Int31n(100)) < ejectionCfg.EnforcementPercentage {
b.ejectAddress(addrInfo) b.ejectAddress(addrInfo)
} }
@ -856,8 +855,7 @@ func (b *outlierDetectionBalancer) failurePercentageAlgorithm() {
} }
failurePercentage := (float64(bucket.numFailures) / float64(bucket.numSuccesses+bucket.numFailures)) * 100 failurePercentage := (float64(bucket.numFailures) / float64(bucket.numSuccesses+bucket.numFailures)) * 100
if failurePercentage > float64(b.cfg.FailurePercentageEjection.Threshold) { if failurePercentage > float64(b.cfg.FailurePercentageEjection.Threshold) {
channelz.Infof(logger, b.channelzParentID, "FailurePercentage algorithm detected outlier: %s, failurePercentage=%f", channelz.Infof(logger, b.channelzParentID, "FailurePercentage algorithm detected outlier: %s, failurePercentage=%f", addrInfo, failurePercentage)
addrInfo.string(), failurePercentage)
if uint32(grpcrand.Int31n(100)) < ejectionCfg.EnforcementPercentage { if uint32(grpcrand.Int31n(100)) < ejectionCfg.EnforcementPercentage {
b.ejectAddress(addrInfo) b.ejectAddress(addrInfo)
} }
@ -872,7 +870,7 @@ func (b *outlierDetectionBalancer) ejectAddress(addrInfo *addressInfo) {
addrInfo.ejectionTimeMultiplier++ addrInfo.ejectionTimeMultiplier++
for _, sbw := range addrInfo.sws { for _, sbw := range addrInfo.sws {
sbw.eject() sbw.eject()
channelz.Infof(logger, b.channelzParentID, "Subchannel ejected: %s", sbw.string()) channelz.Infof(logger, b.channelzParentID, "Subchannel ejected: %s", sbw)
} }
} }
@ -883,7 +881,7 @@ func (b *outlierDetectionBalancer) unejectAddress(addrInfo *addressInfo) {
addrInfo.latestEjectionTimestamp = time.Time{} addrInfo.latestEjectionTimestamp = time.Time{}
for _, sbw := range addrInfo.sws { for _, sbw := range addrInfo.sws {
sbw.uneject() sbw.uneject()
channelz.Infof(logger, b.channelzParentID, "Subchannel unejected: %s", sbw.string()) channelz.Infof(logger, b.channelzParentID, "Subchannel unejected: %s", sbw)
} }
} }
@ -908,11 +906,11 @@ type addressInfo struct {
sws []*subConnWrapper sws []*subConnWrapper
} }
func (a *addressInfo) string() string { func (a *addressInfo) String() string {
var res strings.Builder var res strings.Builder
res.WriteString("[") res.WriteString("[")
for _, sw := range a.sws { for _, sw := range a.sws {
res.WriteString(sw.string()) res.WriteString(sw.String())
} }
res.WriteString("]") res.WriteString("]")
return res.String() return res.String()

View File

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