mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 04:03:20 +00:00
Internal rename api.Minion -> api.Node
This commit is contained in:
@@ -45,7 +45,7 @@ type ConfigFactory struct {
|
||||
// a means to list all scheduled pods
|
||||
PodLister *storeToPodLister
|
||||
// a means to list all minions
|
||||
MinionLister *storeToMinionLister
|
||||
MinionLister *storeToNodeLister
|
||||
// map of strings to predicate functions to be used
|
||||
// to filter the minions for scheduling pods
|
||||
PredicateMap map[string]algorithm.FitPredicate
|
||||
@@ -61,7 +61,7 @@ func NewConfigFactory(client *client.Client) *ConfigFactory {
|
||||
Client: client,
|
||||
PodQueue: cache.NewFIFO(),
|
||||
PodLister: &storeToPodLister{cache.NewStore()},
|
||||
MinionLister: &storeToMinionLister{cache.NewStore()},
|
||||
MinionLister: &storeToNodeLister{cache.NewStore()},
|
||||
PredicateMap: make(map[string]algorithm.FitPredicate),
|
||||
PriorityMap: make(map[string]algorithm.PriorityConfig),
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (factory *ConfigFactory) Create(predicateKeys, priorityKeys []string) (*sch
|
||||
// Minions may be listed frequently, so provide a local up-to-date cache.
|
||||
if false {
|
||||
// Disable this code until minions support watches.
|
||||
cache.NewReflector(factory.createMinionLW(), &api.Minion{}, factory.MinionLister.Store).Run()
|
||||
cache.NewReflector(factory.createMinionLW(), &api.Node{}, factory.MinionLister.Store).Run()
|
||||
} else {
|
||||
cache.NewPoller(factory.pollMinions, 10*time.Second, factory.MinionLister.Store).Run()
|
||||
}
|
||||
@@ -255,12 +255,12 @@ func (factory *ConfigFactory) createMinionLW() *listWatch {
|
||||
|
||||
// pollMinions lists all minions and returns an enumerator for cache.Poller.
|
||||
func (factory *ConfigFactory) pollMinions() (cache.Enumerator, error) {
|
||||
list := &api.MinionList{}
|
||||
list := &api.NodeList{}
|
||||
err := factory.Client.Get().Path("minions").Do().Into(list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &minionEnumerator{list}, nil
|
||||
return &nodeEnumerator{list}, nil
|
||||
}
|
||||
|
||||
func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue *cache.FIFO) func(pod *api.Pod, err error) {
|
||||
@@ -288,22 +288,22 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
|
||||
}
|
||||
}
|
||||
|
||||
// storeToMinionLister turns a store into a minion lister. The store must contain (only) minions.
|
||||
type storeToMinionLister struct {
|
||||
// storeToNodeLister turns a store into a minion lister. The store must contain (only) minions.
|
||||
type storeToNodeLister struct {
|
||||
cache.Store
|
||||
}
|
||||
|
||||
func (s *storeToMinionLister) List() (machines api.MinionList, err error) {
|
||||
func (s *storeToNodeLister) List() (machines api.NodeList, err error) {
|
||||
for _, m := range s.Store.List() {
|
||||
machines.Items = append(machines.Items, *(m.(*api.Minion)))
|
||||
machines.Items = append(machines.Items, *(m.(*api.Node)))
|
||||
}
|
||||
return machines, nil
|
||||
}
|
||||
|
||||
// GetNodeInfo returns cached data for the minion 'id'.
|
||||
func (s *storeToMinionLister) GetNodeInfo(id string) (*api.Minion, error) {
|
||||
func (s *storeToNodeLister) GetNodeInfo(id string) (*api.Node, error) {
|
||||
if minion, ok := s.Get(id); ok {
|
||||
return minion.(*api.Minion), nil
|
||||
return minion.(*api.Node), nil
|
||||
}
|
||||
return nil, fmt.Errorf("minion '%v' is not in cache", id)
|
||||
}
|
||||
@@ -323,22 +323,22 @@ func (s *storeToPodLister) ListPods(selector labels.Selector) (pods []api.Pod, e
|
||||
return pods, nil
|
||||
}
|
||||
|
||||
// minionEnumerator allows a cache.Poller to enumerate items in an api.PodList
|
||||
type minionEnumerator struct {
|
||||
*api.MinionList
|
||||
// nodeEnumerator allows a cache.Poller to enumerate items in an api.NodeList
|
||||
type nodeEnumerator struct {
|
||||
*api.NodeList
|
||||
}
|
||||
|
||||
// Len returns the number of items in the pod list.
|
||||
func (me *minionEnumerator) Len() int {
|
||||
if me.MinionList == nil {
|
||||
// Len returns the number of items in the node list.
|
||||
func (ne *nodeEnumerator) Len() int {
|
||||
if ne.NodeList == nil {
|
||||
return 0
|
||||
}
|
||||
return len(me.Items)
|
||||
return len(ne.Items)
|
||||
}
|
||||
|
||||
// Get returns the item (and ID) with the particular index.
|
||||
func (me *minionEnumerator) Get(index int) (string, interface{}) {
|
||||
return me.Items[index].Name, &me.Items[index]
|
||||
func (ne *nodeEnumerator) Get(index int) (string, interface{}) {
|
||||
return ne.Items[index].Name, &ne.Items[index]
|
||||
}
|
||||
|
||||
type binder struct {
|
||||
|
@@ -145,10 +145,10 @@ func TestCreateWatches(t *testing.T) {
|
||||
|
||||
func TestPollMinions(t *testing.T) {
|
||||
table := []struct {
|
||||
minions []api.Minion
|
||||
minions []api.Node
|
||||
}{
|
||||
{
|
||||
minions: []api.Minion{
|
||||
minions: []api.Node{
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
@@ -156,7 +156,7 @@ func TestPollMinions(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, item := range table {
|
||||
ml := &api.MinionList{Items: item.minions}
|
||||
ml := &api.NodeList{Items: item.minions}
|
||||
handler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: runtime.EncodeOrDie(latest.Codec, ml),
|
||||
@@ -225,9 +225,9 @@ func TestStoreToMinionLister(t *testing.T) {
|
||||
store := cache.NewStore()
|
||||
ids := util.NewStringSet("foo", "bar", "baz")
|
||||
for id := range ids {
|
||||
store.Add(id, &api.Minion{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
store.Add(id, &api.Node{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
}
|
||||
sml := storeToMinionLister{store}
|
||||
sml := storeToNodeLister{store}
|
||||
|
||||
gotNodes, err := sml.List()
|
||||
if err != nil {
|
||||
@@ -273,14 +273,14 @@ func TestStoreToPodLister(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMinionEnumerator(t *testing.T) {
|
||||
testList := &api.MinionList{
|
||||
Items: []api.Minion{
|
||||
testList := &api.NodeList{
|
||||
Items: []api.Node{
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "baz"}},
|
||||
},
|
||||
}
|
||||
me := minionEnumerator{testList}
|
||||
me := nodeEnumerator{testList}
|
||||
|
||||
if e, a := 3, me.Len(); e != a {
|
||||
t.Fatalf("expected %v, got %v", e, a)
|
||||
|
@@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
|
||||
var gotBinding *api.Binding
|
||||
c := &Config{
|
||||
MinionLister: scheduler.FakeMinionLister(
|
||||
api.MinionList{Items: []api.Minion{{ObjectMeta: api.ObjectMeta{Name: "machine1"}}}},
|
||||
api.NodeList{Items: []api.Node{{ObjectMeta: api.ObjectMeta{Name: "machine1"}}}},
|
||||
),
|
||||
Algorithm: item.algo,
|
||||
Binder: fakeBinder{func(b *api.Binding) error {
|
||||
|
Reference in New Issue
Block a user