@@ -279,18 +279,17 @@ func (fbb *FactorBasedBalance) BackendsToBalance(backends []policy.BackendCtx) (
279279 if score1 >= score2 {
280280 // The factors with higher priorities are ordered, so this factor shouldn't violate them.
281281 // E.g. if the CPU usage of A is higher than B, don't migrate from B to A even if A is preferred in location.
282- var advice BalanceAdvice
283- var fields []zap.Field
284- advice , balanceCount , fields = factor .BalanceCount (scoredBackends [i ], scoredBackends [0 ])
282+ advice , count , fields := factor .BalanceCount (scoredBackends [i ], scoredBackends [0 ])
285283 if advice == AdviceNegtive {
286284 // If the factor will be unbalanced after migration, skip the rest factors.
287285 // E.g. if the CPU usage of A will be much higher than B after migration,
288286 // don't migrate from B to A even if A is preferred in location.
289287 break
290288 }
291289 logFields = append (logFields , fields ... )
292- if score1 > score2 && advice == AdvicePositive && balanceCount > 0.0001 {
290+ if score1 > score2 && advice == AdvicePositive && count > 0.0001 {
293291 from , to = scoredBackends [i ].BackendCtx , scoredBackends [0 ].BackendCtx
292+ balanceCount = count
294293 reason = factor .Name ()
295294 logFields = append (logFields , zap .String ("factor" , reason ),
296295 zap .String ("from_total_score" , strconv .FormatUint (scoredBackends [i ].scoreBits , 16 )),
0 commit comments