Unverified Commit 3fa2e747 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #80642 from humblec/automated-cherry-pick-of-#78222-upstream-release-1.15

Automated cherry pick of #78222: Fix nil pointer dereference in metrics value calculator.
parents a8951d5e 388a9e1d
......@@ -138,12 +138,26 @@ func (s *volumeStatCalculator) calcAndStoreStats() {
// parsePodVolumeStats converts (internal) volume.Metrics to (external) stats.VolumeStats structures
func (s *volumeStatCalculator) parsePodVolumeStats(podName string, pvcRef *stats.PVCReference, metric *volume.Metrics, volSpec v1.Volume) stats.VolumeStats {
available := uint64(metric.Available.Value())
capacity := uint64(metric.Capacity.Value())
used := uint64(metric.Used.Value())
inodes := uint64(metric.Inodes.Value())
inodesFree := uint64(metric.InodesFree.Value())
inodesUsed := uint64(metric.InodesUsed.Value())
var available, capacity, used, inodes, inodesFree, inodesUsed uint64
if metric.Available != nil {
available = uint64(metric.Available.Value())
}
if metric.Capacity != nil {
capacity = uint64(metric.Capacity.Value())
}
if metric.Used != nil {
used = uint64(metric.Used.Value())
}
if metric.Inodes != nil {
inodes = uint64(metric.Inodes.Value())
}
if metric.InodesFree != nil {
inodesFree = uint64(metric.InodesFree.Value())
}
if metric.InodesUsed != nil {
inodesUsed = uint64(metric.InodesUsed.Value())
}
return stats.VolumeStats{
Name: podName,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment