insufficient resource error: details of failure in failedPredicateMap
This commit is contained in:
@@ -18,23 +18,32 @@ package predicates
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
ErrExceededMaxPodNumber = newInsufficientResourceError("PodCount")
|
||||
ErrInsufficientFreeCPU = newInsufficientResourceError("CPU")
|
||||
ErrInsufficientFreeMemory = newInsufficientResourceError("Memory")
|
||||
const (
|
||||
podCountResourceName string = "PodCount"
|
||||
cpuResourceName string = "CPU"
|
||||
memoryResoureceName string = "Memory"
|
||||
)
|
||||
|
||||
// InsufficientResourceError is an error type that indicates what kind of resource limit is
|
||||
// hit and caused the unfitting failure.
|
||||
type InsufficientResourceError struct {
|
||||
// ResourceName tells the name of the resource that is insufficient
|
||||
ResourceName string
|
||||
// resourceName is the name of the resource that is insufficient
|
||||
resourceName string
|
||||
requested int64
|
||||
used int64
|
||||
capacity int64
|
||||
}
|
||||
|
||||
func newInsufficientResourceError(resourceName string) *InsufficientResourceError {
|
||||
return &InsufficientResourceError{resourceName}
|
||||
func newInsufficientResourceError(resourceName string, requested, used, capacity int64) *InsufficientResourceError {
|
||||
return &InsufficientResourceError{
|
||||
resourceName: resourceName,
|
||||
requested: requested,
|
||||
used: used,
|
||||
capacity: capacity,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *InsufficientResourceError) Error() string {
|
||||
return fmt.Sprintf("Node didn't have enough resource: %s", e.ResourceName)
|
||||
return fmt.Sprintf("Node didn't have enough resource: %s, requested: %d, used: %d, capacity: %d",
|
||||
e.resourceName, e.requested, e.used, e.capacity)
|
||||
}
|
||||
|
Reference in New Issue
Block a user