mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 19:52:42 +00:00
kubelet: add GetNodeInfo implementation
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
@@ -51,7 +51,7 @@ type NodeController struct {
|
||||
staticResources *api.NodeResources
|
||||
nodes []string
|
||||
kubeClient client.Interface
|
||||
kubeletClient client.KubeletHealthChecker
|
||||
kubeletClient client.KubeletClient
|
||||
registerRetryCount int
|
||||
podEvictionTimeout time.Duration
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func NewNodeController(
|
||||
nodes []string,
|
||||
staticResources *api.NodeResources,
|
||||
kubeClient client.Interface,
|
||||
kubeletClient client.KubeletHealthChecker,
|
||||
kubeletClient client.KubeletClient,
|
||||
registerRetryCount int,
|
||||
podEvictionTimeout time.Duration) *NodeController {
|
||||
return &NodeController{
|
||||
@@ -219,7 +219,7 @@ func (s *NodeController) SyncNodeStatus() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nodes = s.DoChecks(nodes)
|
||||
nodes = s.UpdateNodesStatus(nodes)
|
||||
nodes, err = s.PopulateAddresses(nodes)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -304,13 +304,16 @@ func (s *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// DoChecks performs health checking for given list of nodes.
|
||||
func (s *NodeController) DoChecks(nodes *api.NodeList) *api.NodeList {
|
||||
// UpdateNodesStatus performs health checking for given list of nodes.
|
||||
func (s *NodeController) UpdateNodesStatus(nodes *api.NodeList) *api.NodeList {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(nodes.Items))
|
||||
for i := range nodes.Items {
|
||||
go func(node *api.Node) {
|
||||
node.Status.Conditions = s.DoCheck(node)
|
||||
if err := s.updateNodeInfo(node); err != nil {
|
||||
glog.Errorf("Can't collect information for node %s: %v", node.Name, err)
|
||||
}
|
||||
wg.Done()
|
||||
}(&nodes.Items[i])
|
||||
}
|
||||
@@ -318,6 +321,17 @@ func (s *NodeController) DoChecks(nodes *api.NodeList) *api.NodeList {
|
||||
return nodes
|
||||
}
|
||||
|
||||
func (s *NodeController) updateNodeInfo(node *api.Node) error {
|
||||
nodeInfo, err := s.kubeletClient.GetNodeInfo(node.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for key, value := range nodeInfo.Capacity {
|
||||
node.Spec.Capacity[key] = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DoCheck performs health checking for given node.
|
||||
func (s *NodeController) DoCheck(node *api.Node) []api.NodeCondition {
|
||||
var conditions []api.NodeCondition
|
||||
|
@@ -130,6 +130,10 @@ func (c *FakeKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.
|
||||
return api.PodStatusResult{}, errors.New("Not Implemented")
|
||||
}
|
||||
|
||||
func (c *FakeKubeletClient) GetNodeInfo(host string) (api.NodeInfo, error) {
|
||||
return api.NodeInfo{}, errors.New("Not Implemented")
|
||||
}
|
||||
|
||||
func (c *FakeKubeletClient) HealthCheck(host string) (probe.Result, error) {
|
||||
return c.Status, c.Err
|
||||
}
|
||||
|
Reference in New Issue
Block a user