mirror of
https://github.com/alibaba/higress.git
synced 2026-07-24 05:10:34 +08:00
fix: fix rand.init(0) panic in failover.go (#4112)
This commit is contained in:
@@ -649,6 +649,10 @@ func (c *ProviderConfig) GetGlobalRandomToken() string {
|
||||
count := len(apiTokens)
|
||||
switch count {
|
||||
case 0:
|
||||
if len(unavailableApiTokens) == 0 {
|
||||
log.Warn("all tokens are unavailable and no unavailable tokens recorded")
|
||||
return ""
|
||||
}
|
||||
log.Warn("all tokens are unavailable, will use random one of the unavailable tokens")
|
||||
return unavailableApiTokens[rand.Intn(len(unavailableApiTokens))]
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user