Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: prevent using stale allocs #18601

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2359,7 +2359,7 @@ OUTER:
//
// For full context, please see https://github.com/hashicorp/nomad/issues/18267
if resp.Index <= req.MinQueryIndex {
c.logger.Debug("Received stale allocation information. Retrying.",
c.logger.Debug("received stale allocation information; retrying",
"index", resp.Index, "min_index", req.MinQueryIndex)
continue OUTER
}
Expand Down Expand Up @@ -2419,6 +2419,24 @@ OUTER:
}
}

// It is possible that Alloc.GetAllocs hits a different server than
// Node.GetClientAllocs which returns older results.
if allocsResp.Index <= allocsReq.MinQueryIndex {
tgross marked this conversation as resolved.
Show resolved Hide resolved
retry := c.retryIntv(getAllocRetryIntv)
c.logger.Warn("failed to retrieve updated allocs; retrying",
"req_index", allocsReq.MinQueryIndex,
"resp_index", allocsResp.Index,
"num_allocs", len(pull),
"wait", retry,
)
select {
case <-time.After(retry):
continue
case <-c.shutdownCh:
return
}
}

// Ensure that we received all the allocations we wanted
pulledAllocs = make(map[string]*structs.Allocation, len(allocsResp.Allocs))
for _, alloc := range allocsResp.Allocs {
Expand Down
2 changes: 1 addition & 1 deletion nomad/alloc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (a *Alloc) GetAllocs(args *structs.AllocsGetRequest,
reply.Allocs = allocs
reply.Index = maxIndex
} else {
// Use the last index that affected the nodes table
// Use the last index that affected the allocs table
index, err := state.Index("allocs")
if err != nil {
return err
Expand Down
Loading