Skip to content

Commit

Permalink
Merge pull request #330 from joelsmith/master
Browse files Browse the repository at this point in the history
Populate both CPU and Memory resource container metrics if one is specified
  • Loading branch information
s-urbaniak authored Oct 30, 2020
2 parents 82450eb + bdc8b48 commit 87c429b
Showing 1 changed file with 11 additions and 0 deletions.
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

0 comments on commit 87c429b

Please sign in to comment.