mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Merge pull request #13815 from robertabbott/abbott/kubelet_get_instead_of_list
Auto commit by PR queue bot
This commit is contained in:
commit
ee7168d868
@ -207,7 +207,11 @@ func NewMainKubelet(
|
|||||||
fieldSelector := fields.Set{client.ObjectNameField: nodeName}.AsSelector()
|
fieldSelector := fields.Set{client.ObjectNameField: nodeName}.AsSelector()
|
||||||
listWatch := &cache.ListWatch{
|
listWatch := &cache.ListWatch{
|
||||||
ListFunc: func() (runtime.Object, error) {
|
ListFunc: func() (runtime.Object, error) {
|
||||||
return kubeClient.Nodes().List(labels.Everything(), fieldSelector)
|
obj, err := kubeClient.Nodes().Get(nodeName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &api.NodeList{Items: []api.Node{*obj}}, nil
|
||||||
},
|
},
|
||||||
WatchFunc: func(resourceVersion string) (watch.Interface, error) {
|
WatchFunc: func(resourceVersion string) (watch.Interface, error) {
|
||||||
return kubeClient.Nodes().Watch(labels.Everything(), fieldSelector, resourceVersion)
|
return kubeClient.Nodes().Watch(labels.Everything(), fieldSelector, resourceVersion)
|
||||||
@ -714,17 +718,7 @@ func (kl *Kubelet) GetNode() (*api.Node, error) {
|
|||||||
if kl.standaloneMode {
|
if kl.standaloneMode {
|
||||||
return nil, errors.New("no node entry for kubelet in standalone mode")
|
return nil, errors.New("no node entry for kubelet in standalone mode")
|
||||||
}
|
}
|
||||||
l, err := kl.nodeLister.List()
|
return kl.nodeLister.GetNodeInfo(kl.nodeName)
|
||||||
if err != nil {
|
|
||||||
return nil, errors.New("cannot list nodes")
|
|
||||||
}
|
|
||||||
nodeName := kl.nodeName
|
|
||||||
for _, n := range l.Items {
|
|
||||||
if n.Name == nodeName {
|
|
||||||
return &n, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("node %v not found", nodeName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starts garbage collection threads.
|
// Starts garbage collection threads.
|
||||||
|
@ -18,7 +18,6 @@ package kubelet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -966,7 +965,12 @@ type testNodeLister struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ls testNodeLister) GetNodeInfo(id string) (*api.Node, error) {
|
func (ls testNodeLister) GetNodeInfo(id string) (*api.Node, error) {
|
||||||
return nil, errors.New("not implemented")
|
for _, node := range ls.nodes {
|
||||||
|
if node.Name == id {
|
||||||
|
return &node, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Node with name: %s does not exist", id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls testNodeLister) List() (api.NodeList, error) {
|
func (ls testNodeLister) List() (api.NodeList, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user