mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 03:45:41 +03:00
Fix other instances of blocking queries
This commit is contained in:
@@ -767,7 +767,7 @@ func (w *deploymentWatcher) getAllocsImpl(ws memdb.WatchSet, state *state.StateS
|
||||
}
|
||||
}
|
||||
|
||||
// Use the last index that affected the jobs table
|
||||
// Use the last index that affected the allocs table
|
||||
if len(stubs) == 0 {
|
||||
index, err := state.Index("allocs")
|
||||
if err != nil {
|
||||
@@ -806,7 +806,7 @@ func (w *deploymentWatcher) jobEvalStatus() (latestIndex uint64, blocked bool, e
|
||||
|
||||
var max uint64
|
||||
for _, eval := range evals {
|
||||
// If we ahve a blocked eval, then we do not care what the index is
|
||||
// If we have a blocked eval, then we do not care what the index is
|
||||
// since we will not need to make a new eval.
|
||||
if eval.ShouldBlock() {
|
||||
return 0, true, nil
|
||||
|
||||
@@ -447,6 +447,7 @@ func (w *drainingJobWatcher) getJobAllocsImpl(ws memdb.WatchSet, state *state.St
|
||||
}
|
||||
|
||||
// Capture the allocs for each draining job.
|
||||
var maxIndex uint64 = 0
|
||||
resp := make(map[structs.NamespacedID][]*structs.Allocation, l)
|
||||
for jns := range draining {
|
||||
allocs, err := state.AllocsByJob(ws, jns.Namespace, jns.ID, false)
|
||||
@@ -455,6 +456,17 @@ func (w *drainingJobWatcher) getJobAllocsImpl(ws memdb.WatchSet, state *state.St
|
||||
}
|
||||
|
||||
resp[jns] = allocs
|
||||
for _, alloc := range allocs {
|
||||
if maxIndex < alloc.ModifyIndex {
|
||||
maxIndex = alloc.ModifyIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prefer using the actual max index of affected allocs since it means less
|
||||
// unblocking
|
||||
if maxIndex != 0 {
|
||||
index = maxIndex
|
||||
}
|
||||
|
||||
return resp, index, nil
|
||||
|
||||
@@ -235,6 +235,7 @@ func (w *nodeDrainWatcher) getNodesImpl(ws memdb.WatchSet, state *state.StateSto
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
var maxIndex uint64 = 0
|
||||
resp := make(map[string]*structs.Node, 64)
|
||||
for {
|
||||
raw := iter.Next()
|
||||
@@ -244,6 +245,15 @@ func (w *nodeDrainWatcher) getNodesImpl(ws memdb.WatchSet, state *state.StateSto
|
||||
|
||||
node := raw.(*structs.Node)
|
||||
resp[node.ID] = node
|
||||
if maxIndex < node.ModifyIndex {
|
||||
maxIndex = node.ModifyIndex
|
||||
}
|
||||
}
|
||||
|
||||
// Prefer using the actual max index of affected nodes since it means less
|
||||
// unblocking
|
||||
if maxIndex != 0 {
|
||||
index = maxIndex
|
||||
}
|
||||
|
||||
return resp, index, nil
|
||||
|
||||
Reference in New Issue
Block a user