Skip to content

Commit

Permalink
Merge pull request #1 from baderbuddy/patch-1
Browse files Browse the repository at this point in the history
Adding Ready Count
  • Loading branch information
mhausenblas authored Dec 31, 2019
2 parents 7907ce7 + 7640cba commit 220a827
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/fleet/overview.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,22 @@ func nodesOverview(cfg api.Config, context string) (string, error) {
return "", errors.Wrap(err, "Can't create a clientset based on config provided")
}
nodes, err := cs.CoreV1().Nodes().List(metav1.ListOptions{})
nodeCount := len(nodes.Items)
readyCount := 0
for _, node := range nodes.Items {
for _, nodeCondition := range node.Status.Conditions {
if nodeCondition.Type == "Ready" {
if nodeCondition.Status == "True" {
readyCount++
}
break
}
}
}
if err != nil {
return "", errors.Wrap(err, "Can't get nodes in cluster")
}
noverview := fmt.Sprintf("%v", len(nodes.Items))
noverview := fmt.Sprintf("%v/%v", readyCount, nodeCount)
return noverview, nil
}

Expand Down

0 comments on commit 220a827

Please sign in to comment.