Fix progressMade in scheduler
This commit is contained in:
parent
64ecbb7cc2
commit
e42720c2f5
|
@ -238,8 +238,8 @@ func retryMax(max int, cb func() (bool, error), reset func() bool) error {
|
||||||
// progressMade checks to see if the plan result made allocations or updates.
|
// progressMade checks to see if the plan result made allocations or updates.
|
||||||
// If the result is nil, false is returned.
|
// If the result is nil, false is returned.
|
||||||
func progressMade(result *structs.PlanResult) bool {
|
func progressMade(result *structs.PlanResult) bool {
|
||||||
return result != nil && len(result.NodeUpdate) != 0 &&
|
return result != nil && (len(result.NodeUpdate) != 0 ||
|
||||||
len(result.NodeAllocation) != 0
|
len(result.NodeAllocation) != 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// taintedNodes is used to scan the allocations and then check if the
|
// taintedNodes is used to scan the allocations and then check if the
|
||||||
|
|
|
@ -736,3 +736,23 @@ func TestInitTaskState(t *testing.T) {
|
||||||
t.Fatal("Expected and actual not equal")
|
t.Fatal("Expected and actual not equal")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestProgressMade(t *testing.T) {
|
||||||
|
noopPlan := &structs.PlanResult{}
|
||||||
|
if progressMade(nil) || progressMade(noopPlan) {
|
||||||
|
t.Fatal("no progress plan marked as making progress")
|
||||||
|
}
|
||||||
|
|
||||||
|
m := map[string][]*structs.Allocation{
|
||||||
|
"foo": []*structs.Allocation{mock.Alloc()},
|
||||||
|
}
|
||||||
|
both := &structs.PlanResult{
|
||||||
|
NodeAllocation: m,
|
||||||
|
NodeUpdate: m,
|
||||||
|
}
|
||||||
|
update := &structs.PlanResult{ NodeUpdate: m }
|
||||||
|
alloc := &structs.PlanResult{ NodeAllocation: m }
|
||||||
|
if !(progressMade(both) && progressMade(update) && progressMade(alloc)) {
|
||||||
|
t.Fatal("bad")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue