Commit 2ee074f9 authored by brendandburns's avatar brendandburns

Merge pull request #410 from nyaxt/lint_scheduler

Add comments to pkg/scheduler/ to pass golint
parents 93d45c1e bf137c38
......@@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
// FirstFitScheduler is a Scheduler interface implementation which uses first fit algorithm.
type FirstFitScheduler struct {
podLister PodLister
// TODO: *rand.Rand is *not* threadsafe
......@@ -48,6 +49,7 @@ func (s *FirstFitScheduler) containsPort(pod api.Pod, port api.Port) bool {
return false
}
// Schedule schedules a pod on the first machine which matches its requirement.
func (s *FirstFitScheduler) Schedule(pod api.Pod, minionLister MinionLister) (string, error) {
machines, err := minionLister.List()
if err != nil {
......@@ -80,7 +82,6 @@ func (s *FirstFitScheduler) Schedule(pod api.Pod, minionLister MinionLister) (st
}
if len(machineOptions) == 0 {
return "", fmt.Errorf("failed to find fit for %#v", pod)
} else {
return machineOptions[s.random.Int()%len(machineOptions)], nil
}
return machineOptions[s.random.Int()%len(machineOptions)], nil
}
......@@ -21,27 +21,28 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
// Anything that can list minions for a scheduler.
// MinionLister interface represents anything that can list minions for a scheduler.
type MinionLister interface {
List() (machines []string, err error)
}
// Make a MinionLister from a []string
// FakeMinionLister implements MinionLister on a []string for test purposes.
type FakeMinionLister []string
// Returns minions as a []string
// List returns minions as a []string
func (f FakeMinionLister) List() ([]string, error) {
return []string(f), nil
}
// Anything that can list pods for a scheduler
// PodLister interface represents anything that can list pods for a scheduler
type PodLister interface {
ListPods(labels.Selector) ([]api.Pod, error)
}
// Make a MinionLister from an []api.Pods
// FakePodLister implements PodLister on an []api.Pods for test purposes.
type FakePodLister []api.Pod
// ListPods returns []api.Pod matching a query.
func (f FakePodLister) ListPods(s labels.Selector) (selected []api.Pod, err error) {
for _, pod := range f {
if s.Matches(labels.Set(pod.Labels)) {
......
......@@ -22,7 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
)
// RandomScheduler choses machines uniformly at random.
// RandomScheduler chooses machines uniformly at random.
type RandomScheduler struct {
// TODO: rand.Rand is *NOT* thread safe.
random *rand.Rand
......@@ -34,6 +34,7 @@ func MakeRandomScheduler(random *rand.Rand) Scheduler {
}
}
// Schedule schedules a given pod to a random machine.
func (s *RandomScheduler) Schedule(pod api.Pod, minionLister MinionLister) (string, error) {
machines, err := minionLister.List()
if err != nil {
......
......@@ -31,6 +31,7 @@ func MakeRoundRobinScheduler() Scheduler {
}
}
// Schedule schedules a pod on the machine next to the last scheduled machine.
func (s *RoundRobinScheduler) Schedule(pod api.Pod, minionLister MinionLister) (string, error) {
machines, err := minionLister.List()
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment