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

Populate both CPU and Memory resource container metrics if one is specified #330

Merged
merged 1 commit into from
Oct 30, 2020
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: 11 additions & 0 deletions pkg/resourceprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ func (p *resourceProvider) assignForPod(pod apitypes.NamespacedName, resultsByNs
}
}

// check for any containers that have either memory usage or CPU usage, but not both
for _, containerMetric := range containerMetrics {
_, hasMemory := containerMetric.Usage[corev1.ResourceMemory]
_, hasCPU := containerMetric.Usage[corev1.ResourceCPU]
if hasMemory && !hasCPU {
containerMetric.Usage[corev1.ResourceCPU] = *resource.NewMilliQuantity(int64(0), resource.BinarySI)
} else if hasCPU && !hasMemory {
containerMetric.Usage[corev1.ResourceMemory] = *resource.NewMilliQuantity(int64(0), resource.BinarySI)
}
}

// store the time in the final format
*resTime = api.TimeInfo{
Timestamp: earliestTs.Time(),
Expand Down