Merge pull request #1736 from brendandburns/scheduler

Switch away from the static node info
This commit is contained in:
Dawn Chen 2014-10-10 15:01:09 -07:00
commit 135d187942
3 changed files with 17 additions and 7 deletions

View File

@ -291,3 +291,9 @@ func (c *Client) ListMinions() (result *api.MinionList, err error) {
err = c.Get().Path("minions").Do().Into(result) err = c.Get().Path("minions").Do().Into(result)
return return
} }
func (c *Client) GetMinion(id string) (result *api.Minion, err error) {
result = &api.Minion{}
err = c.Get().Path("minions").Path(id).Do().Into(result)
return
}

View File

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/resources" "github.com/GoogleCloudPlatform/kubernetes/pkg/resources"
"github.com/golang/glog" "github.com/golang/glog"
@ -39,7 +40,15 @@ func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) {
return &nodes.Items[ix], nil return &nodes.Items[ix], nil
} }
} }
return nil, fmt.Errorf("failed to find node: %s", nodeID) return nil, fmt.Errorf("failed to find node: %s, %#v", nodeID, nodes)
}
type ClientNodeInfo struct {
*client.Client
}
func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) {
return nodes.GetMinion(nodeID)
} }
type ResourceFit struct { type ResourceFit struct {

View File

@ -64,17 +64,12 @@ func (factory *ConfigFactory) Create() (*scheduler.Config, error) {
r := rand.New(rand.NewSource(time.Now().UnixNano())) r := rand.New(rand.NewSource(time.Now().UnixNano()))
// TODO: remove this construction-time listing.
nodes, err := factory.Client.ListMinions()
if err != nil {
return nil, err
}
algo := algorithm.NewGenericScheduler( algo := algorithm.NewGenericScheduler(
[]algorithm.FitPredicate{ []algorithm.FitPredicate{
// Fit is defined based on the absence of port conflicts. // Fit is defined based on the absence of port conflicts.
algorithm.PodFitsPorts, algorithm.PodFitsPorts,
// Fit is determined by resource availability // Fit is determined by resource availability
algorithm.NewResourceFitPredicate(algorithm.StaticNodeInfo{nodes}), algorithm.NewResourceFitPredicate(algorithm.ClientNodeInfo{factory.Client}),
}, },
// Prioritize nodes by least requested utilization. // Prioritize nodes by least requested utilization.
algorithm.LeastRequestedPriority, algorithm.LeastRequestedPriority,