mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 04:32:37 +00:00
Rename ID -> Name
This commit is contained in:
@@ -93,7 +93,7 @@ func (factory *ConfigFactory) Create() *scheduler.Config {
|
||||
glog.V(2).Infof("About to try and schedule pod %v\n"+
|
||||
"\tknown minions: %v\n"+
|
||||
"\tknown scheduled pods: %v\n",
|
||||
pod.ID, minionCache.Contains(), podCache.Contains())
|
||||
pod.Name, minionCache.Contains(), podCache.Contains())
|
||||
return pod
|
||||
},
|
||||
Error: factory.makeDefaultErrorFunc(&podBackoff, podQueue),
|
||||
@@ -174,13 +174,13 @@ func (factory *ConfigFactory) pollMinions() (cache.Enumerator, error) {
|
||||
|
||||
func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue *cache.FIFO) func(pod *api.Pod, err error) {
|
||||
return func(pod *api.Pod, err error) {
|
||||
glog.Errorf("Error scheduling %v: %v; retrying", pod.ID, err)
|
||||
glog.Errorf("Error scheduling %v: %v; retrying", pod.Name, err)
|
||||
backoff.gc()
|
||||
// Retry asynchronously.
|
||||
// Note that this is extremely rudimentary and we need a more real error handling path.
|
||||
go func() {
|
||||
defer util.HandleCrash()
|
||||
podID := pod.ID
|
||||
podID := pod.Name
|
||||
backoff.wait(podID)
|
||||
// Get the pod again; it may have changed/been scheduled already.
|
||||
pod = &api.Pod{}
|
||||
@@ -191,7 +191,7 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
|
||||
return
|
||||
}
|
||||
if pod.DesiredState.Host == "" {
|
||||
podQueue.Add(pod.ID, pod)
|
||||
podQueue.Add(pod.Name, pod)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -247,7 +247,7 @@ func (me *minionEnumerator) Len() int {
|
||||
|
||||
// Get returns the item (and ID) with the particular index.
|
||||
func (me *minionEnumerator) Get(index int) (string, interface{}) {
|
||||
return me.Items[index].ID, &me.Items[index]
|
||||
return me.Items[index].Name, &me.Items[index]
|
||||
}
|
||||
|
||||
type binder struct {
|
||||
|
@@ -145,8 +145,8 @@ func TestPollMinions(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
minions: []api.Minion{
|
||||
{TypeMeta: api.TypeMeta{ID: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "bar"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func TestPollMinions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDefaultErrorFunc(t *testing.T) {
|
||||
testPod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
|
||||
testPod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
handler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: runtime.EncodeOrDie(latest.Codec, testPod),
|
||||
@@ -219,7 +219,7 @@ func TestStoreToMinionLister(t *testing.T) {
|
||||
store := cache.NewStore()
|
||||
ids := util.NewStringSet("foo", "bar", "baz")
|
||||
for id := range ids {
|
||||
store.Add(id, &api.Minion{TypeMeta: api.TypeMeta{ID: id}})
|
||||
store.Add(id, &api.Minion{TypeMeta: api.TypeMeta{Name: id}})
|
||||
}
|
||||
sml := storeToMinionLister{store}
|
||||
|
||||
@@ -229,7 +229,7 @@ func TestStoreToMinionLister(t *testing.T) {
|
||||
}
|
||||
got := make([]string, len(gotNodes.Items))
|
||||
for ix := range gotNodes.Items {
|
||||
got[ix] = gotNodes.Items[ix].ID
|
||||
got[ix] = gotNodes.Items[ix].Name
|
||||
}
|
||||
if !ids.HasAll(got...) || len(got) != len(ids) {
|
||||
t.Errorf("Expected %v, got %v", ids, got)
|
||||
@@ -241,7 +241,7 @@ func TestStoreToPodLister(t *testing.T) {
|
||||
ids := []string{"foo", "bar", "baz"}
|
||||
for _, id := range ids {
|
||||
store.Add(id, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: id},
|
||||
TypeMeta: api.TypeMeta{Name: id},
|
||||
Labels: map[string]string{"name": id},
|
||||
})
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func TestStoreToPodLister(t *testing.T) {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
continue
|
||||
}
|
||||
if e, a := id, got[0].ID; e != a {
|
||||
if e, a := id, got[0].Name; e != a {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
continue
|
||||
}
|
||||
@@ -267,9 +267,9 @@ func TestStoreToPodLister(t *testing.T) {
|
||||
func TestMinionEnumerator(t *testing.T) {
|
||||
testList := &api.MinionList{
|
||||
Items: []api.Minion{
|
||||
{TypeMeta: api.TypeMeta{ID: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "bar"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "baz"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "baz"}},
|
||||
},
|
||||
}
|
||||
me := minionEnumerator{testList}
|
||||
@@ -279,7 +279,7 @@ func TestMinionEnumerator(t *testing.T) {
|
||||
}
|
||||
for i := range testList.Items {
|
||||
gotID, gotObj := me.Get(i)
|
||||
if e, a := testList.Items[i].ID, gotID; e != a {
|
||||
if e, a := testList.Items[i].Name, gotID; e != a {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
if e, a := &testList.Items[i], gotObj; !reflect.DeepEqual(e, a) {
|
||||
|
@@ -74,7 +74,7 @@ func (s *Scheduler) scheduleOne() {
|
||||
}
|
||||
b := &api.Binding{
|
||||
TypeMeta: api.TypeMeta{Namespace: pod.Namespace},
|
||||
PodID: pod.ID,
|
||||
PodID: pod.Name,
|
||||
Host: dest,
|
||||
}
|
||||
if err := s.config.Binder.Bind(b); err != nil {
|
||||
@@ -82,5 +82,5 @@ func (s *Scheduler) scheduleOne() {
|
||||
s.config.Error(pod, err)
|
||||
return
|
||||
}
|
||||
record.Eventf(pod, "", string(api.PodWaiting), "scheduled", "Successfully assigned %v to %v", pod.ID, dest)
|
||||
record.Eventf(pod, "", string(api.PodWaiting), "scheduled", "Successfully assigned %v to %v", pod.Name, dest)
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ type fakeBinder struct {
|
||||
func (fb fakeBinder) Bind(binding *api.Binding) error { return fb.b(binding) }
|
||||
|
||||
func podWithID(id string) *api.Pod {
|
||||
return &api.Pod{TypeMeta: api.TypeMeta{ID: id, SelfLink: testapi.SelfLink("pods", id)}}
|
||||
return &api.Pod{TypeMeta: api.TypeMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)}}
|
||||
}
|
||||
|
||||
type mockScheduler struct {
|
||||
@@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
|
||||
var gotBinding *api.Binding
|
||||
c := &Config{
|
||||
MinionLister: scheduler.FakeMinionLister(
|
||||
api.MinionList{Items: []api.Minion{{TypeMeta: api.TypeMeta{ID: "machine1"}}}},
|
||||
api.MinionList{Items: []api.Minion{{TypeMeta: api.TypeMeta{Name: "machine1"}}}},
|
||||
),
|
||||
Algorithm: item.algo,
|
||||
Binder: fakeBinder{func(b *api.Binding) error {
|
||||
|
Reference in New Issue
Block a user