Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wrong current pod number #70

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pkg/capacity/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type containerMetric struct {
}

type podCount struct {
current int
current int64
allocatable int64
}

Expand All @@ -90,14 +90,15 @@ func buildClusterMetric(podList *corev1.PodList, pmList *v1beta1.PodMetricsList,
}

var totalPodAllocatable int64
var totalPodCurrent int64
for _, node := range nodeList.Items {
var tmpPodCount int
var tmpPodCount int64
for _, pod := range podList.Items {
if pod.Spec.NodeName == node.Name {
if pod.Spec.NodeName == node.Name && pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed {
tmpPodCount++
}
}

totalPodCurrent += tmpPodCount
totalPodAllocatable += node.Status.Allocatable.Pods().Value()
cm.nodeMetrics[node.Name] = &nodeMetric{
name: node.Name,
Expand All @@ -117,7 +118,7 @@ func buildClusterMetric(podList *corev1.PodList, pmList *v1beta1.PodMetricsList,
}
}

cm.podCount.current = len(podList.Items)
cm.podCount.current = totalPodCurrent
cm.podCount.allocatable = totalPodAllocatable

if nmList != nil {
Expand Down