Return all predicate failures instead of the first one

This commit is contained in:
Wei Huang
2019-12-06 15:48:05 -08:00
parent 2fbe432d23
commit a136108d2b
8 changed files with 291 additions and 94 deletions

View File

@@ -41,12 +41,17 @@ func PredicateResultToFrameworkStatus(reasons []predicates.PredicateFailureReaso
return nil
}
if r := predicates.UnresolvablePredicateExists(reasons); r != nil {
return framework.NewStatus(framework.UnschedulableAndUnresolvable, r.GetReason())
code := framework.Unschedulable
if predicates.UnresolvablePredicateExists(reasons) {
code = framework.UnschedulableAndUnresolvable
}
// We will just use the first reason.
return framework.NewStatus(framework.Unschedulable, reasons[0].GetReason())
// We will keep all failure reasons.
var failureReasons []string
for _, reason := range reasons {
failureReasons = append(failureReasons, reason.GetReason())
}
return framework.NewStatus(code, failureReasons...)
}
// ErrorToFrameworkStatus converts an error to a framework status.

View File

@@ -54,7 +54,7 @@ func TestPredicateResultToFrameworkStatus(t *testing.T) {
{
name: "Unschedulable and Unresolvable",
reasons: []predicates.PredicateFailureReason{predicates.ErrDiskConflict, predicates.ErrNodeSelectorNotMatch},
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "node(s) didn't match node selector"),
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "node(s) had no available disk", "node(s) didn't match node selector"),
},
}
for _, tt := range tests {