FitError: return details of failure on each node
This commit is contained in:
		| @@ -17,6 +17,7 @@ limitations under the License. | |||||||
| package scheduler | package scheduler | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"math/rand" | 	"math/rand" | ||||||
| 	"sort" | 	"sort" | ||||||
| @@ -41,17 +42,15 @@ type FitError struct { | |||||||
|  |  | ||||||
| var ErrNoNodesAvailable = fmt.Errorf("no nodes available to schedule pods") | var ErrNoNodesAvailable = fmt.Errorf("no nodes available to schedule pods") | ||||||
|  |  | ||||||
| // implementation of the error interface | // Error returns detailed information of why the pod failed to fit on each node | ||||||
| func (f *FitError) Error() string { | func (f *FitError) Error() string { | ||||||
| 	var reason string | 	var buf bytes.Buffer | ||||||
| 	// We iterate over all nodes for logging purposes, even though we only return one reason from one node | 	buf.WriteString(fmt.Sprintf("pod (%s) failed to fit in any node\n", f.Pod.Name)) | ||||||
| 	for node, predicateList := range f.FailedPredicates { | 	for node, predicateList := range f.FailedPredicates { | ||||||
| 		glog.V(2).Infof("Failed to find fit for pod %v on node %s: %s", f.Pod.Name, node, strings.Join(predicateList.List(), ",")) | 		reason := fmt.Sprintf("fit failure on node (%s): %s\n", node, strings.Join(predicateList.List(), ",")) | ||||||
| 		if len(reason) == 0 { | 		buf.WriteString(reason) | ||||||
| 			reason, _ = predicateList.PopAny() |  | ||||||
| 	} | 	} | ||||||
| 	} | 	return buf.String() | ||||||
| 	return fmt.Sprintf("Failed for reason %s and possibly others", reason) |  | ||||||
| } | } | ||||||
|  |  | ||||||
| type genericScheduler struct { | type genericScheduler struct { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Hongchao Deng
					Hongchao Deng