Skip to content

Commit

Permalink
Return original enpoints when all are evicted
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Jan 30, 2024
1 parent 1c54865 commit 97709ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pkg/utils/etcdutil/health_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ func (checker *healthChecker) filterEps(eps []string) []string {
}
pickedEps = append(pickedEps, ep)
}
// If the pickedEps is empty, it means all endpoints are evicted,
// to gain a better availability, just use the original picked endpoints.
if len(pickedEps) == 0 {
log.Warn("all etcd endpoints are evicted, use the picked endpoints directly",
zap.Strings("endpoints", eps),
zap.String("source", checker.source))
return eps
}
return pickedEps
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/etcdutil/health_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestPickEps(t *testing.T) {
},
},
map[string]int{"A": 0, "B": 1, "C": 1, "D": 0},
[]string{},
[]string{"B", "C"},
},
}
check(re, testCases)
Expand Down Expand Up @@ -318,7 +318,7 @@ func TestLatencyPick(t *testing.T) {
},
},
map[string]int{"A": 1, "B": 1, "C": 0},
[]string{},
[]string{"A", "B"},
},
}
check(re, testCases)
Expand Down

0 comments on commit 97709ba

Please sign in to comment.