Skip to content

Commit

Permalink
some fixes for different pod states, bumping version to 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
robscott committed Feb 5, 2019
1 parent e8a6df1 commit ea17688
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions pkg/capacity/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ func buildClusterMetric(podList *corev1.PodList, pmList *v1beta1.PodMetricsList,
}

for _, pod := range podList.Items {
cm.addPodMetric(&pod)
if pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed {
cm.addPodMetric(&pod)
}
}

for _, node := range nodeList.Items {
Expand All @@ -122,9 +124,11 @@ func buildClusterMetric(podList *corev1.PodList, pmList *v1beta1.PodMetricsList,

for _, pod := range pmList.Items {
pm := cm.podMetrics[fmt.Sprintf("%s-%s", pod.GetNamespace(), pod.GetName())]
for _, container := range pod.Containers {
pm.cpu.utilization.Add(container.Usage["cpu"])
pm.memory.utilization.Add(container.Usage["memory"])
if pm != nil {
for _, container := range pod.Containers {
pm.cpu.utilization.Add(container.Usage["cpu"])
pm.memory.utilization.Add(container.Usage["memory"])
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of kube-capacity",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("kube-capacity version 0.1.2")
fmt.Println("kube-capacity version 0.1.3")
},
}

0 comments on commit ea17688

Please sign in to comment.