mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 20:57:20 +00:00
Add a least-requested priority function
This commit is contained in:
@@ -202,9 +202,9 @@ type storeToMinionLister struct {
|
||||
cache.Store
|
||||
}
|
||||
|
||||
func (s *storeToMinionLister) List() (machines []string, err error) {
|
||||
func (s *storeToMinionLister) List() (machines api.MinionList, err error) {
|
||||
for _, m := range s.Store.List() {
|
||||
machines = append(machines, m.(*api.Minion).ID)
|
||||
machines.Items = append(machines.Items, *(m.(*api.Minion)))
|
||||
}
|
||||
return machines, nil
|
||||
}
|
||||
|
@@ -223,10 +223,14 @@ func TestStoreToMinionLister(t *testing.T) {
|
||||
}
|
||||
sml := storeToMinionLister{store}
|
||||
|
||||
got, err := sml.List()
|
||||
gotNodes, err := sml.List()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
got := make([]string, len(gotNodes.Items))
|
||||
for ix := range gotNodes.Items {
|
||||
got[ix] = gotNodes.Items[ix].ID
|
||||
}
|
||||
if !ids.HasAll(got...) || len(got) != len(ids) {
|
||||
t.Errorf("Expected %v, got %v", ids, got)
|
||||
}
|
||||
|
@@ -81,8 +81,10 @@ func TestScheduler(t *testing.T) {
|
||||
var gotPod *api.Pod
|
||||
var gotBinding *api.Binding
|
||||
c := &Config{
|
||||
MinionLister: scheduler.FakeMinionLister{"machine1"},
|
||||
Algorithm: item.algo,
|
||||
MinionLister: scheduler.FakeMinionLister(
|
||||
api.MinionList{Items: []api.Minion{{TypeMeta: api.TypeMeta{ID: "machine1"}}}},
|
||||
),
|
||||
Algorithm: item.algo,
|
||||
Binder: fakeBinder{func(b *api.Binding) error {
|
||||
gotBinding = b
|
||||
return item.injectBindError
|
||||
|
Reference in New Issue
Block a user