Merge pull request #5030 from simon3z/nodeinfo

Add support for fetching node collected information
This commit is contained in:
Brian Grant
2015-03-10 14:05:41 -07:00
15 changed files with 220 additions and 40 deletions

View File

@@ -46,7 +46,7 @@ type NodeController struct {
staticResources *api.NodeResources
nodes []string
kubeClient client.Interface
kubeletClient client.KubeletHealthChecker
kubeletClient client.KubeletClient
registerRetryCount int
podEvictionTimeout time.Duration
lookupIP func(host string) ([]net.IP, error)
@@ -61,7 +61,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{
@@ -216,7 +216,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
@@ -301,13 +301,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])
}
@@ -315,6 +318,18 @@ 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
}
node.Status.NodeInfo = nodeInfo.NodeSystemInfo
return nil
}
// DoCheck performs health checking for given node.
func (s *NodeController) DoCheck(node *api.Node) []api.NodeCondition {
var conditions []api.NodeCondition

View File

@@ -124,6 +124,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
}