mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Merge pull request #19906 from hongchaodeng/fiterror
Auto commit by PR queue bot
This commit is contained in:
commit
2a83f5d5c7
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user