mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-15 14:26:57 +00:00
Merge pull request #13785 from wojtek-t/minion_to_node_2
Auto commit by PR queue bot
This commit is contained in:
@@ -25,7 +25,7 @@ import (
|
||||
// ValidateEvent makes sure that the event makes sense.
|
||||
func ValidateEvent(event *api.Event) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
// TODO: There is no namespace required for minion
|
||||
// TODO: There is no namespace required for node.
|
||||
if event.InvolvedObject.Kind != "Node" &&
|
||||
event.Namespace != event.InvolvedObject.Namespace {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("involvedObject.namespace", event.InvolvedObject.Namespace, "namespace does not match involvedObject"))
|
||||
|
||||
@@ -44,7 +44,7 @@ type policy struct {
|
||||
// providers are in use. Either add "Realm", or assume "user@example.com"
|
||||
// format.
|
||||
|
||||
// TODO: Make the "cluster" Kinds be one API group (minions, bindings,
|
||||
// TODO: Make the "cluster" Kinds be one API group (nodes, bindings,
|
||||
// events, endpoints). The "user" Kinds are another (pods, services,
|
||||
// replicationControllers, operations) Make a "plugin", e.g. build
|
||||
// controller, be another group. That way when we add a new object to a
|
||||
|
||||
2
pkg/client/cache/doc.go
vendored
2
pkg/client/cache/doc.go
vendored
@@ -18,7 +18,7 @@ limitations under the License.
|
||||
// reducing the number of server calls you'd otherwise need to make.
|
||||
// Reflector watches a server and updates a Store. Two stores are provided;
|
||||
// one that simply caches objects (for example, to allow a scheduler to
|
||||
// list currently available minions), and one that additionally acts as
|
||||
// list currently available nodes), and one that additionally acts as
|
||||
// a FIFO queue (for example, to allow a scheduler to process incoming
|
||||
// pods).
|
||||
package cache
|
||||
|
||||
10
pkg/client/cache/listers.go
vendored
10
pkg/client/cache/listers.go
vendored
@@ -158,19 +158,19 @@ func (s storeToNodeConditionLister) List() (nodes api.NodeList, err error) {
|
||||
|
||||
// TODO Move this back to scheduler as a helper function that takes a Store,
|
||||
// rather than a method of StoreToNodeLister.
|
||||
// GetNodeInfo returns cached data for the minion 'id'.
|
||||
// GetNodeInfo returns cached data for the node 'id'.
|
||||
func (s *StoreToNodeLister) GetNodeInfo(id string) (*api.Node, error) {
|
||||
minion, exists, err := s.Get(&api.Node{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
node, exists, err := s.Get(&api.Node{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error retrieving minion '%v' from cache: %v", id, err)
|
||||
return nil, fmt.Errorf("error retrieving node '%v' from cache: %v", id, err)
|
||||
}
|
||||
|
||||
if !exists {
|
||||
return nil, fmt.Errorf("minion '%v' is not in cache", id)
|
||||
return nil, fmt.Errorf("node '%v' is not in cache", id)
|
||||
}
|
||||
|
||||
return minion.(*api.Node), nil
|
||||
return node.(*api.Node), nil
|
||||
}
|
||||
|
||||
// StoreToReplicationControllerLister gives a store List and Exists methods. The store must contain only ReplicationControllers.
|
||||
|
||||
2
pkg/client/cache/listers_test.go
vendored
2
pkg/client/cache/listers_test.go
vendored
@@ -25,7 +25,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
)
|
||||
|
||||
func TestStoreToMinionLister(t *testing.T) {
|
||||
func TestStoreToNodeLister(t *testing.T) {
|
||||
store := NewStore(MetaNamespaceKeyFunc)
|
||||
ids := sets.NewString("foo", "bar", "baz")
|
||||
for id := range ids {
|
||||
|
||||
16
pkg/client/cache/listwatch_test.go
vendored
16
pkg/client/cache/listwatch_test.go
vendored
@@ -61,10 +61,10 @@ func TestListWatchesCanList(t *testing.T) {
|
||||
namespace string
|
||||
fieldSelector fields.Selector
|
||||
}{
|
||||
// Minion
|
||||
// Node
|
||||
{
|
||||
location: testapi.Default.ResourcePath("minions", api.NamespaceAll, ""),
|
||||
resource: "minions",
|
||||
location: testapi.Default.ResourcePath("nodes", api.NamespaceAll, ""),
|
||||
resource: "nodes",
|
||||
namespace: api.NamespaceAll,
|
||||
fieldSelector: parseSelectorOrDie(""),
|
||||
},
|
||||
@@ -112,22 +112,22 @@ func TestListWatchesCanWatch(t *testing.T) {
|
||||
namespace string
|
||||
fieldSelector fields.Selector
|
||||
}{
|
||||
// Minion
|
||||
// Node
|
||||
{
|
||||
location: buildLocation(
|
||||
testapi.Default.ResourcePathWithPrefix("watch", "minions", api.NamespaceAll, ""),
|
||||
testapi.Default.ResourcePathWithPrefix("watch", "nodes", api.NamespaceAll, ""),
|
||||
buildQueryValues(url.Values{"resourceVersion": []string{""}})),
|
||||
rv: "",
|
||||
resource: "minions",
|
||||
resource: "nodes",
|
||||
namespace: api.NamespaceAll,
|
||||
fieldSelector: parseSelectorOrDie(""),
|
||||
},
|
||||
{
|
||||
location: buildLocation(
|
||||
testapi.Default.ResourcePathWithPrefix("watch", "minions", api.NamespaceAll, ""),
|
||||
testapi.Default.ResourcePathWithPrefix("watch", "nodes", api.NamespaceAll, ""),
|
||||
buildQueryValues(url.Values{"resourceVersion": []string{"42"}})),
|
||||
rv: "42",
|
||||
resource: "minions",
|
||||
resource: "nodes",
|
||||
namespace: api.NamespaceAll,
|
||||
fieldSelector: parseSelectorOrDie(""),
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
/*
|
||||
Package client contains the implementation of the client side communication with the
|
||||
Kubernetes master. The Client class provides methods for reading, creating, updating,
|
||||
and deleting pods, replication controllers, daemons, services, and minions.
|
||||
and deleting pods, replication controllers, daemons, services, and nodes.
|
||||
|
||||
Most consumers should use the Config object to create a Client:
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func getNodesResourceName() string {
|
||||
return "nodes"
|
||||
}
|
||||
|
||||
func TestListMinions(t *testing.T) {
|
||||
func TestListNodes(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
Method: "GET",
|
||||
@@ -43,7 +43,7 @@ func TestListMinions(t *testing.T) {
|
||||
c.Validate(t, response, err)
|
||||
}
|
||||
|
||||
func TestListMinionsLabels(t *testing.T) {
|
||||
func TestListNodesLabels(t *testing.T) {
|
||||
labelSelectorQueryParamName := api.LabelSelectorQueryParam(testapi.Default.Version())
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
@@ -73,19 +73,19 @@ func TestListMinionsLabels(t *testing.T) {
|
||||
c.Validate(t, receivedNodeList, err)
|
||||
}
|
||||
|
||||
func TestGetMinion(t *testing.T) {
|
||||
func TestGetNode(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
Method: "GET",
|
||||
Path: testapi.Default.ResourcePath(getNodesResourceName(), "", "1"),
|
||||
},
|
||||
Response: Response{StatusCode: 200, Body: &api.Node{ObjectMeta: api.ObjectMeta{Name: "minion-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Node{ObjectMeta: api.ObjectMeta{Name: "node-1"}}},
|
||||
}
|
||||
response, err := c.Setup(t).Nodes().Get("1")
|
||||
c.Validate(t, response, err)
|
||||
}
|
||||
|
||||
func TestGetMinionWithNoName(t *testing.T) {
|
||||
func TestGetNodeWithNoName(t *testing.T) {
|
||||
c := &testClient{Error: true}
|
||||
receivedNode, err := c.Setup(t).Nodes().Get("")
|
||||
if (err != nil) && (err.Error() != nameRequiredError) {
|
||||
@@ -95,10 +95,10 @@ func TestGetMinionWithNoName(t *testing.T) {
|
||||
c.Validate(t, receivedNode, err)
|
||||
}
|
||||
|
||||
func TestCreateMinion(t *testing.T) {
|
||||
requestMinion := &api.Node{
|
||||
func TestCreateNode(t *testing.T) {
|
||||
requestNode := &api.Node{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "minion-1",
|
||||
Name: "node-1",
|
||||
},
|
||||
Status: api.NodeStatus{
|
||||
Capacity: api.ResourceList{
|
||||
@@ -114,17 +114,17 @@ func TestCreateMinion(t *testing.T) {
|
||||
Request: testRequest{
|
||||
Method: "POST",
|
||||
Path: testapi.Default.ResourcePath(getNodesResourceName(), "", ""),
|
||||
Body: requestMinion},
|
||||
Body: requestNode},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: requestMinion,
|
||||
Body: requestNode,
|
||||
},
|
||||
}
|
||||
receivedMinion, err := c.Setup(t).Nodes().Create(requestMinion)
|
||||
c.Validate(t, receivedMinion, err)
|
||||
receivedNode, err := c.Setup(t).Nodes().Create(requestNode)
|
||||
c.Validate(t, receivedNode, err)
|
||||
}
|
||||
|
||||
func TestDeleteMinion(t *testing.T) {
|
||||
func TestDeleteNode(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
Method: "DELETE",
|
||||
@@ -136,8 +136,8 @@ func TestDeleteMinion(t *testing.T) {
|
||||
c.Validate(t, nil, err)
|
||||
}
|
||||
|
||||
func TestUpdateMinion(t *testing.T) {
|
||||
requestMinion := &api.Node{
|
||||
func TestUpdateNode(t *testing.T) {
|
||||
requestNode := &api.Node{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
@@ -157,8 +157,8 @@ func TestUpdateMinion(t *testing.T) {
|
||||
Method: "PUT",
|
||||
Path: testapi.Default.ResourcePath(getNodesResourceName(), "", "foo"),
|
||||
},
|
||||
Response: Response{StatusCode: 200, Body: requestMinion},
|
||||
Response: Response{StatusCode: 200, Body: requestNode},
|
||||
}
|
||||
response, err := c.Setup(t).Nodes().Update(requestMinion)
|
||||
response, err := c.Setup(t).Nodes().Update(requestNode)
|
||||
c.Validate(t, response, err)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
// FakeNodes implements MinionInterface. Meant to be embedded into a struct to get a default
|
||||
// FakeNodes implements NodeInterface. Meant to be embedded into a struct to get a default
|
||||
// implementation. This makes faking out just the method you want to test easier.
|
||||
type FakeNodes struct {
|
||||
Fake *Fake
|
||||
@@ -47,8 +47,8 @@ func (c *FakeNodes) List(label labels.Selector, field fields.Selector) (*api.Nod
|
||||
return obj.(*api.NodeList), err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) Create(minion *api.Node) (*api.Node, error) {
|
||||
obj, err := c.Fake.Invokes(NewRootCreateAction("nodes", minion), minion)
|
||||
func (c *FakeNodes) Create(node *api.Node) (*api.Node, error) {
|
||||
obj, err := c.Fake.Invokes(NewRootCreateAction("nodes", node), node)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -56,8 +56,8 @@ func (c *FakeNodes) Create(minion *api.Node) (*api.Node, error) {
|
||||
return obj.(*api.Node), err
|
||||
}
|
||||
|
||||
func (c *FakeNodes) Update(minion *api.Node) (*api.Node, error) {
|
||||
obj, err := c.Fake.Invokes(NewRootUpdateAction("nodes", minion), minion)
|
||||
func (c *FakeNodes) Update(node *api.Node) (*api.Node, error) {
|
||||
obj, err := c.Fake.Invokes(NewRootUpdateAction("nodes", node), node)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -74,14 +74,14 @@ func (c *FakeNodes) Watch(label labels.Selector, field fields.Selector, resource
|
||||
return c.Fake.InvokesWatch(NewRootWatchAction("nodes", label, field, resourceVersion))
|
||||
}
|
||||
|
||||
func (c *FakeNodes) UpdateStatus(minion *api.Node) (*api.Node, error) {
|
||||
func (c *FakeNodes) UpdateStatus(node *api.Node) (*api.Node, error) {
|
||||
action := CreateActionImpl{}
|
||||
action.Verb = "update"
|
||||
action.Resource = "nodes"
|
||||
action.Subresource = "status"
|
||||
action.Object = minion
|
||||
action.Object = node
|
||||
|
||||
obj, err := c.Fake.Invokes(action, minion)
|
||||
obj, err := c.Fake.Invokes(action, node)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user