Capacity report (#18)
- pull capacity report via /offers endpoint. - calculate how many tasks (with resource and constraints) can be fit in the cluster. examples of using the above 2 features are in aurora-scheduler/australis#33
This commit is contained in:
parent
5d0998647a
commit
4258634ccf
5 changed files with 1012 additions and 10 deletions
20
util.go
20
util.go
|
@ -104,3 +104,23 @@ func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int {
|
|||
}
|
||||
return batchCount
|
||||
}
|
||||
|
||||
func ResourcesToMap(resources []*aurora.Resource) map[string]float64 {
|
||||
result := map[string]float64{}
|
||||
|
||||
for _, resource := range resources {
|
||||
if resource.NumCpus != nil {
|
||||
result["cpus"] += *resource.NumCpus
|
||||
} else if resource.RamMb != nil {
|
||||
result["mem"] += float64(*resource.RamMb)
|
||||
} else if resource.DiskMb != nil {
|
||||
result["disk"] += float64(*resource.DiskMb)
|
||||
} else if resource.NamedPort != nil {
|
||||
result["ports"]++
|
||||
} else if resource.NumGpus != nil {
|
||||
result["gpus"] += float64(*resource.NumGpus)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue