fixed typos
This commit is contained in:
parent
4158f7f946
commit
349afa60e1
1 changed files with 5 additions and 3 deletions
8
node.go
8
node.go
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -71,13 +72,14 @@ func (nl *NodeList) getServerList(ctx context.Context, c *NodeClient) (err error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
type weightSorter NodeList
|
type weightSorter NodeList
|
||||||
|
|
||||||
func (s weightSorter) Len() int { return len(s) }
|
func (s weightSorter) Len() int { return len(s) }
|
||||||
func (s weightSorter) Less(i, j int) bool {
|
func (s weightSorter) Less(i, j int) bool {
|
||||||
return s.weight() < s[j].weight()
|
return s[i].weight() < s[j].weight()
|
||||||
}
|
}
|
||||||
func (s weightSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
func (s weightSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
|
||||||
|
|
@ -107,7 +109,7 @@ func FilterNodeName(name string) NodeFilter {
|
||||||
func FilterMaxCores(cores int64) NodeFilter {
|
func FilterMaxCores(cores int64) NodeFilter {
|
||||||
return func(nl *NodeList) {
|
return func(nl *NodeList) {
|
||||||
for i, n := range *nl {
|
for i, n := range *nl {
|
||||||
if cores > n.MaxCPU {
|
if cores > int64(n.MaxCPU) {
|
||||||
nl.remove(i)
|
nl.remove(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -170,7 +172,7 @@ func (c *NodeClient) Schedule(ctx context.Context, filters ...NodeFilter) (n *No
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nl.filter(filters)
|
nl.filter(filters...)
|
||||||
nl.sortByWeight()
|
nl.sortByWeight()
|
||||||
if len(nl) == 0 {
|
if len(nl) == 0 {
|
||||||
err = ErrUnschedulable
|
err = ErrUnschedulable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue