mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
Merge pull request #330 from joelsmith/master
Populate both CPU and Memory resource container metrics if one is specified
This commit is contained in:
commit
87c429b5c6
1 changed files with 11 additions and 0 deletions
|
|
@ -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
|
// store the time in the final format
|
||||||
*resTime = api.TimeInfo{
|
*resTime = api.TimeInfo{
|
||||||
Timestamp: earliestTs.Time(),
|
Timestamp: earliestTs.Time(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue