Rename "minion" to "node" in few places.

pull/6/head
Wojciech Tyczynski 2015-09-09 16:18:17 +02:00
parent 45742e885c
commit cd1ac360de
13 changed files with 165 additions and 165 deletions

View File

@ -15,5 +15,5 @@ limitations under the License.
*/
// Package nodecontroller contains code for syncing cloud instances with
// minion registry
// node registry
package nodecontroller

View File

@ -545,21 +545,21 @@ func TestPrintEventsResultSorted(t *testing.T) {
VerifyDatesInOrder(out, "\n" /* rowDelimiter */, " " /* columnDelimiter */, t)
}
func TestPrintMinionStatus(t *testing.T) {
func TestPrintNodeStatus(t *testing.T) {
printer := NewHumanReadablePrinter(false, false, false, false, []string{})
table := []struct {
minion api.Node
node api.Node
status string
}{
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo1"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
},
status: "Ready",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo2"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
@ -567,7 +567,7 @@ func TestPrintMinionStatus(t *testing.T) {
status: "Ready,SchedulingDisabled",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo3"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{
{Type: api.NodeReady, Status: api.ConditionTrue},
@ -576,14 +576,14 @@ func TestPrintMinionStatus(t *testing.T) {
status: "Ready",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo4"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
},
status: "NotReady",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo5"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
@ -591,21 +591,21 @@ func TestPrintMinionStatus(t *testing.T) {
status: "NotReady,SchedulingDisabled",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo6"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: "InvalidValue", Status: api.ConditionTrue}}},
},
status: "Unknown",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo7"},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{}}},
},
status: "Unknown",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo8"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{Type: "InvalidValue", Status: api.ConditionTrue}}},
@ -613,7 +613,7 @@ func TestPrintMinionStatus(t *testing.T) {
status: "Unknown,SchedulingDisabled",
},
{
minion: api.Node{
node: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo9"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{{}}},
@ -624,12 +624,12 @@ func TestPrintMinionStatus(t *testing.T) {
for _, test := range table {
buffer := &bytes.Buffer{}
err := printer.PrintObj(&test.minion, buffer)
err := printer.PrintObj(&test.node, buffer)
if err != nil {
t.Fatalf("An error occurred printing Minion: %#v", err)
t.Fatalf("An error occurred printing Node: %#v", err)
}
if !contains(strings.Fields(buffer.String()), test.status) {
t.Fatalf("Expect printing minion %s with status %#v, got: %#v", test.minion.Name, test.status, buffer.String())
t.Fatalf("Expect printing node %s with status %#v, got: %#v", test.node.Name, test.status, buffer.String())
}
}
}

View File

@ -214,8 +214,8 @@ func NewMainKubelet(
}
nodeLister := &cache.StoreToNodeLister{Store: nodeStore}
// TODO: get the real minion object of ourself,
// and use the real minion name and UID.
// TODO: get the real node object of ourself,
// and use the real node name and UID.
// TODO: what is namespace for node?
nodeRef := &api.ObjectReference{
Kind: "Node",

View File

@ -56,10 +56,10 @@ import (
eventetcd "k8s.io/kubernetes/pkg/registry/event/etcd"
expcontrolleretcd "k8s.io/kubernetes/pkg/registry/experimental/controller/etcd"
limitrangeetcd "k8s.io/kubernetes/pkg/registry/limitrange/etcd"
"k8s.io/kubernetes/pkg/registry/minion"
nodeetcd "k8s.io/kubernetes/pkg/registry/minion/etcd"
"k8s.io/kubernetes/pkg/registry/namespace"
namespaceetcd "k8s.io/kubernetes/pkg/registry/namespace/etcd"
"k8s.io/kubernetes/pkg/registry/node"
nodeetcd "k8s.io/kubernetes/pkg/registry/node/etcd"
pvetcd "k8s.io/kubernetes/pkg/registry/persistentvolume/etcd"
pvcetcd "k8s.io/kubernetes/pkg/registry/persistentvolumeclaim/etcd"
podetcd "k8s.io/kubernetes/pkg/registry/pod/etcd"
@ -100,7 +100,7 @@ type Config struct {
DatabaseStorage storage.Interface
ExpDatabaseStorage storage.Interface
EventTTL time.Duration
MinionRegexp string
NodeRegexp string
KubeletClient client.KubeletClient
// allow downstream consumers to disable the core controller loops
EnableCoreControllers bool
@ -219,7 +219,7 @@ type Master struct {
// registries are internal client APIs for accessing the storage layer
// TODO: define the internal typed interface in a way that clients can
// also be replaced
nodeRegistry minion.Registry
nodeRegistry node.Registry
namespaceRegistry namespace.Registry
serviceRegistry service.Registry
endpointRegistry endpoint.Registry
@ -446,7 +446,7 @@ func (m *Master) init(c *Config) {
m.endpointRegistry = endpoint.NewRegistry(endpointsStorage)
nodeStorage, nodeStatusStorage := nodeetcd.NewREST(c.DatabaseStorage, c.EnableWatchCache, c.KubeletClient)
m.nodeRegistry = minion.NewRegistry(nodeStorage)
m.nodeRegistry = node.NewRegistry(nodeStorage)
serviceStorage := serviceetcd.NewREST(c.DatabaseStorage)
m.serviceRegistry = service.NewRegistry(serviceStorage)
@ -911,7 +911,7 @@ func (m *Master) needToReplaceTunnels(addrs []string) bool {
}
func (m *Master) getNodeAddresses() ([]string, error) {
nodes, err := m.nodeRegistry.ListMinions(api.NewDefaultContext(), labels.Everything(), fields.Everything())
nodes, err := m.nodeRegistry.ListNodes(api.NewDefaultContext(), labels.Everything(), fields.Everything())
if err != nil {
return nil, err
}

View File

@ -45,7 +45,7 @@ func TestGetServersToValidate(t *testing.T) {
config.DatabaseStorage = etcdstorage.NewEtcdStorage(fakeClient, latest.Codec, etcdtest.PathPrefix())
config.ExpDatabaseStorage = etcdstorage.NewEtcdStorage(fakeClient, explatest.Codec, etcdtest.PathPrefix())
master.nodeRegistry = registrytest.NewMinionRegistry([]string{"node1", "node2"}, api.NodeResources{})
master.nodeRegistry = registrytest.NewNodeRegistry([]string{"node1", "node2"}, api.NodeResources{})
servers := master.getServersToValidate(&config)

View File

@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package minion provides Registry interface and implementation for storing Minions.
package minion
// Package node provides Registry interface and implementation for storing Nodes.
package node

View File

@ -24,7 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api/rest"
client "k8s.io/kubernetes/pkg/client/unversioned"
etcdgeneric "k8s.io/kubernetes/pkg/registry/generic/etcd"
"k8s.io/kubernetes/pkg/registry/minion"
"k8s.io/kubernetes/pkg/registry/node"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
)
@ -79,17 +79,17 @@ func NewREST(s storage.Interface, useCacher bool, connection client.ConnectionIn
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Node).Name, nil
},
PredicateFunc: minion.MatchNode,
PredicateFunc: node.MatchNode,
EndpointName: "node",
CreateStrategy: minion.Strategy,
UpdateStrategy: minion.Strategy,
CreateStrategy: node.Strategy,
UpdateStrategy: node.Strategy,
Storage: storageInterface,
}
statusStore := *store
statusStore.UpdateStrategy = minion.StatusStrategy
statusStore.UpdateStrategy = node.StatusStrategy
return &REST{store, connection}, &StatusREST{store: &statusStore}
}
@ -97,7 +97,7 @@ func NewREST(s storage.Interface, useCacher bool, connection client.ConnectionIn
// Implement Redirector.
var _ = rest.Redirector(&REST{})
// ResourceLocation returns a URL to which one can send traffic for the specified minion.
// ResourceLocation returns a URL to which one can send traffic for the specified node.
func (r *REST) ResourceLocation(ctx api.Context, id string) (*url.URL, http.RoundTripper, error) {
return minion.ResourceLocation(r, r.connection, ctx, id)
return node.ResourceLocation(r, r.connection, ctx, id)
}

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package minion
package node
import (
"k8s.io/kubernetes/pkg/api"
@ -26,12 +26,12 @@ import (
// Registry is an interface for things that know how to store node.
type Registry interface {
ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*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
WatchMinions(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
ListNodes(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error)
CreateNode(ctx api.Context, node *api.Node) error
UpdateNode(ctx api.Context, node *api.Node) error
GetNode(ctx api.Context, nodeID string) (*api.Node, error)
DeleteNode(ctx api.Context, nodeID string) error
WatchNodes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}
// storage puts strong typing around storage calls
@ -45,7 +45,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
func (s *storage) ListNodes(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
obj, err := s.List(ctx, label, field)
if err != nil {
return nil, err
@ -54,21 +54,21 @@ func (s *storage) ListMinions(ctx api.Context, label labels.Selector, field fiel
return obj.(*api.NodeList), nil
}
func (s *storage) CreateMinion(ctx api.Context, node *api.Node) error {
func (s *storage) CreateNode(ctx api.Context, node *api.Node) error {
_, err := s.Create(ctx, node)
return err
}
func (s *storage) UpdateMinion(ctx api.Context, node *api.Node) error {
func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error {
_, _, err := s.Update(ctx, node)
return err
}
func (s *storage) WatchMinions(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
func (s *storage) WatchNodes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return s.Watch(ctx, label, field, resourceVersion)
}
func (s *storage) GetMinion(ctx api.Context, name string) (*api.Node, error) {
func (s *storage) GetNode(ctx api.Context, name string) (*api.Node, error) {
obj, err := s.Get(ctx, name)
if err != nil {
return nil, err
@ -76,7 +76,7 @@ func (s *storage) GetMinion(ctx api.Context, name string) (*api.Node, error) {
return obj.(*api.Node), nil
}
func (s *storage) DeleteMinion(ctx api.Context, name string) error {
func (s *storage) DeleteNode(ctx api.Context, name string) error {
_, err := s.Delete(ctx, name, nil)
return err
}

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package minion
package node
import (
"fmt"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package minion
package node
import (
"testing"

View File

@ -1,117 +0,0 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package registrytest
import (
"sync"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// MinionRegistry implements minion.Registry interface.
type MinionRegistry struct {
Err error
Minion string
Minions api.NodeList
sync.Mutex
}
// MakeMinionList constructs api.MinionList from list of minion names and a NodeResource.
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]
list.Items[i].Status.Capacity = nodeResources.Capacity
}
return &list
}
func NewMinionRegistry(minions []string, nodeResources api.NodeResources) *MinionRegistry {
return &MinionRegistry{
Minions: *MakeMinionList(minions, nodeResources),
}
}
func (r *MinionRegistry) SetError(err error) {
r.Lock()
defer r.Unlock()
r.Err = err
}
func (r *MinionRegistry) ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
r.Lock()
defer r.Unlock()
return &r.Minions, r.Err
}
func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Node) error {
r.Lock()
defer r.Unlock()
r.Minion = minion.Name
r.Minions.Items = append(r.Minions.Items, *minion)
return r.Err
}
func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Node) error {
r.Lock()
defer r.Unlock()
for i, node := range r.Minions.Items {
if node.Name == minion.Name {
r.Minions.Items[i] = *minion
return r.Err
}
}
return r.Err
}
func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) {
r.Lock()
defer r.Unlock()
if r.Err != nil {
return nil, r.Err
}
for _, node := range r.Minions.Items {
if node.Name == minionID {
return &node, nil
}
}
return nil, errors.NewNotFound("node", minionID)
}
func (r *MinionRegistry) DeleteMinion(ctx api.Context, minionID string) error {
r.Lock()
defer r.Unlock()
var newList []api.Node
for _, node := range r.Minions.Items {
if node.Name != minionID {
newList = append(newList, api.Node{ObjectMeta: api.ObjectMeta{Name: node.Name}})
}
}
r.Minions.Items = newList
return r.Err
}
func (r *MinionRegistry) WatchMinions(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return nil, r.Err
}

View File

@ -0,0 +1,117 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package registrytest
import (
"sync"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// NodeRegistry implements node.Registry interface.
type NodeRegistry struct {
Err error
Node string
Nodes api.NodeList
sync.Mutex
}
// MakeNodeList constructs api.NodeList from list of node names and a NodeResource.
func MakeNodeList(nodes []string, nodeResources api.NodeResources) *api.NodeList {
list := api.NodeList{
Items: make([]api.Node, len(nodes)),
}
for i := range nodes {
list.Items[i].Name = nodes[i]
list.Items[i].Status.Capacity = nodeResources.Capacity
}
return &list
}
func NewNodeRegistry(nodes []string, nodeResources api.NodeResources) *NodeRegistry {
return &NodeRegistry{
Nodes: *MakeNodeList(nodes, nodeResources),
}
}
func (r *NodeRegistry) SetError(err error) {
r.Lock()
defer r.Unlock()
r.Err = err
}
func (r *NodeRegistry) ListNodes(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
r.Lock()
defer r.Unlock()
return &r.Nodes, r.Err
}
func (r *NodeRegistry) CreateNode(ctx api.Context, node *api.Node) error {
r.Lock()
defer r.Unlock()
r.Node = node.Name
r.Nodes.Items = append(r.Nodes.Items, *node)
return r.Err
}
func (r *NodeRegistry) UpdateNode(ctx api.Context, node *api.Node) error {
r.Lock()
defer r.Unlock()
for i, item := range r.Nodes.Items {
if item.Name == node.Name {
r.Nodes.Items[i] = *node
return r.Err
}
}
return r.Err
}
func (r *NodeRegistry) GetNode(ctx api.Context, nodeID string) (*api.Node, error) {
r.Lock()
defer r.Unlock()
if r.Err != nil {
return nil, r.Err
}
for _, node := range r.Nodes.Items {
if node.Name == nodeID {
return &node, nil
}
}
return nil, errors.NewNotFound("node", nodeID)
}
func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error {
r.Lock()
defer r.Unlock()
var newList []api.Node
for _, node := range r.Nodes.Items {
if node.Name != nodeID {
newList = append(newList, api.Node{ObjectMeta: api.ObjectMeta{Name: node.Name}})
}
}
r.Nodes.Items = newList
return r.Err
}
func (r *NodeRegistry) WatchNodes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return nil, r.Err
}