mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
client/metadata: fix crasher caused by AllowStale = false (#16549)
Fixes #16517 Given a 3 Server cluster with at least 1 Client connected to Follower 1: If a NodeMeta.{Apply,Read} for the Client request is received by Follower 1 with `AllowStale = false` the Follower will forward the request to the Leader. The Leader, not being connected to the target Client, will forward the RPC to Follower 1. Follower 1, seeing AllowStale=false, will forward the request to the Leader. The Leader, not being connected to... well hoppefully you get the picture: an infinite loop occurs.
This commit is contained in:
@@ -143,15 +143,16 @@ func WaitForLeader(t testing.TB, rpc rpcFn) {
|
||||
})
|
||||
}
|
||||
|
||||
// WaitForLeaders blocks until each serverRPC knows the leader.
|
||||
func WaitForLeaders(t testing.TB, serverRPCs ...rpcFn) {
|
||||
// WaitForLeaders blocks until each rpcs knows the leader.
|
||||
func WaitForLeaders(t testing.TB, rpcs ...rpcFn) string {
|
||||
t.Helper()
|
||||
|
||||
for i := 0; i < len(serverRPCs); i++ {
|
||||
var leader string
|
||||
for i := 0; i < len(rpcs); i++ {
|
||||
ok := func() (bool, error) {
|
||||
leader = ""
|
||||
args := &structs.GenericRequest{}
|
||||
var leader string
|
||||
err := serverRPCs[i]("Status.Leader", args, &leader)
|
||||
err := rpcs[i]("Status.Leader", args, &leader)
|
||||
return leader != "", err
|
||||
}
|
||||
must.Wait(t, wait.InitialSuccess(
|
||||
@@ -160,6 +161,8 @@ func WaitForLeaders(t testing.TB, serverRPCs ...rpcFn) {
|
||||
wait.Gap(1*time.Second),
|
||||
))
|
||||
}
|
||||
|
||||
return leader
|
||||
}
|
||||
|
||||
// WaitForClient blocks until the client can be found
|
||||
|
||||
Reference in New Issue
Block a user