diff --git a/cmd/kubecfg/kubecfg.go b/cmd/kubecfg/kubecfg.go index 5b13372d8d8..a119610ec8d 100644 --- a/cmd/kubecfg/kubecfg.go +++ b/cmd/kubecfg/kubecfg.go @@ -79,7 +79,7 @@ var parser = kubecfg.NewParser(map[string]runtime.Object{ "pods": &api.Pod{}, "services": &api.Service{}, "replicationControllers": &api.ReplicationController{}, - "minions": &api.Minion{}, + "minions": &api.Node{}, "events": &api.Event{}, }) diff --git a/pkg/api/register.go b/pkg/api/register.go index d508d73b1e4..0d4ef3a389b 100644 --- a/pkg/api/register.go +++ b/pkg/api/register.go @@ -31,8 +31,8 @@ func init() { &ReplicationController{}, &ServiceList{}, &Service{}, - &MinionList{}, - &Minion{}, + &NodeList{}, + &Node{}, &Status{}, &ServerOpList{}, &ServerOp{}, @@ -47,8 +47,8 @@ func init() { &BoundPods{}, ) // Legacy names are supported - Scheme.AddKnownTypeWithName("", "Node", &Minion{}) - Scheme.AddKnownTypeWithName("", "NodeList", &MinionList{}) + Scheme.AddKnownTypeWithName("", "Minion", &Node{}) + Scheme.AddKnownTypeWithName("", "MinionList", &NodeList{}) } func (*Pod) IsAnAPIObject() {} @@ -59,8 +59,8 @@ func (*Service) IsAnAPIObject() {} func (*ServiceList) IsAnAPIObject() {} func (*Endpoints) IsAnAPIObject() {} func (*EndpointsList) IsAnAPIObject() {} -func (*Minion) IsAnAPIObject() {} -func (*MinionList) IsAnAPIObject() {} +func (*Node) IsAnAPIObject() {} +func (*NodeList) IsAnAPIObject() {} func (*Binding) IsAnAPIObject() {} func (*Status) IsAnAPIObject() {} func (*ServerOp) IsAnAPIObject() {} diff --git a/pkg/api/types.go b/pkg/api/types.go index c1efe41dc64..54501dea5e0 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -672,10 +672,9 @@ type ResourceName string type ResourceList map[ResourceName]util.IntOrString -// Minion is a worker node in Kubernetenes -// The name of the minion according to etcd is in ObjectMeta.Name. -// TODO: Rename to Node -type Minion struct { +// Node is a worker node in Kubernetenes +// The name of the node according to etcd is in ObjectMeta.Name. +type Node struct { TypeMeta `json:",inline"` ObjectMeta `json:"metadata,omitempty"` @@ -686,12 +685,12 @@ type Minion struct { Status NodeStatus `json:"status,omitempty"` } -// MinionList is a list of minions. -type MinionList struct { +// NodeList is a list of minions. +type NodeList struct { TypeMeta `json:",inline"` ListMeta `json:"metadata,omitempty"` - Items []Minion `json:"items"` + Items []Node `json:"items"` } // Binding is written by a scheduler to cause a pod to be bound to a host. diff --git a/pkg/api/v1beta1/conversion.go b/pkg/api/v1beta1/conversion.go index e2eba5271c2..56a13ae20cb 100644 --- a/pkg/api/v1beta1/conversion.go +++ b/pkg/api/v1beta1/conversion.go @@ -137,7 +137,7 @@ func init() { }, // MinionList.Items had a wrong name in v1beta1 - func(in *newer.MinionList, out *MinionList, s conversion.Scope) error { + func(in *newer.NodeList, out *MinionList, s conversion.Scope) error { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { return err } @@ -150,7 +150,7 @@ func init() { out.Minions = out.Items return nil }, - func(in *MinionList, out *newer.MinionList, s conversion.Scope) error { + func(in *MinionList, out *newer.NodeList, s conversion.Scope) error { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { return err } @@ -444,7 +444,7 @@ func init() { return nil }, - func(in *newer.Minion, out *Minion, s conversion.Scope) error { + func(in *newer.Node, out *Minion, s conversion.Scope) error { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { return err } @@ -458,7 +458,7 @@ func init() { out.HostIP = in.Status.HostIP return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0) }, - func(in *Minion, out *newer.Minion, s conversion.Scope) error { + func(in *Minion, out *newer.Node, s conversion.Scope) error { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { return err } diff --git a/pkg/api/v1beta1/conversion_test.go b/pkg/api/v1beta1/conversion_test.go index 23d9b6dbc20..3e16ba5da44 100644 --- a/pkg/api/v1beta1/conversion_test.go +++ b/pkg/api/v1beta1/conversion_test.go @@ -31,7 +31,7 @@ func TestNodeConversion(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if _, ok := obj.(*newer.Minion); !ok { + if _, ok := obj.(*newer.Node); !ok { t.Errorf("unexpected type: %#v", obj) } @@ -39,7 +39,7 @@ func TestNodeConversion(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if _, ok := obj.(*newer.MinionList); !ok { + if _, ok := obj.(*newer.NodeList); !ok { t.Errorf("unexpected type: %#v", obj) } @@ -141,39 +141,39 @@ func TestMinionListConversionToNew(t *testing.T) { oldMinion := func(id string) current.Minion { return current.Minion{TypeMeta: current.TypeMeta{ID: id}} } - newMinion := func(id string) newer.Minion { - return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}} + newMinion := func(id string) newer.Node { + return newer.Node{ObjectMeta: newer.ObjectMeta{Name: id}} } oldMinions := []current.Minion{ oldMinion("foo"), oldMinion("bar"), } - newMinions := []newer.Minion{ + newMinions := []newer.Node{ newMinion("foo"), newMinion("bar"), } table := []struct { oldML *current.MinionList - newML *newer.MinionList + newML *newer.NodeList }{ { oldML: ¤t.MinionList{Items: oldMinions}, - newML: &newer.MinionList{Items: newMinions}, + newML: &newer.NodeList{Items: newMinions}, }, { oldML: ¤t.MinionList{Minions: oldMinions}, - newML: &newer.MinionList{Items: newMinions}, + newML: &newer.NodeList{Items: newMinions}, }, { oldML: ¤t.MinionList{ Items: oldMinions, Minions: []current.Minion{oldMinion("baz")}, }, - newML: &newer.MinionList{Items: newMinions}, + newML: &newer.NodeList{Items: newMinions}, }, } for _, item := range table { - got := &newer.MinionList{} + got := &newer.NodeList{} err := Convert(item.oldML, got) if err != nil { t.Errorf("Unexpected error: %v", err) @@ -188,19 +188,19 @@ func TestMinionListConversionToOld(t *testing.T) { oldMinion := func(id string) current.Minion { return current.Minion{TypeMeta: current.TypeMeta{ID: id}} } - newMinion := func(id string) newer.Minion { - return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}} + newMinion := func(id string) newer.Node { + return newer.Node{ObjectMeta: newer.ObjectMeta{Name: id}} } oldMinions := []current.Minion{ oldMinion("foo"), oldMinion("bar"), } - newMinions := []newer.Minion{ + newMinions := []newer.Node{ newMinion("foo"), newMinion("bar"), } - newML := &newer.MinionList{Items: newMinions} + newML := &newer.NodeList{Items: newMinions} oldML := ¤t.MinionList{ Items: oldMinions, Minions: oldMinions, diff --git a/pkg/api/v1beta2/conversion.go b/pkg/api/v1beta2/conversion.go index 3db6cd02213..3754b302b63 100644 --- a/pkg/api/v1beta2/conversion.go +++ b/pkg/api/v1beta2/conversion.go @@ -374,7 +374,7 @@ func init() { return nil }, - func(in *newer.Minion, out *Minion, s conversion.Scope) error { + func(in *newer.Node, out *Minion, s conversion.Scope) error { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { return err } @@ -388,7 +388,7 @@ func init() { out.HostIP = in.Status.HostIP return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0) }, - func(in *Minion, out *newer.Minion, s conversion.Scope) error { + func(in *Minion, out *newer.Node, s conversion.Scope) error { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { return err } diff --git a/pkg/api/v1beta2/conversion_test.go b/pkg/api/v1beta2/conversion_test.go index c8bd7ac285d..5df11e8ef4f 100644 --- a/pkg/api/v1beta2/conversion_test.go +++ b/pkg/api/v1beta2/conversion_test.go @@ -60,7 +60,7 @@ func TestNodeConversion(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if _, ok := obj.(*newer.Minion); !ok { + if _, ok := obj.(*newer.Node); !ok { t.Errorf("unexpected type: %#v", obj) } @@ -68,7 +68,7 @@ func TestNodeConversion(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if _, ok := obj.(*newer.MinionList); !ok { + if _, ok := obj.(*newer.NodeList); !ok { t.Errorf("unexpected type: %#v", obj) } diff --git a/pkg/api/v1beta3/conversion_test.go b/pkg/api/v1beta3/conversion_test.go index 215e9f6cb2d..22432818b1f 100644 --- a/pkg/api/v1beta3/conversion_test.go +++ b/pkg/api/v1beta3/conversion_test.go @@ -28,7 +28,7 @@ func TestNodeConversion(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if _, ok := obj.(*newer.Minion); !ok { + if _, ok := obj.(*newer.Node); !ok { t.Errorf("unexpected type: %#v", obj) } @@ -36,7 +36,7 @@ func TestNodeConversion(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if _, ok := obj.(*newer.MinionList); !ok { + if _, ok := obj.(*newer.NodeList); !ok { t.Errorf("unexpected type: %#v", obj) } diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 8fff5166cf4..eac28edda49 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -550,7 +550,7 @@ func ValidateBoundPod(pod *api.BoundPod) (errors []error) { } // ValidateMinion tests if required fields in the minion are set. -func ValidateMinion(minion *api.Minion) errs.ValidationErrorList { +func ValidateMinion(minion *api.Node) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} if len(minion.Namespace) != 0 { allErrs = append(allErrs, errs.NewFieldInvalid("namespace", minion.Namespace, "")) @@ -563,7 +563,7 @@ func ValidateMinion(minion *api.Minion) errs.ValidationErrorList { } // ValidateMinionUpdate tests to make sure a minion update can be applied. Modifies oldMinion. -func ValidateMinionUpdate(oldMinion *api.Minion, minion *api.Minion) errs.ValidationErrorList { +func ValidateMinionUpdate(oldMinion *api.Node, minion *api.Node) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} oldMinion.Labels = minion.Labels if !reflect.DeepEqual(oldMinion, minion) { diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 40ea9cf12e9..ef323a0c467 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -1077,7 +1077,7 @@ func TestValidateBoundPodNoName(t *testing.T) { func TestValidateMinion(t *testing.T) { validSelector := map[string]string{"a": "b"} invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"} - successCases := []api.Minion{ + successCases := []api.Node{ { ObjectMeta: api.ObjectMeta{ Name: "abc", @@ -1100,7 +1100,7 @@ func TestValidateMinion(t *testing.T) { } } - errorCases := map[string]api.Minion{ + errorCases := map[string]api.Node{ "zero-length Name": { ObjectMeta: api.ObjectMeta{ Name: "", @@ -1134,45 +1134,45 @@ func TestValidateMinion(t *testing.T) { func TestValidateMinionUpdate(t *testing.T) { tests := []struct { - oldMinion api.Minion - minion api.Minion + oldMinion api.Node + minion api.Node valid bool }{ - {api.Minion{}, api.Minion{}, true}, - {api.Minion{ + {api.Node{}, api.Node{}, true}, + {api.Node{ ObjectMeta: api.ObjectMeta{ Name: "foo"}}, - api.Minion{ + api.Node{ ObjectMeta: api.ObjectMeta{ Name: "bar"}, }, false}, - {api.Minion{ + {api.Node{ ObjectMeta: api.ObjectMeta{ Name: "foo", Labels: map[string]string{"foo": "bar"}, }, - }, api.Minion{ + }, api.Node{ ObjectMeta: api.ObjectMeta{ Name: "foo", Labels: map[string]string{"foo": "baz"}, }, }, true}, - {api.Minion{ + {api.Node{ ObjectMeta: api.ObjectMeta{ Name: "foo", }, - }, api.Minion{ + }, api.Node{ ObjectMeta: api.ObjectMeta{ Name: "foo", Labels: map[string]string{"foo": "baz"}, }, }, true}, - {api.Minion{ + {api.Node{ ObjectMeta: api.ObjectMeta{ Name: "foo", Labels: map[string]string{"bar": "foo"}, }, - }, api.Minion{ + }, api.Node{ ObjectMeta: api.ObjectMeta{ Name: "foo", Labels: map[string]string{"foo": "baz"}, diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 070255fd3be..a643cb708e8 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -604,7 +604,7 @@ func TestGetServerAPIVersions(t *testing.T) { func TestListMinions(t *testing.T) { c := &testClient{ Request: testRequest{Method: "GET", Path: "/minions"}, - Response: Response{StatusCode: 200, Body: &api.MinionList{ListMeta: api.ListMeta{ResourceVersion: "1"}}}, + Response: Response{StatusCode: 200, Body: &api.NodeList{ListMeta: api.ListMeta{ResourceVersion: "1"}}}, } response, err := c.Setup().Minions().List() c.Validate(t, response, err) @@ -613,14 +613,14 @@ func TestListMinions(t *testing.T) { func TestGetMinion(t *testing.T) { c := &testClient{ Request: testRequest{Method: "GET", Path: "/minions/1"}, - Response: Response{StatusCode: 200, Body: &api.Minion{ObjectMeta: api.ObjectMeta{Name: "minion-1"}}}, + Response: Response{StatusCode: 200, Body: &api.Node{ObjectMeta: api.ObjectMeta{Name: "minion-1"}}}, } response, err := c.Setup().Minions().Get("1") c.Validate(t, response, err) } func TestCreateMinion(t *testing.T) { - requestMinion := &api.Minion{ + requestMinion := &api.Node{ ObjectMeta: api.ObjectMeta{ Name: "minion-1", }, diff --git a/pkg/client/fake.go b/pkg/client/fake.go index 3eb7d6b9b59..a97d756c445 100644 --- a/pkg/client/fake.go +++ b/pkg/client/fake.go @@ -39,7 +39,7 @@ type Fake struct { Ctrl api.ReplicationController ServiceList api.ServiceList EndpointsList api.EndpointsList - MinionsList api.MinionList + MinionsList api.NodeList EventsList api.EventList Err error Watch watch.Interface diff --git a/pkg/client/fake_minions.go b/pkg/client/fake_minions.go index ca60f7699ee..e35cd922897 100644 --- a/pkg/client/fake_minions.go +++ b/pkg/client/fake_minions.go @@ -26,19 +26,19 @@ type FakeMinions struct { Fake *Fake } -func (c *FakeMinions) Get(name string) (*api.Minion, error) { +func (c *FakeMinions) Get(name string) (*api.Node, error) { c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-minion", Value: name}) - return &api.Minion{}, nil + return &api.Node{}, nil } -func (c *FakeMinions) List() (*api.MinionList, error) { +func (c *FakeMinions) List() (*api.NodeList, error) { c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-minions", Value: nil}) return &c.Fake.MinionsList, nil } -func (c *FakeMinions) Create(minion *api.Minion) (*api.Minion, error) { +func (c *FakeMinions) Create(minion *api.Node) (*api.Node, error) { c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-minion", Value: minion}) - return &api.Minion{}, nil + return &api.Node{}, nil } func (c *FakeMinions) Delete(id string) error { diff --git a/pkg/client/minions.go b/pkg/client/minions.go index e61d8a64c93..88120899248 100644 --- a/pkg/client/minions.go +++ b/pkg/client/minions.go @@ -23,9 +23,9 @@ type MinionsInterface interface { } type MinionInterface interface { - Get(id string) (result *api.Minion, err error) - Create(minion *api.Minion) (*api.Minion, error) - List() (*api.MinionList, error) + Get(id string) (result *api.Node, err error) + Create(minion *api.Node) (*api.Node, error) + List() (*api.NodeList, error) Delete(id string) error } @@ -40,22 +40,22 @@ func newMinions(c *Client) *minions { } // Create creates a new minion. -func (c *minions) Create(minion *api.Minion) (*api.Minion, error) { - result := &api.Minion{} +func (c *minions) Create(minion *api.Node) (*api.Node, error) { + result := &api.Node{} err := c.r.Post().Path("minions").Body(minion).Do().Into(result) return result, err } // List lists all the minions in the cluster. -func (c *minions) List() (*api.MinionList, error) { - result := &api.MinionList{} +func (c *minions) List() (*api.NodeList, error) { + result := &api.NodeList{} err := c.r.Get().Path("minions").Do().Into(result) return result, err } // Get gets an existing minion -func (c *minions) Get(id string) (*api.Minion, error) { - result := &api.Minion{} +func (c *minions) Get(id string) (*api.Node, error) { + result := &api.Node{} err := c.r.Get().Path("minions").Path(id).Do().Into(result) return result, err } diff --git a/pkg/cloudprovider/controller/minioncontroller.go b/pkg/cloudprovider/controller/minioncontroller.go index 961fdf594e8..8d2c4d7d695 100644 --- a/pkg/cloudprovider/controller/minioncontroller.go +++ b/pkg/cloudprovider/controller/minioncontroller.go @@ -73,7 +73,7 @@ func (s *MinionController) SyncStatic(period time.Duration) error { if registered.Has(minionID) { continue } - _, err := s.kubeClient.Minions().Create(&api.Minion{ + _, err := s.kubeClient.Minions().Create(&api.Node{ ObjectMeta: api.ObjectMeta{Name: minionID}, Spec: api.NodeSpec{ Capacity: s.staticResources.Capacity, @@ -101,7 +101,7 @@ func (s *MinionController) SyncCloud() error { if err != nil { return err } - minionMap := make(map[string]*api.Minion) + minionMap := make(map[string]*api.Node) for _, minion := range minions.Items { minionMap[minion.Name] = &minion } @@ -128,8 +128,8 @@ func (s *MinionController) SyncCloud() error { return nil } -// cloudMinions constructs and returns api.MinionList from cloudprovider. -func (s *MinionController) cloudMinions() (*api.MinionList, error) { +// cloudMinions constructs and returns api.NodeList from cloudprovider. +func (s *MinionController) cloudMinions() (*api.NodeList, error) { instances, ok := s.cloud.Instances() if !ok { return nil, fmt.Errorf("cloud doesn't support instances") @@ -138,8 +138,8 @@ func (s *MinionController) cloudMinions() (*api.MinionList, error) { if err != nil { return nil, err } - result := &api.MinionList{ - Items: make([]api.Minion, len(matches)), + result := &api.NodeList{ + Items: make([]api.Node, len(matches)), } for i := range matches { result.Items[i].Name = matches[i] diff --git a/pkg/cloudprovider/controller/minioncontroller_test.go b/pkg/cloudprovider/controller/minioncontroller_test.go index effc06594e1..bb40b7898d0 100644 --- a/pkg/cloudprovider/controller/minioncontroller_test.go +++ b/pkg/cloudprovider/controller/minioncontroller_test.go @@ -26,8 +26,8 @@ import ( fake_cloud "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake" ) -func newMinion(name string) *api.Minion { - return &api.Minion{ObjectMeta: api.ObjectMeta{Name: name}} +func newMinion(name string) *api.Node { + return &api.Node{ObjectMeta: api.ObjectMeta{Name: name}} } type FakeMinionHandler struct { @@ -35,12 +35,12 @@ type FakeMinionHandler struct { client.FakeMinions // Input: Hooks determine if request is valid or not - CreateHook func(*FakeMinionHandler, *api.Minion) bool - Existing []*api.Minion + CreateHook func(*FakeMinionHandler, *api.Node) bool + Existing []*api.Node // Output - CreatedMinions []*api.Minion - DeletedMinions []*api.Minion + CreatedMinions []*api.Node + DeletedMinions []*api.Node RequestCount int } @@ -48,7 +48,7 @@ func (c *FakeMinionHandler) Minions() client.MinionInterface { return c } -func (m *FakeMinionHandler) Create(minion *api.Minion) (*api.Minion, error) { +func (m *FakeMinionHandler) Create(minion *api.Node) (*api.Node, error) { defer func() { m.RequestCount++ }() if m.CreateHook == nil || m.CreateHook(m, minion) { m.CreatedMinions = append(m.CreatedMinions, minion) @@ -58,9 +58,9 @@ func (m *FakeMinionHandler) Create(minion *api.Minion) (*api.Minion, error) { } } -func (m *FakeMinionHandler) List() (*api.MinionList, error) { +func (m *FakeMinionHandler) List() (*api.NodeList, error) { defer func() { m.RequestCount++ }() - minions := []api.Minion{} + minions := []api.Node{} for i := 0; i < len(m.Existing); i++ { if !contains(m.Existing[i], m.DeletedMinions) { minions = append(minions, *m.Existing[i]) @@ -71,7 +71,7 @@ func (m *FakeMinionHandler) List() (*api.MinionList, error) { minions = append(minions, *m.CreatedMinions[i]) } } - return &api.MinionList{Items: minions}, nil + return &api.NodeList{Items: minions}, nil } func (m *FakeMinionHandler) Delete(id string) error { @@ -82,7 +82,7 @@ func (m *FakeMinionHandler) Delete(id string) error { func TestSyncStaticCreateMinion(t *testing.T) { fakeMinionHandler := &FakeMinionHandler{ - CreateHook: func(fake *FakeMinionHandler, minion *api.Minion) bool { + CreateHook: func(fake *FakeMinionHandler, minion *api.Node) bool { return true }, } @@ -104,7 +104,7 @@ func TestSyncStaticCreateMinion(t *testing.T) { func TestSyncStaticCreateMinionWithError(t *testing.T) { fakeMinionHandler := &FakeMinionHandler{ - CreateHook: func(fake *FakeMinionHandler, minion *api.Minion) bool { + CreateHook: func(fake *FakeMinionHandler, minion *api.Node) bool { if fake.RequestCount == 0 { return false } @@ -129,7 +129,7 @@ func TestSyncStaticCreateMinionWithError(t *testing.T) { func TestSyncCloudCreateMinion(t *testing.T) { fakeMinionHandler := &FakeMinionHandler{ - Existing: []*api.Minion{newMinion("minion0")}, + Existing: []*api.Node{newMinion("minion0")}, } instances := []string{"minion0", "minion1"} fakeCloud := fake_cloud.FakeCloud{ @@ -153,7 +153,7 @@ func TestSyncCloudCreateMinion(t *testing.T) { func TestSyncCloudDeleteMinion(t *testing.T) { fakeMinionHandler := &FakeMinionHandler{ - Existing: []*api.Minion{newMinion("minion0"), newMinion("minion1")}, + Existing: []*api.Node{newMinion("minion0"), newMinion("minion1")}, } instances := []string{"minion0"} fakeCloud := fake_cloud.FakeCloud{ @@ -177,7 +177,7 @@ func TestSyncCloudDeleteMinion(t *testing.T) { func TestSyncCloudRegexp(t *testing.T) { fakeMinionHandler := &FakeMinionHandler{ - Existing: []*api.Minion{newMinion("minion0")}, + Existing: []*api.Node{newMinion("minion0")}, } instances := []string{"minion0", "minion1", "node0"} fakeCloud := fake_cloud.FakeCloud{ @@ -199,7 +199,7 @@ func TestSyncCloudRegexp(t *testing.T) { } } -func contains(minion *api.Minion, minions []*api.Minion) bool { +func contains(minion *api.Node, minions []*api.Node) bool { for i := 0; i < len(minions); i++ { if minion.Name == minions[i].Name { return true diff --git a/pkg/kubecfg/resource_printer.go b/pkg/kubecfg/resource_printer.go index 1bef4e1cab2..cea32df1684 100644 --- a/pkg/kubecfg/resource_printer.go +++ b/pkg/kubecfg/resource_printer.go @@ -248,12 +248,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error { return nil } -func printMinion(minion *api.Minion, w io.Writer) error { +func printMinion(minion *api.Node, w io.Writer) error { _, err := fmt.Fprintf(w, "%s\t%s\n", minion.Name, labels.Set(minion.Labels)) return err } -func printMinionList(list *api.MinionList, w io.Writer) error { +func printMinionList(list *api.NodeList, w io.Writer) error { for _, minion := range list.Items { if err := printMinion(&minion, w); err != nil { return err diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index 384d6c84c1c..6af374784cb 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -296,12 +296,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error { return nil } -func printMinion(minion *api.Minion, w io.Writer) error { +func printMinion(minion *api.Node, w io.Writer) error { _, err := fmt.Fprintf(w, "%s\t%s\n", minion.Name, formatLabels(minion.Labels)) return err } -func printMinionList(list *api.MinionList, w io.Writer) error { +func printMinionList(list *api.NodeList, w io.Writer) error { for _, minion := range list.Items { if err := printMinion(&minion, w); err != nil { return err diff --git a/pkg/registry/etcd/etcd.go b/pkg/registry/etcd/etcd.go index faf8557118a..9dfc56f3a78 100644 --- a/pkg/registry/etcd/etcd.go +++ b/pkg/registry/etcd/etcd.go @@ -559,26 +559,26 @@ func makeMinionKey(minionID string) string { return "/registry/minions/" + minionID } -func (r *Registry) ListMinions(ctx api.Context) (*api.MinionList, error) { - minions := &api.MinionList{} +func (r *Registry) ListMinions(ctx api.Context) (*api.NodeList, error) { + minions := &api.NodeList{} err := r.ExtractToList("/registry/minions", minions) return minions, err } -func (r *Registry) CreateMinion(ctx api.Context, minion *api.Minion) error { +func (r *Registry) CreateMinion(ctx api.Context, minion *api.Node) error { // TODO: Add some validations. err := r.CreateObj(makeMinionKey(minion.Name), minion, 0) return etcderr.InterpretCreateError(err, "minion", minion.Name) } -func (r *Registry) UpdateMinion(ctx api.Context, minion *api.Minion) error { +func (r *Registry) UpdateMinion(ctx api.Context, minion *api.Node) error { // TODO: Add some validations. err := r.SetObj(makeMinionKey(minion.Name), minion) return etcderr.InterpretUpdateError(err, "minion", minion.Name) } -func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) { - var minion api.Minion +func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) { + var minion api.Node key := makeMinionKey(minionID) err := r.ExtractObj(key, &minion, false) if err != nil { diff --git a/pkg/registry/etcd/etcd_test.go b/pkg/registry/etcd/etcd_test.go index 18f52035502..a9f407a402b 100644 --- a/pkg/registry/etcd/etcd_test.go +++ b/pkg/registry/etcd/etcd_test.go @@ -1364,12 +1364,12 @@ func TestEtcdListMinions(t *testing.T) { Node: &etcd.Node{ Nodes: []*etcd.Node{ { - Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{ + Value: runtime.EncodeOrDie(latest.Codec, &api.Node{ ObjectMeta: api.ObjectMeta{Name: "foo"}, }), }, { - Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{ + Value: runtime.EncodeOrDie(latest.Codec, &api.Node{ ObjectMeta: api.ObjectMeta{Name: "bar"}, }), }, @@ -1393,7 +1393,7 @@ func TestEtcdCreateMinion(t *testing.T) { ctx := api.NewContext() fakeClient := tools.NewFakeEtcdClient(t) registry := NewTestEtcdRegistry(fakeClient) - err := registry.CreateMinion(ctx, &api.Minion{ + err := registry.CreateMinion(ctx, &api.Node{ ObjectMeta: api.ObjectMeta{Name: "foo"}, }) if err != nil { @@ -1405,7 +1405,7 @@ func TestEtcdCreateMinion(t *testing.T) { t.Errorf("unexpected error: %v", err) } - var minion api.Minion + var minion api.Node err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &minion) if err != nil { t.Errorf("unexpected error: %v", err) @@ -1419,7 +1419,7 @@ func TestEtcdCreateMinion(t *testing.T) { func TestEtcdGetMinion(t *testing.T) { ctx := api.NewContext() fakeClient := tools.NewFakeEtcdClient(t) - fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0) + fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Node{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) minion, err := registry.GetMinion(ctx, "foo") if err != nil { diff --git a/pkg/registry/minion/healthy_registry.go b/pkg/registry/minion/healthy_registry.go index 76054d7f9c5..a64bd9ac1c2 100644 --- a/pkg/registry/minion/healthy_registry.go +++ b/pkg/registry/minion/healthy_registry.go @@ -36,7 +36,7 @@ func NewHealthyRegistry(delegate Registry, client client.KubeletHealthChecker) R } } -func (r *HealthyRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) { +func (r *HealthyRegistry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) { minion, err := r.delegate.GetMinion(ctx, minionID) if minion == nil { return nil, ErrDoesNotExist @@ -58,16 +58,16 @@ func (r *HealthyRegistry) DeleteMinion(ctx api.Context, minionID string) error { return r.delegate.DeleteMinion(ctx, minionID) } -func (r *HealthyRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error { +func (r *HealthyRegistry) CreateMinion(ctx api.Context, minion *api.Node) error { return r.delegate.CreateMinion(ctx, minion) } -func (r *HealthyRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error { +func (r *HealthyRegistry) UpdateMinion(ctx api.Context, minion *api.Node) error { return r.delegate.UpdateMinion(ctx, minion) } -func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.MinionList, err error) { - result := &api.MinionList{} +func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.NodeList, err error) { + result := &api.NodeList{} list, err := r.delegate.ListMinions(ctx) if err != nil { return result, err diff --git a/pkg/registry/minion/healthy_registry_test.go b/pkg/registry/minion/healthy_registry_test.go index 2412f36fece..cae721a99c0 100644 --- a/pkg/registry/minion/healthy_registry_test.go +++ b/pkg/registry/minion/healthy_registry_test.go @@ -45,7 +45,7 @@ func TestBasicDelegation(t *testing.T) { if !reflect.DeepEqual(list, &mockMinionRegistry.Minions) { t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list) } - err = healthy.CreateMinion(ctx, &api.Minion{ + err = healthy.CreateMinion(ctx, &api.Node{ ObjectMeta: api.ObjectMeta{Name: "foo"}, }) if err != nil { diff --git a/pkg/registry/minion/registry.go b/pkg/registry/minion/registry.go index b76e87f0e3e..ceea50b6aef 100644 --- a/pkg/registry/minion/registry.go +++ b/pkg/registry/minion/registry.go @@ -20,9 +20,9 @@ import "github.com/GoogleCloudPlatform/kubernetes/pkg/api" // MinionRegistry is an interface for things that know how to store minions. type Registry interface { - ListMinions(ctx api.Context) (*api.MinionList, error) - CreateMinion(ctx api.Context, minion *api.Minion) error - UpdateMinion(ctx api.Context, minion *api.Minion) error - GetMinion(ctx api.Context, minionID string) (*api.Minion, error) + ListMinions(ctx api.Context) (*api.NodeList, error) + CreateMinion(ctx api.Context, minion *api.Node) error + UpdateMinion(ctx api.Context, minion *api.Node) error + GetMinion(ctx api.Context, minionID string) (*api.Node, error) DeleteMinion(ctx api.Context, minionID string) error } diff --git a/pkg/registry/minion/rest.go b/pkg/registry/minion/rest.go index d9c887a1e5f..3a2e52901f6 100644 --- a/pkg/registry/minion/rest.go +++ b/pkg/registry/minion/rest.go @@ -47,7 +47,7 @@ var ErrDoesNotExist = errors.New("The requested resource does not exist.") var ErrNotHealty = errors.New("The requested minion is not healthy.") func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) { - minion, ok := obj.(*api.Minion) + minion, ok := obj.(*api.Node) if !ok { return nil, fmt.Errorf("not a minion: %#v", obj) } @@ -93,11 +93,11 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj } func (rs *REST) New() runtime.Object { - return &api.Minion{} + return &api.Node{} } func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) { - minion, ok := obj.(*api.Minion) + minion, ok := obj.(*api.Node) if !ok { return nil, fmt.Errorf("not a minion: %#v", obj) } @@ -121,8 +121,8 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE }), nil } -func (rs *REST) toApiMinion(name string) *api.Minion { - return &api.Minion{ObjectMeta: api.ObjectMeta{Name: name}} +func (rs *REST) toApiMinion(name string) *api.Node { + return &api.Node{ObjectMeta: api.ObjectMeta{Name: name}} } // ResourceLocation returns a URL to which one can send traffic for the specified minion. diff --git a/pkg/registry/minion/rest_test.go b/pkg/registry/minion/rest_test.go index 4b818cb4c60..6f4d39e2867 100644 --- a/pkg/registry/minion/rest_test.go +++ b/pkg/registry/minion/rest_test.go @@ -28,28 +28,28 @@ import ( func TestMinionREST(t *testing.T) { ms := NewREST(registrytest.NewMinionRegistry([]string{"foo", "bar"}, api.NodeResources{})) ctx := api.NewContext() - if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Minion).Name != "foo" { + if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Node).Name != "foo" { t.Errorf("missing expected object") } - if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Minion).Name != "bar" { + if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Node).Name != "bar" { t.Errorf("missing expected object") } if _, err := ms.Get(ctx, "baz"); err != ErrDoesNotExist { t.Errorf("has unexpected object") } - c, err := ms.Create(ctx, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "baz"}}) + c, err := ms.Create(ctx, &api.Node{ObjectMeta: api.ObjectMeta{Name: "baz"}}) if err != nil { t.Errorf("insert failed") } obj := <-c - if !api.HasObjectMetaSystemFieldValues(&obj.Object.(*api.Minion).ObjectMeta) { + if !api.HasObjectMetaSystemFieldValues(&obj.Object.(*api.Node).ObjectMeta) { t.Errorf("storage did not populate object meta field values") } - if m, ok := obj.Object.(*api.Minion); !ok || m.Name != "baz" { + if m, ok := obj.Object.(*api.Node); !ok || m.Name != "baz" { t.Errorf("insert return value was weird: %#v", obj) } - if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Minion).Name != "baz" { + if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Node).Name != "baz" { t.Errorf("insert didn't actually insert") } @@ -74,14 +74,14 @@ func TestMinionREST(t *testing.T) { if err != nil { t.Errorf("got error calling List") } - expect := []api.Minion{ + expect := []api.Node{ { ObjectMeta: api.ObjectMeta{Name: "foo"}, }, { ObjectMeta: api.ObjectMeta{Name: "baz"}, }, } - nodeList := list.(*api.MinionList) + nodeList := list.(*api.NodeList) if len(expect) != len(nodeList.Items) || !contains(nodeList, "foo") || !contains(nodeList, "baz") { t.Errorf("Unexpected list value: %#v", list) } @@ -97,12 +97,12 @@ func TestMinionStorageWithHealthCheck(t *testing.T) { ms := NewREST(&minionHealthRegistry) ctx := api.NewContext() - c, err := ms.Create(ctx, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m1"}}) + c, err := ms.Create(ctx, &api.Node{ObjectMeta: api.ObjectMeta{Name: "m1"}}) if err != nil { t.Errorf("insert failed") } result := <-c - if m, ok := result.Object.(*api.Minion); !ok || m.Name != "m1" { + if m, ok := result.Object.(*api.Node); !ok || m.Name != "m1" { t.Errorf("insert return value was weird: %#v", result) } if _, err := ms.Get(ctx, "m1"); err == nil { @@ -110,7 +110,7 @@ func TestMinionStorageWithHealthCheck(t *testing.T) { } } -func contains(nodes *api.MinionList, nodeID string) bool { +func contains(nodes *api.NodeList, nodeID string) bool { for _, node := range nodes.Items { if node.Name == nodeID { return true @@ -126,7 +126,7 @@ func TestMinionStorageInvalidUpdate(t *testing.T) { if err != nil { t.Errorf("Unexpected error: %v", err) } - minion, ok := obj.(*api.Minion) + minion, ok := obj.(*api.Node) if !ok { t.Fatalf("Object is not a minion: %#v", obj) } @@ -143,7 +143,7 @@ func TestMinionStorageValidUpdate(t *testing.T) { if err != nil { t.Errorf("Unexpected error: %v", err) } - minion, ok := obj.(*api.Minion) + minion, ok := obj.(*api.Node) if !ok { t.Fatalf("Object is not a minion: %#v", obj) } @@ -161,7 +161,7 @@ func TestMinionStorageValidatesCreate(t *testing.T) { ctx := api.NewContext() validSelector := map[string]string{"a": "b"} invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"} - failureCases := map[string]api.Minion{ + failureCases := map[string]api.Node{ "zero-length Name": { ObjectMeta: api.ObjectMeta{ Name: "", diff --git a/pkg/registry/pod/rest_test.go b/pkg/registry/pod/rest_test.go index 543ee02eff4..eee750f601c 100644 --- a/pkg/registry/pod/rest_test.go +++ b/pkg/registry/pod/rest_test.go @@ -370,8 +370,8 @@ func TestGetPodCloud(t *testing.T) { func TestMakePodStatus(t *testing.T) { fakeClient := client.Fake{ - MinionsList: api.MinionList{ - Items: []api.Minion{ + MinionsList: api.NodeList{ + Items: []api.Node{ { ObjectMeta: api.ObjectMeta{Name: "machine"}, }, diff --git a/pkg/registry/registrytest/minion.go b/pkg/registry/registrytest/minion.go index 889e8f1e818..7504826918d 100644 --- a/pkg/registry/registrytest/minion.go +++ b/pkg/registry/registrytest/minion.go @@ -25,13 +25,13 @@ import ( type MinionRegistry struct { Err error Minion string - Minions api.MinionList + Minions api.NodeList sync.Mutex } -func MakeMinionList(minions []string, nodeResources api.NodeResources) *api.MinionList { - list := api.MinionList{ - Items: make([]api.Minion, len(minions)), +func MakeMinionList(minions []string, nodeResources api.NodeResources) *api.NodeList { + list := api.NodeList{ + Items: make([]api.Node, len(minions)), } for i := range minions { list.Items[i].Name = minions[i] @@ -46,13 +46,13 @@ func NewMinionRegistry(minions []string, nodeResources api.NodeResources) *Minio } } -func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.MinionList, error) { +func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.NodeList, error) { r.Lock() defer r.Unlock() return &r.Minions, r.Err } -func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error { +func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Node) error { r.Lock() defer r.Unlock() r.Minion = minion.Name @@ -60,7 +60,7 @@ func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error return r.Err } -func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error { +func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Node) error { r.Lock() defer r.Unlock() for i, node := range r.Minions.Items { @@ -72,7 +72,7 @@ func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error return r.Err } -func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) { +func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) { r.Lock() defer r.Unlock() for _, node := range r.Minions.Items { @@ -86,10 +86,10 @@ func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minio func (r *MinionRegistry) DeleteMinion(ctx api.Context, minionID string) error { r.Lock() defer r.Unlock() - var newList []api.Minion + var newList []api.Node for _, node := range r.Minions.Items { if node.Name != minionID { - newList = append(newList, api.Minion{ObjectMeta: api.ObjectMeta{Name: node.Name}}) + newList = append(newList, api.Node{ObjectMeta: api.ObjectMeta{Name: node.Name}}) } } r.Minions.Items = newList diff --git a/pkg/registry/service/rest.go b/pkg/registry/service/rest.go index ba15a61083f..053cba6b15a 100644 --- a/pkg/registry/service/rest.go +++ b/pkg/registry/service/rest.go @@ -154,7 +154,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE }), nil } -func hostsFromMinionList(list *api.MinionList) []string { +func hostsFromMinionList(list *api.NodeList) []string { result := make([]string, len(list.Items)) for ix := range list.Items { result[ix] = list.Items[ix].Name diff --git a/pkg/scheduler/generic_scheduler.go b/pkg/scheduler/generic_scheduler.go index 3345886e4a5..62949167082 100644 --- a/pkg/scheduler/generic_scheduler.go +++ b/pkg/scheduler/generic_scheduler.go @@ -76,18 +76,18 @@ func (g *genericScheduler) selectHost(priorityList HostPriorityList) (string, er // Filters the minions to find the ones that fit based on the given predicate functions // Each minion is passed through the predicate functions to determine if it is a fit -func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicate, nodes api.MinionList) (api.MinionList, error) { - filtered := []api.Minion{} +func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicate, nodes api.NodeList) (api.NodeList, error) { + filtered := []api.Node{} machineToPods, err := MapPodsToMachines(podLister) if err != nil { - return api.MinionList{}, err + return api.NodeList{}, err } for _, node := range nodes.Items { fits := true for _, predicate := range predicates { fit, err := predicate(pod, machineToPods[node.Name], node.Name) if err != nil { - return api.MinionList{}, err + return api.NodeList{}, err } if !fit { fits = false @@ -98,7 +98,7 @@ func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicat filtered = append(filtered, node) } } - return api.MinionList{Items: filtered}, nil + return api.NodeList{Items: filtered}, nil } // Prioritizes the minions by running the individual priority functions sequentially. diff --git a/pkg/scheduler/generic_scheduler_test.go b/pkg/scheduler/generic_scheduler_test.go index 977c28c576b..baae91564f7 100644 --- a/pkg/scheduler/generic_scheduler_test.go +++ b/pkg/scheduler/generic_scheduler_test.go @@ -83,9 +83,9 @@ func reverseNumericPriority(pod api.Pod, podLister PodLister, minionLister Minio return reverseResult, nil } -func makeMinionList(nodeNames []string) api.MinionList { - result := api.MinionList{ - Items: make([]api.Minion, len(nodeNames)), +func makeMinionList(nodeNames []string) api.NodeList { + result := api.NodeList{ + Items: make([]api.Node, len(nodeNames)), } for ix := range nodeNames { result.Items[ix].Name = nodeNames[ix] diff --git a/pkg/scheduler/listers.go b/pkg/scheduler/listers.go index 5d0a72aa829..152650e399f 100644 --- a/pkg/scheduler/listers.go +++ b/pkg/scheduler/listers.go @@ -23,15 +23,15 @@ import ( // MinionLister interface represents anything that can list minions for a scheduler. type MinionLister interface { - List() (list api.MinionList, err error) + List() (list api.NodeList, err error) } // FakeMinionLister implements MinionLister on a []string for test purposes. -type FakeMinionLister api.MinionList +type FakeMinionLister api.NodeList // List returns minions as a []string. -func (f FakeMinionLister) List() (api.MinionList, error) { - return api.MinionList(f), nil +func (f FakeMinionLister) List() (api.NodeList, error) { + return api.NodeList(f), nil } // PodLister interface represents anything that can list pods for a scheduler. diff --git a/pkg/scheduler/predicates.go b/pkg/scheduler/predicates.go index 782ca86399d..f21cac453fd 100644 --- a/pkg/scheduler/predicates.go +++ b/pkg/scheduler/predicates.go @@ -27,14 +27,14 @@ import ( ) type NodeInfo interface { - GetNodeInfo(nodeID string) (*api.Minion, error) + GetNodeInfo(nodeID string) (*api.Node, error) } type StaticNodeInfo struct { - *api.MinionList + *api.NodeList } -func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) { +func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error) { for ix := range nodes.Items { if nodes.Items[ix].Name == nodeID { return &nodes.Items[ix], nil @@ -47,7 +47,7 @@ type ClientNodeInfo struct { *client.Client } -func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) { +func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error) { return nodes.Minions().Get(nodeID) } diff --git a/pkg/scheduler/predicates_test.go b/pkg/scheduler/predicates_test.go index 0b80ef0a000..1dd7498ea76 100644 --- a/pkg/scheduler/predicates_test.go +++ b/pkg/scheduler/predicates_test.go @@ -25,10 +25,10 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/util" ) -type FakeNodeInfo api.Minion +type FakeNodeInfo api.Node -func (n FakeNodeInfo) GetNodeInfo(nodeName string) (*api.Minion, error) { - node := api.Minion(n) +func (n FakeNodeInfo) GetNodeInfo(nodeName string) (*api.Node, error) { + node := api.Node(n) return &node, nil } @@ -111,7 +111,7 @@ func TestPodFitsResources(t *testing.T) { }, } for _, test := range tests { - node := api.Minion{Spec: api.NodeSpec{Capacity: makeResources(10, 20).Capacity}} + node := api.Node{Spec: api.NodeSpec{Capacity: makeResources(10, 20).Capacity}} fit := ResourceFit{FakeNodeInfo(node)} fits, err := fit.PodFitsResources(test.pod, test.existingPods, "machine") @@ -335,7 +335,7 @@ func TestPodFitsSelector(t *testing.T) { }, } for _, test := range tests { - node := api.Minion{ObjectMeta: api.ObjectMeta{Labels: test.labels}} + node := api.Node{ObjectMeta: api.ObjectMeta{Labels: test.labels}} fit := NodeSelector{FakeNodeInfo(node)} fits, err := fit.PodSelectorMatches(test.pod, []api.Pod{}, "machine") diff --git a/pkg/scheduler/priorities.go b/pkg/scheduler/priorities.go index 34a5bb651e2..c2ec09bbdec 100644 --- a/pkg/scheduler/priorities.go +++ b/pkg/scheduler/priorities.go @@ -37,7 +37,7 @@ func calculateScore(requested, capacity int, node string) int { // Calculate the occupancy on a node. 'node' has information about the resources on the node. // 'pods' is a list of pods currently scheduled on the node. -func calculateOccupancy(pod api.Pod, node api.Minion, pods []api.Pod) HostPriority { +func calculateOccupancy(pod api.Pod, node api.Node, pods []api.Pod) HostPriority { totalCPU := 0 totalMemory := 0 for _, existingPod := range pods { diff --git a/pkg/scheduler/priorities_test.go b/pkg/scheduler/priorities_test.go index e8ebd7c5e86..327d877f44d 100644 --- a/pkg/scheduler/priorities_test.go +++ b/pkg/scheduler/priorities_test.go @@ -25,8 +25,8 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/util" ) -func makeMinion(node string, cpu, memory int) api.Minion { - return api.Minion{ +func makeMinion(node string, cpu, memory int) api.Node { + return api.Node{ ObjectMeta: api.ObjectMeta{Name: node}, Spec: api.NodeSpec{ Capacity: api.ResourceList{ @@ -70,7 +70,7 @@ func TestLeastRequested(t *testing.T) { tests := []struct { pod api.Pod pods []api.Pod - nodes []api.Minion + nodes []api.Node expectedList HostPriorityList test string }{ @@ -87,7 +87,7 @@ func TestLeastRequested(t *testing.T) { Minion2 Score: (10 + 10) / 2 = 10 */ pod: api.Pod{Spec: noResources}, - nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, + nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, test: "nothing scheduled, nothing requested", }, @@ -104,7 +104,7 @@ func TestLeastRequested(t *testing.T) { Minion2 Score: (5 + 5) / 2 = 5 */ pod: api.Pod{Spec: cpuAndMemory}, - nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 6000, 10000)}, + nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 6000, 10000)}, expectedList: []HostPriority{{"machine1", 3}, {"machine2", 5}}, test: "nothing scheduled, resources requested, differently sized machines", }, @@ -121,7 +121,7 @@ func TestLeastRequested(t *testing.T) { Minion2 Score: (10 + 10) / 2 = 10 */ pod: api.Pod{Spec: noResources}, - nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, + nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, test: "no resources requested, pods scheduled", pods: []api.Pod{ @@ -144,7 +144,7 @@ func TestLeastRequested(t *testing.T) { Minion2 Score: (4 + 7.5) / 2 = 5 */ pod: api.Pod{Spec: noResources}, - nodes: []api.Minion{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)}, + nodes: []api.Node{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)}, expectedList: []HostPriority{{"machine1", 7}, {"machine2", 5}}, test: "no resources requested, pods scheduled with resources", pods: []api.Pod{ @@ -167,7 +167,7 @@ func TestLeastRequested(t *testing.T) { Minion2 Score: (4 + 5) / 2 = 4 */ pod: api.Pod{Spec: cpuAndMemory}, - nodes: []api.Minion{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)}, + nodes: []api.Node{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 4}}, test: "resources requested, pods scheduled with resources", pods: []api.Pod{ @@ -188,7 +188,7 @@ func TestLeastRequested(t *testing.T) { Minion2 Score: (4 + 8) / 2 = 6 */ pod: api.Pod{Spec: cpuAndMemory}, - nodes: []api.Minion{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 50000)}, + nodes: []api.Node{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 50000)}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 6}}, test: "resources requested, pods scheduled with resources, differently sized machines", pods: []api.Pod{ @@ -209,7 +209,7 @@ func TestLeastRequested(t *testing.T) { Minion2 Score: (0 + 5) / 2 = 2 */ pod: api.Pod{Spec: cpuOnly}, - nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, + nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 2}}, test: "requested resources exceed minion capacity", pods: []api.Pod{ @@ -219,7 +219,7 @@ func TestLeastRequested(t *testing.T) { }, { pod: api.Pod{Spec: noResources}, - nodes: []api.Minion{makeMinion("machine1", 0, 0), makeMinion("machine2", 0, 0)}, + nodes: []api.Node{makeMinion("machine1", 0, 0), makeMinion("machine2", 0, 0)}, expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}}, test: "zero minion resources, pods scheduled with resources", pods: []api.Pod{ @@ -230,7 +230,7 @@ func TestLeastRequested(t *testing.T) { } for _, test := range tests { - list, err := LeastRequestedPriority(test.pod, FakePodLister(test.pods), FakeMinionLister(api.MinionList{Items: test.nodes})) + list, err := LeastRequestedPriority(test.pod, FakePodLister(test.pods), FakeMinionLister(api.NodeList{Items: test.nodes})) if err != nil { t.Errorf("unexpected error: %v", err) } diff --git a/plugin/pkg/scheduler/factory/factory.go b/plugin/pkg/scheduler/factory/factory.go index 6fd88fbf2dd..cd3fc51f389 100644 --- a/plugin/pkg/scheduler/factory/factory.go +++ b/plugin/pkg/scheduler/factory/factory.go @@ -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 { diff --git a/plugin/pkg/scheduler/factory/factory_test.go b/plugin/pkg/scheduler/factory/factory_test.go index 6c7d504c495..80e1864bc08 100644 --- a/plugin/pkg/scheduler/factory/factory_test.go +++ b/plugin/pkg/scheduler/factory/factory_test.go @@ -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) diff --git a/plugin/pkg/scheduler/scheduler_test.go b/plugin/pkg/scheduler/scheduler_test.go index 2d95d6c0cf2..6d76475bd64 100644 --- a/plugin/pkg/scheduler/scheduler_test.go +++ b/plugin/pkg/scheduler/scheduler_test.go @@ -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 {