Add a system modeler to scheduler

So it can try to predict the effect its bindings will have.
This commit is contained in:
Daniel Smith
2015-03-12 17:28:00 -07:00
parent 6319f8a568
commit 992d78a32e
8 changed files with 377 additions and 26 deletions

View File

@@ -52,6 +52,15 @@ func (s *StoreToPodLister) List(selector labels.Selector) (pods []api.Pod, err e
return pods, nil
}
// Exists returns true if a pod matching the namespace/name of the given pod exists in the store.
func (s *StoreToPodLister) Exists(pod *api.Pod) (bool, error) {
_, exists, err := s.Store.Get(pod)
if err != nil {
return false, err
}
return exists, nil
}
// StoreToNodeLister makes a Store have the List method of the client.NodeInterface
// The Store must contain (only) Nodes.
type StoreToNodeLister struct {

View File

@@ -72,5 +72,21 @@ func TestStoreToPodLister(t *testing.T) {
t.Errorf("Expected %v, got %v", e, a)
continue
}
exists, err := spl.Exists(&api.Pod{ObjectMeta: api.ObjectMeta{Name: id}})
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !exists {
t.Errorf("exists returned false for %v", id)
}
}
exists, err := spl.Exists(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "qux"}})
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if exists {
t.Errorf("Unexpected pod exists")
}
}